Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
71b0ab8b
Commit
71b0ab8b
authored
Oct 05, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring container for speed.
parent
4263203d
Changes
32
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
1157 additions
and
1422 deletions
+1157
-1422
aliases.php
application/config/aliases.php
+52
-52
application.php
application/config/application.php
+114
-114
auth.php
application/config/auth.php
+63
-63
cache.php
application/config/cache.php
+51
-51
database.php
application/config/database.php
+72
-72
error.php
application/config/error.php
+86
-86
session.php
application/config/session.php
+93
-93
routes.php
application/routes.php
+1
-1
core.php
laravel/bootstrap/core.php
+3
-1
config.php
laravel/config.php
+153
-153
container.php
laravel/config/container.php
+165
-216
container.php
laravel/container.php
+14
-6
cookie.php
laravel/cookie.php
+10
-28
model.php
laravel/database/eloquent/model.php
+24
-1
query.php
laravel/database/query.php
+1
-1
facades.php
laravel/facades.php
+1
-7
input.php
laravel/input.php
+17
-26
laravel.php
laravel/laravel.php
+44
-9
loader.php
laravel/loader.php
+12
-25
paginator.php
laravel/paginator.php
+3
-14
proxy.php
laravel/proxy.php
+0
-21
request.php
laravel/request.php
+26
-55
response.php
laravel/response.php
+3
-3
router.php
laravel/routing/router.php
+4
-5
auth.php
laravel/security/auth.php
+18
-33
crypter.php
laravel/security/crypter.php
+23
-45
cookie.php
laravel/session/drivers/cookie.php
+5
-36
cookie.php
laravel/session/transporters/cookie.php
+2
-20
uri.php
laravel/uri.php
+14
-32
url.php
laravel/url.php
+1
-1
validator.php
laravel/validation/validator.php
+3
-4
view.php
laravel/view.php
+79
-148
No files found.
application/config/aliases.php
View file @
71b0ab8b
...
...
@@ -20,13 +20,13 @@ return array(
'Arr'
=>
'Laravel\\Arr'
,
'Asset'
=>
'Laravel\\Asset'
,
'Auth'
=>
'Laravel\\
Facades\\Auth'
,
'Auth'
=>
'Laravel\\
Auth'
,
'Benchmark'
=>
'Laravel\\Benchmark'
,
'Cache'
=>
'Laravel\\Cache'
,
'Config'
=>
'Laravel\\Config'
,
'Controller'
=>
'Laravel\\Controller'
,
'Cookie'
=>
'Laravel\\
Facades\\Cookie'
,
'Crypter'
=>
'Laravel\\
Facades\\Crypter'
,
'Cookie'
=>
'Laravel\\
Cookie'
,
'Crypter'
=>
'Laravel\\
Crypter'
,
'DB'
=>
'Laravel\\Database\\Manager'
,
'Eloquent'
=>
'Laravel\\Database\\Eloquent\\Model'
,
'File'
=>
'Laravel\\File'
,
...
...
@@ -34,20 +34,20 @@ return array(
'Hasher'
=>
'Laravel\\Facades\\Hasher'
,
'HTML'
=>
'Laravel\\HTML'
,
'Inflector'
=>
'Laravel\\Inflector'
,
'Input'
=>
'Laravel\\
Facades\\Input'
,
'Input'
=>
'Laravel\\
Input'
,
'IoC'
=>
'Laravel\\IoC'
,
'Lang'
=>
'Laravel\\Lang'
,
'Loader'
=>
'Laravel\\Loader'
,
'Messages'
=>
'Laravel\\Validation\\Messages'
,
'Package'
=>
'Laravel\\Facades\\Package'
,
'URI'
=>
'Laravel\\
Facades\\URI'
,
'URI'
=>
'Laravel\\
URI'
,
'URL'
=>
'Laravel\\URL'
,
'Redirect'
=>
'Laravel\\Redirect'
,
'Request'
=>
'Laravel\\
Facades\\Request'
,
'Request'
=>
'Laravel\\
Request'
,
'Response'
=>
'Laravel\\Response'
,
'Session'
=>
'Laravel\\Facades\\Session'
,
'Str'
=>
'Laravel\\Str'
,
'Validator'
=>
'Laravel\\Validation\\Validator'
,
'View'
=>
'Laravel\\
Facades\\View'
,
'View'
=>
'Laravel\\
View'
,
);
\ No newline at end of file
application/config/application.php
View file @
71b0ab8b
...
...
@@ -63,6 +63,25 @@ return array(
'encoding'
=>
'UTF-8'
,
/*
|--------------------------------------------------------------------------
| Auto-Loaded Packages
|--------------------------------------------------------------------------
|
| The packages that should be auto-loaded each time Laravel handles a
| request. These should generally be packages that you use on almost every
| request to your application.
|
| Each package specified here will be bootstrapped and can be conveniently
| used by your application's routes, models, and libraries.
|
| Note: The package names in this array should correspond to a package
| directory in application/packages.
|
*/
'packages'
=>
array
(),
/*
|--------------------------------------------------------------------------
| Application Key
...
...
@@ -93,23 +112,4 @@ return array(
'ssl'
=>
true
,
/*
|--------------------------------------------------------------------------
| Auto-Loaded Packages
|--------------------------------------------------------------------------
|
| The packages that should be auto-loaded each time Laravel handles a
| request. These should generally be packages that you use on almost every
| request to your application.
|
| Each package specified here will be bootstrapped and can be conveniently
| used by your application's routes, models, and libraries.
|
| Note: The package names in this array should correspond to a package
| directory in application/packages.
|
*/
'packages'
=>
array
(),
);
\ No newline at end of file
application/config/auth.php
View file @
71b0ab8b
application/config/cache.php
View file @
71b0ab8b
application/config/database.php
View file @
71b0ab8b
application/config/error.php
View file @
71b0ab8b
application/config/session.php
View file @
71b0ab8b
application/routes.php
View file @
71b0ab8b
...
...
@@ -37,7 +37,7 @@ return array(
|
*/
'GET /'
=>
function
()
'GET /'
=>
function
(
$application
)
{
return
View
::
make
(
'home.index'
);
},
...
...
laravel/bootstrap/core.php
View file @
71b0ab8b
...
...
@@ -61,7 +61,9 @@ IoC::$container = $container;
* for the lazy-loading of all of the Laravel core classes, as well as
* the developer created libraries and models.
*/
spl_autoload_register
(
array
(
$container
->
resolve
(
'laravel.loader'
),
'load'
));
spl_autoload_register
(
array
(
'Laravel\\Loader'
,
'load'
));
Loader
::
$aliases
=
Config
::
get
(
'aliases'
);
/**
* Define a few convenient global functions.
...
...
laravel/config.php
View file @
71b0ab8b
laravel/config/container.php
View file @
71b0ab8b
...
...
@@ -2,108 +2,34 @@
return
array
(
/*
|--------------------------------------------------------------------------
| Core Laravel Components
|--------------------------------------------------------------------------
*/
'laravel.auth'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Security\Auth
(
$c
->
resolve
(
'laravel.session'
));
}),
'laravel.cookie'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Cookie
(
$_COOKIE
);
}),
'laravel.crypter'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Security\Crypter
(
MCRYPT_RIJNDAEL_256
,
'cbc'
,
Config
::
get
(
'application.key'
));
}),
'laravel.hasher'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Security\Hashing\Bcrypt
(
8
,
false
);
}),
'laravel.input'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
$input
=
array
();
switch
(
$c
->
resolve
(
'laravel.request'
)
->
method
())
{
case
'GET'
:
$input
=
$_GET
;
break
;
case
'POST'
:
$input
=
$_POST
;
break
;
case
'PUT'
:
case
'DELETE'
:
if
(
$c
->
resolve
(
'laravel.request'
)
->
spoofed
())
{
$input
=
$_POST
;
}
else
{
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
}
}
unset
(
$input
[
Request
::
spoofer
]);
return
new
Input
(
$input
,
$_FILES
);
}),
'laravel.loader'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Loader
(
array
(
BASE_PATH
,
MODEL_PATH
,
LIBRARY_PATH
,
BASE_PATH
),
Config
::
get
(
'aliases'
));
}),
'laravel.request'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Request
(
$c
->
resolve
(
'laravel.uri'
),
$_SERVER
,
$_POST
);
}),
'laravel.uri'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
URI
(
$_SERVER
);
}),
'laravel.view'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
require_once
SYS_PATH
.
'view'
.
EXT
;
return
new
View_Factory
(
$c
->
resolve
(
'laravel.composer'
),
VIEW_PATH
,
STORAGE_PATH
.
'views/'
);
}),
'laravel.composer'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
View_Composer
(
require
APP_PATH
.
'composers'
.
EXT
);
}),
/*
|--------------------------------------------------------------------------
| Laravel Routing Components
|--------------------------------------------------------------------------
|
| The following components are used by the Laravel routing system.
|
| The router is used to map a given method and URI to a route intance.
|
| The route loader is responsible for loading the appropriates routes file
| for a given request URI, as well as loading all routes when the framework
| needs to find a named route wtihin the application.
|
| The route caller is responsible for receiving a route and taking the
| appropriate action to execute that route. Some routes delegate execution
| to a controller, so this class will also resolve controllers out of the
| container and call the appropriate methods on those controllers.
|
*/
'laravel.routing.router'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Routing\Router
(
$c
->
resolve
(
'laravel.routing.loader'
),
CONTROLLER_PATH
);
return
new
Routing\Router
(
$c
->
core
(
'routing.loader'
),
CONTROLLER_PATH
);
}),
...
...
@@ -122,6 +48,13 @@ return array(
|--------------------------------------------------------------------------
| Laravel Caching Components
|--------------------------------------------------------------------------
|
| The following components are used by the wonderfully, simple Laravel
| caching system. Each driver is resolved through the container.
|
| New cache drivers may be added to the framework by simply registering
| them into the container.
|
*/
'laravel.cache.apc'
=>
array
(
'resolver'
=>
function
(
$c
)
...
...
@@ -138,7 +71,7 @@ return array(
'laravel.cache.memcached'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Cache\Drivers\Memcached
(
$c
->
resolve
(
'laravel.cache.memcache.connection'
),
Config
::
get
(
'cache.key'
));
return
new
Cache\Drivers\Memcached
(
$c
->
core
(
'cache.memcache.connection'
),
Config
::
get
(
'cache.key'
));
}),
...
...
@@ -163,37 +96,53 @@ return array(
|--------------------------------------------------------------------------
| Laravel Session Components
|--------------------------------------------------------------------------
|
| The following components are used by the Laravel session system.
|
| The framework allows the session ID to be transported via a variety
| of different mechanisms by resolve the ID itself and the session
| transporter instance out of the container. This allows sessions
| to be used by clients who cannot receive cookies.
|
| The session manager is responsible for loading the session payload
| from the session driver, as well as examining the payload validitiy
| and things like the CSRF token.
|
| Like the caching components, each session driver is resolved via the
| container and new drivers may be added by registering them into the
| container. Several session drivers are "driven" by the cache drivers.
|
*/
'laravel.session.id'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
$c
->
resolve
(
'laravel.cookie'
)
->
get
(
'laravel_session'
);
return
Cookie
::
get
(
'laravel_session'
);
}),
'laravel.session.manager'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
$driver
=
$c
->
resolve
(
'laravel.session.'
.
Config
::
get
(
'session.driver'
));
$driver
=
$c
->
core
(
'session.'
.
Config
::
get
(
'session.driver'
));
return
new
Session\Manager
(
$driver
,
$c
->
resolve
(
'laravel.session.transporter'
));
return
new
Session\Manager
(
$driver
,
$c
->
core
(
'session.transporter'
));
}),
'laravel.session.transporter'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Session\Transporters\Cookie
(
$c
->
resolve
(
'laravel.cookie'
));
return
new
Session\Transporters\Cookie
;
}),
'laravel.session.apc'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Session\Drivers\APC
(
$c
->
resolve
(
'laravel.cache.apc'
));
return
new
Session\Drivers\APC
(
$c
->
core
(
'cache.apc'
));
}),
'laravel.session.cookie'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Session\Drivers\Cookie
(
$c
->
resolve
(
'laravel.crypter'
),
$c
->
resolve
(
'laravel.cookie'
));
return
new
Session\Drivers\Cookie
;
}),
...
...
@@ -211,7 +160,7 @@ return array(
'laravel.session.memcached'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Session\Drivers\Memcached
(
$c
->
resolve
(
'laravel.cache.memcached'
));
return
new
Session\Drivers\Memcached
(
$c
->
core
(
'cache.memcached'
));
}),
);
\ No newline at end of file
laravel/container.php
View file @
71b0ab8b
...
...
@@ -134,19 +134,23 @@ class Container {
* Resolve a core Laravel class from the container.
*
* <code>
* // Resolve the "laravel.
input
" class from the container
* // Resolve the "laravel.
router
" class from the container
* $input = IoC::container()->core('input');
*
* // Equivalent resolution using the "resolve" method
* $input = IoC::container()->resolve('laravel.input');
* $input = IoC::container()->resolve('laravel.router');
*
* // Pass an array of parameters to the resolver
* $input = IoC::container()->core('input', array('test'));
* </code>
*
* @param string $name
* @param array $parameters
* @return mixed
*/
public
function
core
(
$name
)
public
function
core
(
$name
,
$parameters
=
array
()
)
{
return
$this
->
resolve
(
"laravel.
{
$name
}
"
);
return
$this
->
resolve
(
"laravel.
{
$name
}
"
,
$parameters
);
}
/**
...
...
@@ -155,12 +159,16 @@ class Container {
* <code>
* // Get an instance of the "mailer" object registered in the container
* $mailer = IoC::container()->resolve('mailer');
*
* // Pass an array of parameters to the resolver
* $mailer = IoC::container()->resolve('mailer', array('test'));
* </code>
*
* @param string $name
* @param array $parameters
* @return mixed
*/
public
function
resolve
(
$name
)
public
function
resolve
(
$name
,
$parameters
=
array
()
)
{
if
(
array_key_exists
(
$name
,
$this
->
singletons
))
return
$this
->
singletons
[
$name
];
...
...
@@ -169,7 +177,7 @@ class Container {
throw
new
\Exception
(
"Error resolving [
$name
]. No resolver has been registered in the container."
);
}
$object
=
call_user_func
(
$this
->
registry
[
$name
][
'resolver'
],
$this
);
$object
=
call_user_func
(
$this
->
registry
[
$name
][
'resolver'
],
$this
,
$parameters
);
return
(
isset
(
$this
->
registry
[
$name
][
'singleton'
]))
?
$this
->
singletons
[
$name
]
=
$object
:
$object
;
}
...
...
laravel/cookie.php
View file @
71b0ab8b
...
...
@@ -2,33 +2,15 @@
class
Cookie
{
/**
* The cookies for the current request.
*
* @var array
*/
protected
$cookies
;
/**
* Create a new cookie manager instance.
*
* @param array $cookies
* @return void
*/
public
function
__construct
(
&
$cookies
)
{
$this
->
cookies
=&
$cookies
;
}
/**
* Determine if a cookie exists.
*
* @param string $name
* @return bool
*/
public
function
has
(
$name
)
public
static
function
has
(
$name
)
{
return
!
is_null
(
$this
->
get
(
$name
));
return
!
is_null
(
static
::
get
(
$name
));
}
/**
...
...
@@ -38,9 +20,9 @@ class Cookie {
* @param mixed $default
* @return string
*/
public
function
get
(
$name
,
$default
=
null
)
public
static
function
get
(
$name
,
$default
=
null
)
{
return
Arr
::
get
(
$
this
->
cookies
,
$name
,
$default
);
return
Arr
::
get
(
$
_COOKIE
,
$name
,
$default
);
}
/**
...
...
@@ -54,9 +36,9 @@ class Cookie {
* @param bool $http_only
* @return bool
*/
public
function
forever
(
$name
,
$value
,
$path
=
'/'
,
$domain
=
null
,
$secure
=
false
,
$http_only
=
false
)
public
static
function
forever
(
$name
,
$value
,
$path
=
'/'
,
$domain
=
null
,
$secure
=
false
,
$http_only
=
false
)
{
return
$this
->
put
(
$name
,
$value
,
2628000
,
$path
,
$domain
,
$secure
,
$http_only
);
return
static
::
put
(
$name
,
$value
,
2628000
,
$path
,
$domain
,
$secure
,
$http_only
);
}
/**
...
...
@@ -77,11 +59,11 @@ class Cookie {
* @param bool $http_only
* @return bool
*/
public
function
put
(
$name
,
$value
,
$minutes
=
0
,
$path
=
'/'
,
$domain
=
null
,
$secure
=
false
,
$http_only
=
false
)
public
static
function
put
(
$name
,
$value
,
$minutes
=
0
,
$path
=
'/'
,
$domain
=
null
,
$secure
=
false
,
$http_only
=
false
)
{
if
(
headers_sent
())
return
false
;
if
(
$minutes
<
0
)
unset
(
$
this
->
cookies
[
$name
]);
if
(
$minutes
<
0
)
unset
(
$
_COOKIE
[
$name
]);
// Since PHP needs the cookie lifetime in seconds, we will calculate it here.
// A "0" lifetime means the cookie expires when the browser closes.
...
...
@@ -96,9 +78,9 @@ class Cookie {
* @param string $name
* @return bool
*/
public
function
forget
(
$name
)
public
static
function
forget
(
$name
)
{
return
$this
->
put
(
$name
,
null
,
-
60
);
return
static
::
put
(
$name
,
null
,
-
60
);
}
}
\ No newline at end of file
laravel/database/eloquent/model.php
View file @
71b0ab8b
...
...
@@ -3,6 +3,7 @@
use
Laravel\IoC
;
use
Laravel\Str
;
use
Laravel\Inflector
;
use
Laravel\Paginator
;
use
Laravel\Database\Manager
as
DB
;
abstract
class
Model
{
...
...
@@ -223,6 +224,28 @@ abstract class Model {
return
(
count
(
$results
=
$this
->
take
(
1
)
->
_get
())
>
0
)
?
reset
(
$results
)
:
null
;
}
/**
* Get paginated model results as a Paginator instance.
*
* @param int $per_page
* @return Paginator
*/
private
function
_paginate
(
$per_page
=
null
)
{
$total
=
$this
->
query
->
count
();
// The number of models to show per page may be specified as a static property
// on the model. The models shown per page may also be overriden for the model
// by passing the number into this method. If the models to show per page is
// not available via either of these avenues, a default number will be shown.
if
(
is_null
(
$per_page
))
{
$per_page
=
(
property_exists
(
get_class
(
$this
),
'per_page'
))
?
static
::
$per_page
:
20
;
}
return
Paginator
::
make
(
$this
->
for_page
(
Paginator
::
page
(
$total
,
$per_page
),
$per_page
)
->
get
(),
$total
,
$per_page
);
}
/**
* Retrieve the query for a 1:1 relationship.
*
...
...
@@ -484,7 +507,7 @@ abstract class Model {
// To allow the "with", "get", "first", and "paginate" methods to be called both
// staticly and on an instance, we need to have private, underscored versions
// of the methods and handle them dynamically.
if
(
in_array
(
$method
,
array
(
'with'
,
'get'
,
'first'
)))
if
(
in_array
(
$method
,
array
(
'with'
,
'get'
,
'first'
,
'paginate'
)))
{
return
call_user_func_array
(
array
(
$this
,
'_'
.
$method
),
$parameters
);
}
...
...
laravel/database/query.php
View file @
71b0ab8b
...
...
@@ -525,7 +525,7 @@ class Query {
* @param array $columns
* @return Paginator
*/
public
function
paginate
(
$per_page
,
$columns
=
array
(
'*'
))
public
function
paginate
(
$per_page
=
20
,
$columns
=
array
(
'*'
))
{
// Calculate the current page for the request. The page number will be validated
// and adjusted by the Paginator class, so we can assume it is valid.
...
...
laravel/facades.php
View file @
71b0ab8b
...
...
@@ -32,12 +32,6 @@ abstract class Facade {
}
class
Auth
extends
Facade
{
public
static
$resolve
=
'laravel.auth'
;
}
class
Cookie
extends
Facade
{
public
static
$resolve
=
'laravel.cookie'
;
}
class
Crypter
extends
Facade
{
public
static
$resolve
=
'laravel.crypter'
;
}
class
Hasher
extends
Facade
{
public
static
$resolve
=
'laravel.hasher'
;
}
class
Input
extends
Facade
{
public
static
$resolve
=
'laravel.input'
;
}
class
Request
extends
Facade
{
public
static
$resolve
=
'laravel.request'
;
}
class
Session
extends
Facade
{
public
static
$resolve
=
'laravel.session'
;
}
\ No newline at end of file
class
URI
extends
Facade
{
public
static
$resolve
=
'laravel.uri'
;
}
class
View
extends
Facade
{
public
static
$resolve
=
'laravel.view'
;
}
\ No newline at end of file
laravel/input.php
View file @
71b0ab8b
...
...
@@ -7,14 +7,7 @@ class Input {
*
* @var array
*/
protected
$input
;
/**
* The $_FILES array for the current request.
*
* @var array
*/
protected
$files
;
protected
static
$input
;
/**
* The key used to store old input in the session.
...
...
@@ -24,16 +17,14 @@ class Input {
const
old_input
=
'laravel_old_input'
;
/**
*
Create a new input manager instance
.
*
Set the input for the current request
.
*
* @param array $input
* @param array $files
* @return void
*/
public
function
__construct
(
$input
,
$files
)
public
static
function
set
(
$input
)
{
$this
->
input
=
$input
;
$this
->
files
=
$files
;
static
::
$input
=
$input
;
}
/**
...
...
@@ -43,9 +34,9 @@ class Input {
*
* @return array
*/
public
function
all
()
public
static
function
all
()
{
return
array_merge
(
$this
->
get
(),
$this
->
file
());
return
array_merge
(
static
::
get
(),
static
::
file
());
}
/**
...
...
@@ -56,9 +47,9 @@ class Input {
* @param string $key
* @return bool
*/
public
function
has
(
$key
)
public
static
function
has
(
$key
)
{
return
(
!
is_null
(
$this
->
get
(
$key
))
and
trim
((
string
)
$this
->
get
(
$key
))
!==
''
);
return
(
!
is_null
(
static
::
get
(
$key
))
and
trim
((
string
)
static
::
get
(
$key
))
!==
''
);
}
/**
...
...
@@ -78,9 +69,9 @@ class Input {
* @param mixed $default
* @return mixed
*/
public
function
get
(
$key
=
null
,
$default
=
null
)
public
static
function
get
(
$key
=
null
,
$default
=
null
)
{
return
Arr
::
get
(
$this
->
input
,
$key
,
$default
);
return
Arr
::
get
(
static
::
$
input
,
$key
,
$default
);
}
/**
...
...
@@ -89,9 +80,9 @@ class Input {
* @param string $key
* @return bool
*/
public
function
had
(
$key
)
public
static
function
had
(
$key
)
{
return
(
!
is_null
(
$this
->
old
(
$key
))
and
trim
((
string
)
$this
->
old
(
$key
))
!==
''
);
return
(
!
is_null
(
static
::
old
(
$key
))
and
trim
((
string
)
static
::
old
(
$key
))
!==
''
);
}
/**
...
...
@@ -109,7 +100,7 @@ class Input {
* @param mixed $default
* @return string
*/
public
function
old
(
$key
=
null
,
$default
=
null
)
public
static
function
old
(
$key
=
null
,
$default
=
null
)
{
if
(
Config
::
get
(
'session.driver'
)
==
''
)
{
...
...
@@ -136,9 +127,9 @@ class Input {
* @param mixed $default
* @return array
*/
public
function
file
(
$key
=
null
,
$default
=
null
)
public
static
function
file
(
$key
=
null
,
$default
=
null
)
{
return
Arr
::
get
(
$
this
->
files
,
$key
,
$default
);
return
Arr
::
get
(
$
_FILES
,
$key
,
$default
);
}
/**
...
...
@@ -155,9 +146,9 @@ class Input {
* @param string $path
* @return bool
*/
public
function
upload
(
$key
,
$path
)
public
static
function
upload
(
$key
,
$path
)
{
return
array_key_exists
(
$key
,
$
this
->
files
)
?
File
::
upload
(
$key
,
$path
,
$this
->
files
)
:
false
;
return
array_key_exists
(
$key
,
$
_FILES
)
?
File
::
upload
(
$key
,
$path
,
$_FILES
)
:
false
;
}
}
\ No newline at end of file
laravel/laravel.php
View file @
71b0ab8b
...
...
@@ -32,23 +32,58 @@ if (Config::get('session.driver') !== '')
}
/**
* Resolve the incoming request instance from the IoC container
* and route the request to the proper route in the application.
* If a route is found, the route will be called with the current
* requst instance. If no route is found, the 404 response will
* be returned to the browser.
* Manually load some core classes that are used on every request
* This allows to avoid using the loader for these classes.
*/
require
SYS_PATH
.
'uri'
.
EXT
;
require
SYS_PATH
.
'request'
.
EXT
;
require
SYS_PATH
.
'routing/route'
.
EXT
;
require
SYS_PATH
.
'routing/router'
.
EXT
;
require
SYS_PATH
.
'routing/loader'
.
EXT
;
require
SYS_PATH
.
'routing/caller'
.
EXT
;
$request
=
$container
->
core
(
'request'
);
/**
* Gather the input to the application for the current request.
* The input will be gathered based on the current request method
* and will be set on the Input manager.
*/
$input
=
array
();
switch
(
Request
::
method
())
{
case
'GET'
:
$input
=
$_GET
;
break
;
case
'POST'
:
$input
=
$_POST
;
break
;
list
(
$method
,
$uri
)
=
array
(
$request
->
method
(),
$request
->
uri
());
case
'PUT'
:
case
'DELETE'
:
if
(
Request
::
spoofed
())
{
$input
=
$_POST
;
}
else
{
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
}
}
unset
(
$input
[
Request
::
spoofer
]);
Input
::
set
(
$input
);
/**
* Route the request to the proper route in the application. If a
* route is found, the route will be called with the current request
* instance. If no route is found, the 404 response will be returned
* to the browser.
*/
list
(
$method
,
$uri
)
=
array
(
Request
::
method
(),
URI
::
get
());
$route
=
$container
->
core
(
'routing.router'
)
->
route
(
$
request
,
$
method
,
$uri
);
$route
=
$container
->
core
(
'routing.router'
)
->
route
(
$method
,
$uri
);
if
(
!
is_null
(
$route
))
{
...
...
@@ -75,7 +110,7 @@ $response->content = $response->render();
*/
if
(
isset
(
$session
))
{
$flash
=
array
(
Input
::
old_input
=>
$container
->
core
(
'input'
)
->
get
());
$flash
=
array
(
Input
::
old_input
=>
Input
::
get
());
$session
->
close
(
$container
->
core
(
'session'
),
Config
::
get
(
'session'
),
$flash
);
}
...
...
laravel/loader.php
View file @
71b0ab8b
...
...
@@ -7,27 +7,14 @@ class Loader {
*
* @var array
*/
p
rotected
$paths
=
array
(
);
p
ublic
static
$paths
=
array
(
BASE_PATH
,
MODEL_PATH
,
LIBRARY_PATH
,
APP_PATH
);
/**
* The class aliases defined for the application.
*
* @var array
*/
protected
$aliases
=
array
();
/**
* Create a new class loader instance.
*
* @param array $paths
* @param array $aliases
* @return void
*/
public
function
__construct
(
$paths
,
$aliases
=
array
())
{
$this
->
paths
=
$paths
;
$this
->
aliases
=
$aliases
;
}
public
static
$aliases
=
array
();
/**
* Load the file for a given class.
...
...
@@ -43,7 +30,7 @@ class Loader {
* @param string $class
* @return void
*/
public
function
load
(
$class
)
public
static
function
load
(
$class
)
{
// All Laravel core classes follow a namespace to directory convention.
// We will replace all of the namespace slashes with directory slashes.
...
...
@@ -51,12 +38,12 @@ class Loader {
// Check to determine if an alias exists. If it does, we will define the
// alias and bail out. Aliases are defined for most used core classes.
if
(
array_key_exists
(
$class
,
$this
->
aliases
))
if
(
array_key_exists
(
$class
,
static
::
$
aliases
))
{
return
class_alias
(
$this
->
aliases
[
$class
],
$class
);
return
class_alias
(
static
::
$
aliases
[
$class
],
$class
);
}
foreach
(
$this
->
paths
as
$path
)
foreach
(
static
::
$
paths
as
$path
)
{
if
(
file_exists
(
$path
=
$path
.
$file
.
EXT
))
{
...
...
@@ -74,9 +61,9 @@ class Loader {
* @param string $class
* @return void
*/
public
function
alias
(
$alias
,
$class
)
public
static
function
alias
(
$alias
,
$class
)
{
$this
->
aliases
[
$alias
]
=
$class
;
static
::
$
aliases
[
$alias
]
=
$class
;
}
/**
...
...
@@ -85,9 +72,9 @@ class Loader {
* @param string $path
* @return void
*/
public
function
path
(
$path
)
public
static
function
path
(
$path
)
{
$this
->
paths
[]
=
rtrim
(
$path
,
'/'
)
.
'/'
;
static
::
$
paths
[]
=
rtrim
(
$path
,
'/'
)
.
'/'
;
}
/**
...
...
@@ -96,9 +83,9 @@ class Loader {
* @param string $alias
* @return void
*/
public
function
forget_alias
(
$alias
)
public
static
function
forget_alias
(
$alias
)
{
unset
(
$this
->
aliases
[
$alias
]);
unset
(
static
::
$
aliases
[
$alias
]);
}
}
\ No newline at end of file
laravel/paginator.php
View file @
71b0ab8b
...
...
@@ -54,14 +54,7 @@ class Paginator {
protected
$appendage
;
/**
* The current request instance.
*
* @var Request
*/
protected
$request
;
/**
* The paginatino elements that will be generated.
* The pagination elements that will be generated.
*
* @var array
*/
...
...
@@ -84,10 +77,6 @@ class Paginator {
$this
->
total
=
$total
;
$this
->
results
=
$results
;
$this
->
per_page
=
$per_page
;
// Grab the active request instance. This is used to determine the current URI
// and to determine if HTTPS links should be generated.
$this
->
request
=
IoC
::
container
()
->
core
(
'request'
);
}
/**
...
...
@@ -112,7 +101,7 @@ class Paginator {
*/
public
static
function
page
(
$total
,
$per_page
)
{
$page
=
I
oC
::
container
()
->
core
(
'input'
)
->
get
(
'page'
,
1
);
$page
=
I
nput
::
get
(
'page'
,
1
);
// The page will be validated and adjusted if it is less than one or greater
// than the last page. For example, if the current page is not an integer or
...
...
@@ -253,7 +242,7 @@ class Paginator {
// We will assume the page links should use HTTPS if the current request
// is also using HTTPS. Since pagination links automatically point to
// the current URI, this makes pretty good sense.
list
(
$uri
,
$secure
)
=
array
(
$this
->
request
->
uri
(),
$this
->
request
->
secure
());
list
(
$uri
,
$secure
)
=
array
(
URI
::
get
(),
Request
::
secure
());
return
HTML
::
link
(
$uri
.
$this
->
appendage
(
$element
,
$page
),
$text
,
array
(
'class'
=>
$class
),
$secure
);
}
...
...
laravel/proxy.php
deleted
100644 → 0
View file @
4263203d
<?php
namespace
Laravel
;
/**
* The Proxy class, like the File class, is primarily intended to get rid of
* the testability problems introduced by PHP's global functions.
*
* For instance, the APC cache driver calls the APC global functions. Instead of
* calling those functions directory in the driver, we inject a Proxy instance into
* the class, which allows us to stub the global functions.
*/
class
Proxy
{
/**
* Magic Method for calling any global function.
*/
public
function
__call
(
$method
,
$parameters
)
{
return
call_user_func_array
(
$method
,
$parameters
);
}
}
\ No newline at end of file
laravel/request.php
View file @
71b0ab8b
...
...
@@ -7,21 +7,7 @@ class Request {
*
* @var Routing\Route
*/
public
$route
;
/**
* The $_SERVER array for the current request.
*
* @var array
*/
protected
$server
;
/**
* The $_POST array for the current request.
*
* @var array
*/
protected
$post
;
public
static
$route
;
/**
* The request data key that is used to indicate a spoofed request method.
...
...
@@ -30,21 +16,6 @@ class Request {
*/
const
spoofer
=
'__spoofer'
;
/**
* Create a new request instance.
*
* @param URI $uri
* @param array $server
* @param array $post
* @return void
*/
public
function
__construct
(
URI
$uri
,
$server
,
$post
)
{
$this
->
uri
=
$uri
;
$this
->
post
=
$post
;
$this
->
server
=
$server
;
}
/**
* Get the URI for the current request.
*
...
...
@@ -52,9 +23,9 @@ class Request {
*
* @return string
*/
public
function
uri
()
public
static
function
uri
()
{
return
$this
->
uri
->
get
();
return
URI
::
get
();
}
/**
...
...
@@ -64,9 +35,9 @@ class Request {
*
* @return string
*/
public
function
format
()
public
static
function
format
()
{
return
((
$extension
=
pathinfo
(
$this
->
uri
->
get
(),
PATHINFO_EXTENSION
))
!==
''
)
?
$extension
:
'html'
;
return
((
$extension
=
pathinfo
(
URI
::
get
(),
PATHINFO_EXTENSION
))
!==
''
)
?
$extension
:
'html'
;
}
/**
...
...
@@ -78,9 +49,9 @@ class Request {
*
* @return string
*/
public
function
method
()
public
static
function
method
()
{
return
(
$this
->
spoofed
())
?
$this
->
post
[
Request
::
spoofer
]
:
$this
->
server
[
'REQUEST_METHOD'
];
return
(
static
::
spoofed
())
?
$_POST
[
Request
::
spoofer
]
:
$_SERVER
[
'REQUEST_METHOD'
];
}
/**
...
...
@@ -92,9 +63,9 @@ class Request {
* @param mixed $default
* @return string
*/
public
function
server
(
$key
=
null
,
$default
=
null
)
public
static
function
server
(
$key
=
null
,
$default
=
null
)
{
return
Arr
::
get
(
$
this
->
server
,
strtoupper
(
$key
),
$default
);
return
Arr
::
get
(
$
_SERVER
,
strtoupper
(
$key
),
$default
);
}
/**
...
...
@@ -106,9 +77,9 @@ class Request {
*
* @return bool
*/
public
function
spoofed
()
public
static
function
spoofed
()
{
return
is_array
(
$
this
->
post
)
and
array_key_exists
(
Request
::
spoofer
,
$this
->
post
);
return
is_array
(
$
_POST
)
and
array_key_exists
(
Request
::
spoofer
,
$_POST
);
}
/**
...
...
@@ -117,19 +88,19 @@ class Request {
* @param mixed $default
* @return string
*/
public
function
ip
(
$default
=
'0.0.0.0'
)
public
static
function
ip
(
$default
=
'0.0.0.0'
)
{
if
(
isset
(
$
this
->
server
[
'HTTP_X_FORWARDED_FOR'
]))
if
(
isset
(
$
_SERVER
[
'HTTP_X_FORWARDED_FOR'
]))
{
return
$
this
->
server
[
'HTTP_X_FORWARDED_FOR'
];
return
$
_SERVER
[
'HTTP_X_FORWARDED_FOR'
];
}
elseif
(
isset
(
$
this
->
server
[
'HTTP_CLIENT_IP'
]))
elseif
(
isset
(
$
_SERVER
[
'HTTP_CLIENT_IP'
]))
{
return
$
this
->
server
[
'HTTP_CLIENT_IP'
];
return
$
_SERVER
[
'HTTP_CLIENT_IP'
];
}
elseif
(
isset
(
$
this
->
server
[
'REMOTE_ADDR'
]))
elseif
(
isset
(
$
_SERVER
[
'REMOTE_ADDR'
]))
{
return
$
this
->
server
[
'REMOTE_ADDR'
];
return
$
_SERVER
[
'REMOTE_ADDR'
];
}
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
...
...
@@ -143,9 +114,9 @@ class Request {
*
* @return string
*/
public
function
protocol
()
public
static
function
protocol
()
{
return
(
isset
(
$
this
->
server
[
'HTTPS'
])
and
$this
->
server
[
'HTTPS'
]
!==
'off'
)
?
'https'
:
'http'
;
return
(
isset
(
$
_SERVER
[
'HTTPS'
])
and
$_SERVER
[
'HTTPS'
]
!==
'off'
)
?
'https'
:
'http'
;
}
/**
...
...
@@ -153,9 +124,9 @@ class Request {
*
* @return bool
*/
public
function
secure
()
public
static
function
secure
()
{
return
$this
->
protocol
()
==
'https'
;
return
static
::
protocol
()
==
'https'
;
}
/**
...
...
@@ -163,11 +134,11 @@ class Request {
*
* @return bool
*/
public
function
ajax
()
public
static
function
ajax
()
{
if
(
!
isset
(
$
this
->
server
[
'HTTP_X_REQUESTED_WITH'
]))
return
false
;
if
(
!
isset
(
$
_SERVER
[
'HTTP_X_REQUESTED_WITH'
]))
return
false
;
return
strtolower
(
$
this
->
server
[
'HTTP_X_REQUESTED_WITH'
])
===
'xmlhttprequest'
;
return
strtolower
(
$
_SERVER
[
'HTTP_X_REQUESTED_WITH'
])
===
'xmlhttprequest'
;
}
/**
...
...
@@ -175,6 +146,6 @@ class Request {
*
* @return Route
*/
public
function
route
()
{
return
$this
->
route
;
}
public
static
function
route
()
{
return
static
::
$
route
;
}
}
\ No newline at end of file
laravel/response.php
View file @
71b0ab8b
...
...
@@ -133,7 +133,7 @@ class Response {
*/
public
static
function
view
(
$view
,
$data
=
array
())
{
return
new
static
(
IoC
::
container
()
->
core
(
'view'
)
->
make
(
$view
,
$data
));
return
new
static
(
View
::
make
(
$view
,
$data
));
}
/**
...
...
@@ -153,7 +153,7 @@ class Response {
*/
public
static
function
of
(
$name
,
$data
=
array
())
{
return
new
static
(
IoC
::
container
()
->
core
(
'view'
)
->
of
(
$name
,
$data
));
return
new
static
(
View
::
of
(
$name
,
$data
));
}
/**
...
...
@@ -177,7 +177,7 @@ class Response {
*/
public
static
function
error
(
$code
,
$data
=
array
())
{
return
new
static
(
IoC
::
container
()
->
core
(
'view'
)
->
make
(
'error/'
.
$code
,
$data
),
$code
);
return
new
static
(
View
::
make
(
'error/'
.
$code
,
$data
),
$code
);
}
/**
...
...
laravel/routing/router.php
View file @
71b0ab8b
...
...
@@ -87,12 +87,11 @@ class Router {
/**
* Search the routes for the route matching a request method and URI.
*
* @param Request $request
* @param string $method
* @param string $uri
* @return Route
*/
public
function
route
(
Request
$request
,
$method
,
$uri
)
public
function
route
(
$method
,
$uri
)
{
$routes
=
$this
->
loader
->
load
(
$uri
);
...
...
@@ -104,7 +103,7 @@ class Router {
// no need to spin through all of the routes.
if
(
isset
(
$routes
[
$destination
]))
{
return
$request
->
route
=
new
Route
(
$destination
,
$routes
[
$destination
],
array
());
return
Request
::
$
route
=
new
Route
(
$destination
,
$routes
[
$destination
],
array
());
}
foreach
(
$routes
as
$keys
=>
$callback
)
...
...
@@ -120,13 +119,13 @@ class Router {
if
(
preg_match
(
'#^'
.
$this
->
translate_wildcards
(
$key
)
.
'$#'
,
$destination
))
{
return
$request
->
route
=
new
Route
(
$keys
,
$callback
,
$this
->
parameters
(
$destination
,
$key
));
return
Request
::
$
route
=
new
Route
(
$keys
,
$callback
,
$this
->
parameters
(
$destination
,
$key
));
}
}
}
}
return
$request
->
route
=
$this
->
route_to_controller
(
$method
,
$uri
,
$destination
);
return
Request
::
$
route
=
$this
->
route_to_controller
(
$method
,
$uri
,
$destination
);
}
/**
...
...
laravel/security/auth.php
View file @
71b0ab8b
<?php
namespace
Laravel\Security
;
use
Laravel\IoC
;
use
Laravel\Config
;
use
Laravel\Session\Payload
;
...
...
@@ -10,14 +11,7 @@ class Auth {
*
* @var object
*/
protected
$user
;
/**
* The session payload instance.
*
* @var Session\Payload
*/
protected
$session
;
protected
static
$user
;
/**
* The key used when storing the user ID in the session.
...
...
@@ -26,25 +20,14 @@ class Auth {
*/
const
user_key
=
'laravel_user_id'
;
/**
* Create a new authenticator instance.
*
* @param Session\Payload $session
* @return void
*/
public
function
__construct
(
Payload
$session
)
{
$this
->
session
=
$session
;
}
/**
* Determine if the current user of the application is authenticated.
*
* @return bool
*/
public
function
check
()
public
static
function
check
()
{
return
!
is_null
(
$this
->
user
());
return
!
is_null
(
static
::
user
());
}
/**
...
...
@@ -63,11 +46,13 @@ class Auth {
*
* @return object
*/
public
function
user
()
public
static
function
user
()
{
if
(
!
is_null
(
$this
->
user
))
return
$this
->
user
;
if
(
!
is_null
(
static
::
$user
))
return
static
::
$user
;
$id
=
IoC
::
container
()
->
core
(
'session'
)
->
get
(
Auth
::
user_key
);
return
$this
->
user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$this
->
session
->
get
(
Auth
::
user_key
)
);
return
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
}
/**
...
...
@@ -80,11 +65,11 @@ class Auth {
* @param string $password
* @return bool
*/
public
function
attempt
(
$username
,
$password
=
null
)
public
static
function
attempt
(
$username
,
$password
=
null
)
{
if
(
!
is_null
(
$user
=
call_user_func
(
Config
::
get
(
'auth.attempt'
),
$username
,
$password
)))
{
$this
->
remember
(
$user
);
static
::
remember
(
$user
);
return
true
;
}
...
...
@@ -100,11 +85,11 @@ class Auth {
* @param object $user
* @return void
*/
public
function
remember
(
$user
)
public
static
function
remember
(
$user
)
{
$this
->
user
=
$user
;
static
::
$
user
=
$user
;
$this
->
session
->
put
(
Auth
::
user_key
,
$user
->
id
);
IoC
::
container
()
->
core
(
'session'
)
->
put
(
Auth
::
user_key
,
$user
->
id
);
}
/**
...
...
@@ -114,13 +99,13 @@ class Auth {
*
* @return void
*/
public
function
logout
()
public
static
function
logout
()
{
call_user_func
(
Config
::
get
(
'auth.logout'
),
$this
->
user
());
call_user_func
(
Config
::
get
(
'auth.logout'
),
static
::
user
());
$this
->
user
=
null
;
static
::
$
user
=
null
;
$this
->
session
->
forget
(
Auth
::
user_key
);
IoC
::
container
()
->
core
(
'session'
)
->
forget
(
Auth
::
user_key
);
}
}
\ No newline at end of file
laravel/security/crypter.php
View file @
71b0ab8b
<?php
namespace
Laravel\Security
;
use
Laravel\Config
;
if
(
trim
(
Config
::
get
(
'application.key'
))
===
''
)
{
throw
new
\Exception
(
'The encryption class may not be used without an encryption key.'
);
}
class
Crypter
{
/**
...
...
@@ -7,44 +14,14 @@ class Crypter {
*
* @var string
*/
p
ublic
$cipher
;
p
rotected
static
$cipher
=
MCRYPT_RIJNDAEL_256
;
/**
* The encryption mode.
*
* @var string
*/
public
$mode
;
/**
* The encryption key.
*
* @var string
*/
public
$key
;
/**
* Create a new Crypter instance.
*
* A valid cipher and mode supported by the Mcrypt extension must be given to the constructor.
* Also, an encryption key (typically from the application configuration) must be specified.
*
* @param string $cipher
* @param string $mode
* @param string $key
* @return void
*/
public
function
__construct
(
$cipher
,
$mode
,
$key
)
{
$this
->
key
=
$key
;
$this
->
mode
=
$mode
;
$this
->
cipher
=
$cipher
;
if
(
trim
((
string
)
$this
->
key
)
===
''
)
{
throw
new
\Exception
(
'The encryption class may not be used without an encryption key.'
);
}
}
protected
static
$mode
=
'cbc'
;
/**
* Encrypt a string using Mcrypt.
...
...
@@ -60,10 +37,10 @@ class Crypter {
* @param string $value
* @return string
*/
public
function
encrypt
(
$value
)
public
static
function
encrypt
(
$value
)
{
// Determine the most appropriate random number generator for the
operating
// system and environment the application is running on.
// Determine the most appropriate random number generator for the
//
OS and
system and environment the application is running on.
if
(
defined
(
'MCRYPT_DEV_URANDOM'
))
{
$randomizer
=
MCRYPT_DEV_URANDOM
;
...
...
@@ -77,16 +54,14 @@ class Crypter {
$randomizer
=
MCRYPT_RAND
;
}
$iv
=
mcrypt_create_iv
(
$this
->
iv_size
(),
$randomizer
);
$iv
=
mcrypt_create_iv
(
static
::
iv_size
(),
$randomizer
);
return
base64_encode
(
$iv
.
mcrypt_encrypt
(
$this
->
cipher
,
$this
->
key
,
$value
,
$this
->
mode
,
$iv
));
return
base64_encode
(
$iv
.
mcrypt_encrypt
(
static
::
$cipher
,
Config
::
get
(
'application.key'
),
$value
,
static
::
$
mode
,
$iv
));
}
/**
* Decrypt a string using Mcrypt.
*
* The string will be decrypted using the cipher and mode specified when the crypter was created.
*
* <code>
* // Decrypt a string using the Mcrypt PHP extension
* $decrypted = Crypter::decrypt($secret);
...
...
@@ -95,7 +70,7 @@ class Crypter {
* @param string $value
* @return string
*/
public
function
decrypt
(
$value
)
public
static
function
decrypt
(
$value
)
{
// Since all encrypted strings generated by this class are base64 encoded, we will
// first attempt to base64 decode the string. If we can't do it, we'll bail out.
...
...
@@ -104,10 +79,13 @@ class Crypter {
throw
new
\Exception
(
'Decryption error. Input value is not valid base64 data.'
);
}
// Extract the input vector and the encrypted string from the value
list
(
$iv
,
$value
)
=
array
(
substr
(
$value
,
0
,
$this
->
iv_size
()),
substr
(
$value
,
$this
->
iv_size
()));
// Extract the input vector and the encrypted string from the value.
// These will be used by Mcrypt to properly decrypt the value.
$iv
=
substr
(
$value
,
0
,
static
::
iv_size
());
$value
=
substr
(
$value
,
static
::
iv_size
());
return
rtrim
(
mcrypt_decrypt
(
$this
->
cipher
,
$this
->
key
,
$value
,
$this
->
mode
,
$iv
),
"
\0
"
);
return
rtrim
(
mcrypt_decrypt
(
static
::
$cipher
,
Config
::
get
(
'application.key'
),
$value
,
static
::
$
mode
,
$iv
),
"
\0
"
);
}
/**
...
...
@@ -117,9 +95,9 @@ class Crypter {
*
* @return int
*/
pr
ivate
function
iv_size
()
pr
otected
static
function
iv_size
()
{
return
mcrypt_get_iv_size
(
$this
->
cipher
,
$this
->
mode
);
return
mcrypt_get_iv_size
(
static
::
$cipher
,
static
::
$
mode
);
}
}
\ No newline at end of file
laravel/session/drivers/cookie.php
View file @
71b0ab8b
...
...
@@ -4,37 +4,6 @@ use Laravel\Security\Crypter;
class
Cookie
implements
Driver
{
/**
* The crypter instance.
*
* All session cookies have an encrypted payload. Since the session contains sensitive
* data that cannot be compromised, it is important that the payload be encrypted using
* the strong encryption provided by the Crypter class.
*
* @var Crypter
*/
private
$crypter
;
/**
* The cookie manager instance.
*
* @var Cookie
*/
private
$cookies
;
/**
* Create a new Cookie session driver instance.
*
* @param Crypter $crypter
* @param Cookie $cookies
* @return void
*/
public
function
__construct
(
Crypter
$crypter
,
\Laravel\Cookie
$cookies
)
{
$this
->
crypter
=
$crypter
;
$this
->
cookies
=
$cookies
;
}
/**
* Load a session from storage by a given ID.
*
...
...
@@ -45,9 +14,9 @@ class Cookie implements Driver {
*/
public
function
load
(
$id
)
{
if
(
$this
->
cookies
->
has
(
'session_payload'
))
if
(
\Laravel\Cookie
::
has
(
'session_payload'
))
{
return
unserialize
(
$this
->
crypter
->
decrypt
(
$this
->
cookies
->
get
(
'session_payload'
)));
return
unserialize
(
Crypter
::
decrypt
(
\Laravel\Cookie
::
get
(
'session_payload'
)));
}
}
...
...
@@ -63,9 +32,9 @@ class Cookie implements Driver {
{
extract
(
$config
);
$payload
=
$this
->
crypter
->
encrypt
(
serialize
(
$session
));
$payload
=
Crypter
::
encrypt
(
serialize
(
$session
));
$this
->
cookies
->
put
(
'session_payload'
,
$payload
,
$lifetime
,
$path
,
$domain
);
\Laravel\Cookie
::
put
(
'session_payload'
,
$payload
,
$lifetime
,
$path
,
$domain
);
}
/**
...
...
@@ -76,7 +45,7 @@ class Cookie implements Driver {
*/
public
function
delete
(
$id
)
{
$this
->
cookies
->
forget
(
'session_payload'
);
\Laravel\Cookie
::
forget
(
'session_payload'
);
}
}
\ No newline at end of file
laravel/session/transporters/cookie.php
View file @
71b0ab8b
...
...
@@ -2,13 +2,6 @@
class
Cookie
implements
Transporter
{
/**
* The cookie manager instance.
*
* @var Cookie
*/
protected
$cookies
;
/**
* The name of the cookie used to store the session ID.
*
...
...
@@ -16,17 +9,6 @@ class Cookie implements Transporter {
*/
const
key
=
'laravel_session'
;
/**
* Create a new cookie session transporter instance.
*
* @param Cookie $cookie
* @return void
*/
public
function
__construct
(
\Laravel\Cookie
$cookies
)
{
$this
->
cookies
=
$cookies
;
}
/**
* Get the session identifier for the request.
*
...
...
@@ -35,7 +17,7 @@ class Cookie implements Transporter {
*/
public
function
get
(
$config
)
{
return
$this
->
cookies
->
get
(
Cookie
::
key
);
return
\Laravel\Cookie
::
get
(
Cookie
::
key
);
}
/**
...
...
@@ -52,7 +34,7 @@ class Cookie implements Transporter {
// deleted until the user closes their browser.
$minutes
=
(
!
$config
[
'expire_on_close'
])
?
$config
[
'lifetime'
]
:
0
;
$this
->
cookies
->
put
(
Cookie
::
key
,
$id
,
$minutes
,
$config
[
'path'
],
$config
[
'domain'
]);
\Laravel\Cookie
::
put
(
Cookie
::
key
,
$id
,
$minutes
,
$config
[
'path'
],
$config
[
'domain'
]);
}
}
\ No newline at end of file
laravel/uri.php
View file @
71b0ab8b
...
...
@@ -9,25 +9,7 @@ class URI {
*
* @var string
*/
protected
$uri
;
/**
* The $_SERVER array for the current request.
*
* @var array
*/
protected
$server
;
/**
* Create a new URI parser instance.
*
* @param array $server
* @return void
*/
public
function
__construct
(
$server
)
{
$this
->
server
=
$server
;
}
protected
static
$uri
;
/**
* Determine the request URI.
...
...
@@ -41,16 +23,16 @@ class URI {
*
* @return string
*/
public
function
get
()
public
static
function
get
()
{
if
(
!
is_null
(
$this
->
uri
))
return
$this
->
uri
;
if
(
!
is_null
(
static
::
$uri
))
return
static
::
$
uri
;
if
((
$uri
=
$this
->
from_server
())
===
false
)
if
((
$uri
=
static
::
from_server
())
===
false
)
{
throw
new
\Exception
(
'Malformed request URI. Request terminated.'
);
}
return
$this
->
uri
=
$this
->
format
(
$this
->
clean
(
$uri
));
return
static
::
$uri
=
static
::
format
(
static
::
clean
(
$uri
));
}
/**
...
...
@@ -68,9 +50,9 @@ class URI {
* @param mixed $default
* @return string
*/
public
function
segment
(
$segment
=
null
,
$default
=
null
)
public
static
function
segment
(
$segment
=
null
,
$default
=
null
)
{
$segments
=
Arr
::
without
(
explode
(
'/'
,
$this
->
get
()),
array
(
''
));
$segments
=
Arr
::
without
(
explode
(
'/'
,
static
::
get
()),
array
(
''
));
if
(
!
is_null
(
$segment
))
$segment
=
$segment
-
1
;
...
...
@@ -82,20 +64,20 @@ class URI {
*
* @return string
*/
protected
function
from_server
()
protected
static
function
from_server
()
{
// If the PATH_INFO $_SERVER element is set, we will use since it contains
// the request URI formatted perfectly for Laravel's routing engine.
if
(
isset
(
$
this
->
server
[
'PATH_INFO'
]))
if
(
isset
(
$
_SERVER
[
'PATH_INFO'
]))
{
return
$
this
->
server
[
'PATH_INFO'
];
return
$
_SERVER
[
'PATH_INFO'
];
}
// If the REQUEST_URI is set, we need to extract the URL path since this
// should return the URI formatted in a manner similar to PATH_INFO.
elseif
(
isset
(
$
this
->
server
[
'REQUEST_URI'
]))
elseif
(
isset
(
$
_SERVER
[
'REQUEST_URI'
]))
{
return
parse_url
(
$
this
->
server
[
'REQUEST_URI'
],
PHP_URL_PATH
);
return
parse_url
(
$
_SERVER
[
'REQUEST_URI'
],
PHP_URL_PATH
);
}
throw
new
\Exception
(
'Unable to determine the request URI.'
);
...
...
@@ -110,7 +92,7 @@ class URI {
* @param string $uri
* @return string
*/
protected
function
clean
(
$uri
)
protected
static
function
clean
(
$uri
)
{
foreach
(
array
(
parse_url
(
Config
::
get
(
'application.url'
),
PHP_URL_PATH
),
'/index.php'
)
as
$value
)
{
...
...
@@ -128,7 +110,7 @@ class URI {
* @param string $uri
* @return string
*/
protected
function
format
(
$uri
)
protected
static
function
format
(
$uri
)
{
return
((
$uri
=
trim
(
$uri
,
'/'
))
==
''
)
?
'/'
:
$uri
;
}
...
...
laravel/url.php
View file @
71b0ab8b
...
...
@@ -57,7 +57,7 @@ class URL {
*/
public
static
function
to_asset
(
$url
,
$https
=
null
)
{
if
(
is_null
(
$https
))
$https
=
IoC
::
container
()
->
core
(
'request'
)
->
secure
();
if
(
is_null
(
$https
))
$https
=
Request
::
secure
();
return
str_replace
(
'index.php/'
,
''
,
static
::
to
(
$url
,
$https
));
}
...
...
laravel/validation/validator.php
View file @
71b0ab8b
...
...
@@ -4,6 +4,7 @@ use Closure;
use
Laravel\IoC
;
use
Laravel\Str
;
use
Laravel\Lang
;
use
Laravel\Input
;
use
Laravel\Database\Manager
as
DB
;
class
Validator
{
...
...
@@ -304,9 +305,7 @@ class Validator {
$value
=
$this
->
attributes
[
$attribute
];
$files
=
IoC
::
container
()
->
resolve
(
'laravel.input'
)
->
file
();
return
(
array_key_exists
(
$attribute
,
$files
))
?
$value
[
'size'
]
/
1024
:
Str
::
length
(
trim
(
$value
));
return
(
array_key_exists
(
$attribute
,
Input
::
file
()))
?
$value
[
'size'
]
/
1024
:
Str
::
length
(
trim
(
$value
));
}
/**
...
...
@@ -478,7 +477,7 @@ class Validator {
// the default error message for the appropriate units.
if
(
in_array
(
$rule
,
$this
->
size_rules
)
and
!
$this
->
has_rule
(
$attribute
,
$this
->
numeric_rules
))
{
return
(
array_key_exists
(
$attribute
,
I
oC
::
container
()
->
resolve
(
'laravel.input'
)
->
file
()))
return
(
array_key_exists
(
$attribute
,
I
nput
::
file
()))
?
rtrim
(
$message
,
'.'
)
.
' '
.
Lang
::
line
(
'validation.kilobytes'
)
->
get
(
$this
->
language
)
.
'.'
:
rtrim
(
$message
,
'.'
)
.
' '
.
Lang
::
line
(
'validation.characters'
)
->
get
(
$this
->
language
)
.
'.'
;
}
...
...
laravel/view.php
View file @
71b0ab8b
<?php
namespace
Laravel
;
use
Closure
;
class
View
_Factory
{
class
View
{
/**
* The
directory containing the views
.
* The
name of the view
.
*
* @var string
*/
public
$
path
;
public
$
view
;
/**
* The path to the directory containing compiled views.
* The view data.
*
* @var array
*/
public
$data
;
/**
* The path to the view on disk.
*
* @var string
*/
p
ublic
$compiled
;
p
rotected
$path
;
/**
*
The view composer instance
.
*
All of the view composers for the application
.
*
* @var
View_Composer
* @var
array
*/
protected
$composer
;
protected
static
$composers
;
/**
* Create a new view
factory
instance.
* Create a new view instance.
*
* @param View_Composer $composer
* @param string $path
* @param string $compiled
* @param string $view
* @param array $data
* @return void
*/
public
function
__construct
(
View_Composer
$composer
,
$path
,
$compiled
)
public
function
__construct
(
$view
,
$data
=
array
())
{
$this
->
view
=
$view
;
$this
->
data
=
$data
;
$this
->
path
=
$this
->
path
(
$view
);
}
/**
* Get the path to a given view on disk.
*
* The view may be either a "normal" view or a "Blade" view, so we will
* need to check the view directory for either extension.
*
* @param string $view
* @return string
*/
protected
function
path
(
$view
)
{
$this
->
path
=
$path
;
$this
->
composer
=
$composer
;
$this
->
compiled
=
$compiled
;
$view
=
str_replace
(
'.'
,
'/'
,
$view
);
foreach
(
array
(
EXT
,
BLADE_EXT
)
as
$extension
)
{
if
(
file_exists
(
$path
=
VIEW_PATH
.
$view
.
$extension
))
return
$path
;
}
throw
new
\Exception
(
"View [
$view
] does not exist."
);
}
/**
...
...
@@ -57,9 +84,9 @@ class View_Factory {
* @param array $data
* @return View
*/
public
function
make
(
$view
,
$data
=
array
())
public
static
function
make
(
$view
,
$data
=
array
())
{
return
new
View
(
$this
,
$this
->
composer
,
$view
,
$data
,
$this
->
path
(
$view
)
);
return
new
static
(
$view
,
$data
);
}
/**
...
...
@@ -79,73 +106,13 @@ class View_Factory {
* @param array $data
* @return View
*/
public
function
of
(
$name
,
$data
=
array
())
public
static
function
of
(
$name
,
$data
=
array
())
{
if
(
!
is_null
(
$view
=
$this
->
composer
->
name
(
$name
)))
return
$this
->
make
(
$view
,
$data
);
if
(
!
is_null
(
$view
=
static
::
name
(
$name
)))
return
static
::
make
(
$view
,
$data
);
throw
new
\Exception
(
"Named view [
$name
] is not defined."
);
}
/**
* Get the path to a given view on disk.
*
* @param string $view
* @return string
*/
protected
function
path
(
$view
)
{
$view
=
str_replace
(
'.'
,
'/'
,
$view
);
foreach
(
array
(
EXT
,
BLADE_EXT
)
as
$extension
)
{
if
(
file_exists
(
$path
=
$this
->
path
.
$view
.
$extension
))
return
$path
;
}
throw
new
\Exception
(
"View [
$view
] does not exist."
);
}
/**
* Magic Method for handling the dynamic creation of named views.
*
* <code>
* // Create an instance of the "layout" named view
* $view = View::of_layout();
*
* // Create an instance of a named view with data
* $view = View::of_layout(array('name' => 'Taylor'));
* </code>
*/
public
function
__call
(
$method
,
$parameters
)
{
if
(
strpos
(
$method
,
'of_'
)
===
0
)
{
return
$this
->
of
(
substr
(
$method
,
3
),
Arr
::
get
(
$parameters
,
0
,
array
()));
}
}
}
class
View_Composer
{
/**
* The view composers.
*
* @var array
*/
protected
$composers
;
/**
* Create a new view composer instance.
*
* @param array $composers
* @return void
*/
public
function
__construct
(
$composers
)
{
$this
->
composers
=
$composers
;
}
/**
* Find the key for a view by name.
*
...
...
@@ -155,12 +122,14 @@ class View_Composer {
* @param string $name
* @return string
*/
p
ubl
ic
function
name
(
$name
)
p
rotected
stat
ic
function
name
(
$name
)
{
if
(
is_null
(
static
::
$composers
))
static
::
$composers
=
require
APP_PATH
.
'composers'
.
EXT
;
// The view's name may specified in several different ways in the composers file.
// The composer may simple have a string value, which is the name. Or, the composer
// could have an array value in which a "name" key exists.
foreach
(
$this
->
composers
as
$key
=>
$value
)
foreach
(
static
::
$
composers
as
$key
=>
$value
)
{
if
(
$name
===
$value
or
(
isset
(
$value
[
'name'
])
and
$name
===
$value
[
'name'
]))
{
return
$key
;
}
}
...
...
@@ -172,80 +141,23 @@ class View_Composer {
* @param View $view
* @return void
*/
p
ubl
ic
function
compose
(
View
$view
)
p
rotected
stat
ic
function
compose
(
View
$view
)
{
if
(
is_null
(
static
::
$composers
))
static
::
$composers
=
require
APP_PATH
.
'composers'
.
EXT
;
// The shared composer is called for every view instance. This allows the
// convenient binding of global view data or partials within a single method.
if
(
isset
(
$this
->
composers
[
'shared'
]))
call_user_func
(
$this
->
composers
[
'shared'
],
$view
);
if
(
isset
(
static
::
$composers
[
'shared'
]))
call_user_func
(
static
::
$
composers
[
'shared'
],
$view
);
if
(
isset
(
$this
->
composers
[
$view
->
view
]))
if
(
isset
(
static
::
$
composers
[
$view
->
view
]))
{
foreach
((
array
)
$this
->
composers
[
$view
->
view
]
as
$key
=>
$value
)
foreach
((
array
)
static
::
$
composers
[
$view
->
view
]
as
$key
=>
$value
)
{
if
(
$value
instanceof
Closure
)
return
call_user_func
(
$value
,
$view
);
}
}
}
}
class
View
{
/**
* The name of the view.
*
* @var string
*/
public
$view
;
/**
* The view data.
*
* @var array
*/
public
$data
;
/**
* The path to the view on disk.
*
* @var string
*/
protected
$path
;
/**
* The view composer instance.
*
* @var View_Composer
*/
protected
$composer
;
/**
* The view factory instance, which is used to create sub-views.
*
* @var View_Factory
*/
protected
$factory
;
/**
* Create a new view instance.
*
* @param View_Factory $factory
* @param View_Composer $composer
* @param string $view
* @param array $data
* @param string $path
* @return void
*/
public
function
__construct
(
View_Factory
$factory
,
View_Composer
$composer
,
$view
,
$data
,
$path
)
{
$this
->
view
=
$view
;
$this
->
data
=
$data
;
$this
->
path
=
$path
;
$this
->
factory
=
$factory
;
$this
->
composer
=
$composer
;
}
/**
* Get the evaluated string content of the view.
*
...
...
@@ -253,7 +165,7 @@ class View {
*/
public
function
render
()
{
$this
->
composer
->
compose
(
$this
);
static
::
compose
(
$this
);
// All nested views and responses are evaluated before the main view. This allows
// the assets used by these views to be added to the asset container before the
...
...
@@ -288,7 +200,7 @@ class View {
// For simplicity, compiled views are stored in a single directory by the MD5 hash of
// their name. This allows us to avoid recreating the entire view directory structure
// within the compiled views directory.
$compiled
=
$this
->
factory
->
compiled
.
md5
(
$this
->
view
);
$compiled
=
STORAGE_PATH
.
'views/'
.
md5
(
$this
->
view
);
// The view will only be re-compiled if the view has been modified since the last compiled
// version of the view was created or no compiled view exists. Otherwise, the path will
...
...
@@ -322,7 +234,7 @@ class View {
*/
public
function
nest
(
$key
,
$view
,
$data
=
array
())
{
return
$this
->
with
(
$key
,
$this
->
factory
->
make
(
$view
,
$data
));
return
$this
->
with
(
$key
,
static
::
make
(
$view
,
$data
));
}
/**
...
...
@@ -373,4 +285,23 @@ class View {
unset
(
$this
->
data
[
$key
]);
}
/**
* Magic Method for handling the dynamic creation of named views.
*
* <code>
* // Create an instance of the "layout" named view
* $view = View::of_layout();
*
* // Create an instance of a named view with data
* $view = View::of_layout(array('name' => 'Taylor'));
* </code>
*/
public
static
function
__callStatic
(
$method
,
$parameters
)
{
if
(
strpos
(
$method
,
'of_'
)
===
0
)
{
return
static
::
of
(
substr
(
$method
,
3
),
Arr
::
get
(
$parameters
,
0
,
array
()));
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment