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
c7ddbbb0
Commit
c7ddbbb0
authored
Aug 31, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more dependency injection!
parent
c200f3eb
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
113 additions
and
218 deletions
+113
-218
application.php
laravel/application.php
+21
-13
bootstrap.php
laravel/bootstrap.php
+3
-6
apc.php
laravel/cache/apc.php
+0
-10
driver.php
laravel/cache/driver.php
+0
-23
manager.php
laravel/cache/manager.php
+0
-13
memcached.php
laravel/cache/memcached.php
+0
-10
container.php
laravel/config/container.php
+26
-8
container.php
laravel/container.php
+3
-0
controller.php
laravel/controller.php
+3
-14
download.php
laravel/download.php
+14
-11
form.php
laravel/form.php
+14
-39
html.php
laravel/html.php
+0
-16
loader.php
laravel/loader.php
+2
-2
package.php
laravel/package.php
+1
-1
request.php
laravel/request.php
+12
-3
response.php
laravel/response.php
+6
-3
cookie.php
laravel/session/cookie.php
+2
-2
driver.php
laravel/session/driver.php
+4
-42
manager.php
laravel/session/manager.php
+1
-1
str.php
laravel/str.php
+1
-1
No files found.
laravel/application.php
View file @
c7ddbbb0
<?php
namespace
Laravel
;
<?php
namespace
Laravel
;
class
Application
{
abstract
class
Resolver
{
/**
/**
*
The application
IoC container.
*
Magic Method for resolving classes out of the
IoC container.
*
*
* @var Container
* This allows the derived class to provide access to all of the Laravel libraries
*/
* registered in the container. Currently, this class is derived by the Application
public
$container
;
* and Controller classes.
/**
* Magic Method for resolving core classes out of the IoC container.
*/
*/
public
function
__get
(
$key
)
public
function
__get
(
$key
)
{
{
if
(
$this
->
container
->
registered
(
'laravel.'
.
$key
))
if
(
IoC
::
container
()
->
registered
(
'laravel.'
.
$key
))
{
{
return
$this
->
container
->
resolve
(
'laravel.'
.
$key
);
return
IoC
::
container
()
->
resolve
(
'laravel.'
.
$key
);
}
}
elseif
(
$this
->
container
->
registered
(
$key
))
elseif
(
IoC
::
container
()
->
registered
(
$key
))
{
{
return
$this
->
container
->
resolve
(
$key
);
return
IoC
::
container
()
->
resolve
(
$key
);
}
}
throw
new
\Exception
(
"Attempting to access undefined property [
$key
]
on application instance
."
);
throw
new
\Exception
(
"Attempting to access undefined property [
$key
]."
);
}
}
}
}
class
Application
extends
Resolver
{
/**
* The IoC container instance for the application.
*
* @var Container
*/
public
$container
;
}
\ No newline at end of file
laravel/bootstrap.php
View file @
c7ddbbb0
...
@@ -65,6 +65,8 @@ if (isset($_SERVER['LARAVEL_ENV']) and file_exists($path = CONFIG_PATH.$_SERVER[
...
@@ -65,6 +65,8 @@ if (isset($_SERVER['LARAVEL_ENV']) and file_exists($path = CONFIG_PATH.$_SERVER[
$application
->
container
=
new
Container
(
$dependencies
);
$application
->
container
=
new
Container
(
$dependencies
);
IoC
::
$container
=
$application
->
container
;
// --------------------------------------------------------------
// --------------------------------------------------------------
// Load the auto-loader.
// Load the auto-loader.
// --------------------------------------------------------------
// --------------------------------------------------------------
...
@@ -73,9 +75,4 @@ spl_autoload_register(array($application->loader, 'load'));
...
@@ -73,9 +75,4 @@ spl_autoload_register(array($application->loader, 'load'));
// --------------------------------------------------------------
// --------------------------------------------------------------
// Register the application in the container.
// Register the application in the container.
// --------------------------------------------------------------
// --------------------------------------------------------------
$application
->
container
->
instance
(
'laravel.application'
,
$application
);
IoC
::
container
()
->
instance
(
'laravel.application'
,
$application
);
\ No newline at end of file
// --------------------------------------------------------------
// Set the IoC container instance for use as a service locator.
// --------------------------------------------------------------
IoC
::
$container
=
$application
->
container
;
\ No newline at end of file
laravel/cache/apc.php
View file @
c7ddbbb0
...
@@ -75,11 +75,6 @@ class APC extends Driver {
...
@@ -75,11 +75,6 @@ class APC extends Driver {
/**
/**
* Determine if an item exists in the cache.
* Determine if an item exists in the cache.
*
*
* <code>
* // Determine if the "name" item exists in the cache
* $exists = Cache::driver()->has('name');
* </code>
*
* @param string $key
* @param string $key
* @return bool
* @return bool
*/
*/
...
@@ -102,11 +97,6 @@ class APC extends Driver {
...
@@ -102,11 +97,6 @@ class APC extends Driver {
/**
/**
* Write an item to the cache for a given number of minutes.
* Write an item to the cache for a given number of minutes.
*
*
* <code>
* // Write the "name" item to the cache for 30 minutes
* Cache::driver()->put('name', 'Fred', 30);
* </code>
*
* @param string $key
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $minutes
* @param int $minutes
...
...
laravel/cache/driver.php
View file @
c7ddbbb0
...
@@ -5,11 +5,6 @@ abstract class Driver {
...
@@ -5,11 +5,6 @@ abstract class Driver {
/**
/**
* Determine if an item exists in the cache.
* Determine if an item exists in the cache.
*
*
* <code>
* // Determine if the "name" item exists in the cache
* $exists = Cache::driver()->has('name');
* </code>
*
* @param string $key
* @param string $key
* @return bool
* @return bool
*/
*/
...
@@ -21,14 +16,6 @@ abstract class Driver {
...
@@ -21,14 +16,6 @@ abstract class Driver {
* A default value may also be specified, and will be returned in the requested
* A default value may also be specified, and will be returned in the requested
* item does not exist in the cache.
* item does not exist in the cache.
*
*
* <code>
* // Get the "name" item from the cache
* $name = Cache::driver()->get('name');
*
* // Get the "name" item from the cache or return "Fred"
* $name = Cache::driver()->get('name', 'Fred');
* </code>
*
* @param string $key
* @param string $key
* @param mixed $default
* @param mixed $default
* @param string $driver
* @param string $driver
...
@@ -52,11 +39,6 @@ abstract class Driver {
...
@@ -52,11 +39,6 @@ abstract class Driver {
/**
/**
* Write an item to the cache for a given number of minutes.
* Write an item to the cache for a given number of minutes.
*
*
* <code>
* // Write the "name" item to the cache for 30 minutes
* Cache::driver()->put('name', 'Fred', 30);
* </code>
*
* @param string $key
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $minutes
* @param int $minutes
...
@@ -68,11 +50,6 @@ abstract class Driver {
...
@@ -68,11 +50,6 @@ abstract class Driver {
* Get an item from the cache. If the item doesn't exist in the cache, store
* Get an item from the cache. If the item doesn't exist in the cache, store
* the default value in the cache and return it.
* the default value in the cache and return it.
*
*
* <code>
* // Get the "name" item from the cache or store "Fred" for 30 minutes
* $name = Cache::driver()->remember('name', 'Fred', 30);
* </code>
*
* @param string $key
* @param string $key
* @param mixed $default
* @param mixed $default
* @param int $minutes
* @param int $minutes
...
...
laravel/cache/manager.php
View file @
c7ddbbb0
...
@@ -43,14 +43,6 @@ class Manager {
...
@@ -43,14 +43,6 @@ class Manager {
* If no driver name is specified, the default cache driver will be returned
* If no driver name is specified, the default cache driver will be returned
* as defined in the cache configuration file.
* as defined in the cache configuration file.
*
*
* <code>
* // Get the default cache driver
* $driver = $application->cache->driver();
*
* // Get the APC cache driver
* $apc = $application->cache->driver('apc');
* </code>
*
* @param string $driver
* @param string $driver
* @return Cache\Driver
* @return Cache\Driver
*/
*/
...
@@ -76,11 +68,6 @@ class Manager {
...
@@ -76,11 +68,6 @@ class Manager {
*
*
* Passing method calls to the driver instance provides a convenient API for the developer
* Passing method calls to the driver instance provides a convenient API for the developer
* when always using the default cache driver.
* when always using the default cache driver.
*
* <code>
* // Get an item from the default cache driver
* $name = $application->cache->get('name');
* </code>
*/
*/
public
function
__call
(
$method
,
$parameters
)
public
function
__call
(
$method
,
$parameters
)
{
{
...
...
laravel/cache/memcached.php
View file @
c7ddbbb0
...
@@ -34,11 +34,6 @@ class Memcached extends Driver {
...
@@ -34,11 +34,6 @@ class Memcached extends Driver {
/**
/**
* Determine if an item exists in the cache.
* Determine if an item exists in the cache.
*
*
* <code>
* // Determine if the "name" item exists in the cache
* $exists = Cache::driver()->has('name');
* </code>
*
* @param string $key
* @param string $key
* @return bool
* @return bool
*/
*/
...
@@ -61,11 +56,6 @@ class Memcached extends Driver {
...
@@ -61,11 +56,6 @@ class Memcached extends Driver {
/**
/**
* Write an item to the cache for a given number of minutes.
* Write an item to the cache for a given number of minutes.
*
*
* <code>
* // Write the "name" item to the cache for 30 minutes
* Cache::driver()->put('name', 'Fred', 30);
* </code>
*
* @param string $key
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $minutes
* @param int $minutes
...
...
laravel/config/container.php
View file @
c7ddbbb0
...
@@ -47,23 +47,41 @@ return array(
...
@@ -47,23 +47,41 @@ return array(
}),
}),
'laravel.form'
=>
array
(
'resolver'
=>
function
(
$container
)
{
list
(
$request
,
$html
,
$url
)
=
array
(
$container
->
resolve
(
'laravel.request'
),
$container
->
resolve
(
'laravel.html'
),
$container
->
resolve
(
'laravel.url'
),
);
return
new
Form
(
$request
,
$html
,
$url
);
}),
'laravel.html'
=>
array
(
'resolver'
=>
function
(
$container
)
{
return
new
HTML
(
$container
->
resolve
(
'laravel.url'
),
$container
->
resolve
(
'laravel.config'
)
->
get
(
'application.encoding'
));
}),
'laravel.input'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.input'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
{
{
$
application
=
$container
->
resolve
(
'laravel.application
'
);
$
request
=
$container
->
resolve
(
'laravel.request
'
);
$input
=
array
();
$input
=
array
();
if
(
$
application
->
request
->
method
()
==
'GET'
)
if
(
$request
->
method
()
==
'GET'
)
{
{
$input
=
$_GET
;
$input
=
$_GET
;
}
}
elseif
(
$
application
->
request
->
method
()
==
'POST'
)
elseif
(
$request
->
method
()
==
'POST'
)
{
{
$input
=
$_POST
;
$input
=
$_POST
;
}
}
elseif
(
$
application
->
request
->
method
()
==
'PUT'
or
$application
->
request
->
method
==
'DELETE'
)
elseif
(
$
request
->
method
()
==
'PUT'
or
$
request
->
method
==
'DELETE'
)
{
{
(
$
application
->
request
->
spoofed
())
?
$input
=
$_POST
:
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
(
$request
->
spoofed
())
?
$input
=
$_POST
:
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
}
}
return
new
Input
(
$input
,
$_FILES
,
$container
->
resolve
(
'laravel.cookie'
));
return
new
Input
(
$input
,
$_FILES
,
$container
->
resolve
(
'laravel.cookie'
));
...
@@ -98,7 +116,7 @@ return array(
...
@@ -98,7 +116,7 @@ return array(
'laravel.request'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.request'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
{
{
return
new
Request
(
$_SERVER
,
$container
->
resolve
(
'laravel.config'
)
->
get
(
'application.url'
));
return
new
Request
(
$_SERVER
,
$
_POST
,
$
container
->
resolve
(
'laravel.config'
)
->
get
(
'application.url'
));
}),
}),
...
@@ -265,7 +283,7 @@ return array(
...
@@ -265,7 +283,7 @@ return array(
}),
}),
'laravel.cache.memcache.connection'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
()
'laravel.cache.memcache.connection'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
{
{
if
(
!
class_exists
(
'Memcache'
))
if
(
!
class_exists
(
'Memcache'
))
{
{
...
@@ -274,7 +292,7 @@ return array(
...
@@ -274,7 +292,7 @@ return array(
$memcache
=
new
\Memcache
;
$memcache
=
new
\Memcache
;
foreach
(
Config
::
get
(
'cache.servers'
)
as
$server
)
foreach
(
$container
->
resolve
(
'laravel.config'
)
->
get
(
'cache.servers'
)
as
$server
)
{
{
$memcache
->
addServer
(
$server
[
'host'
],
$server
[
'port'
],
true
,
$server
[
'weight'
]);
$memcache
->
addServer
(
$server
[
'host'
],
$server
[
'port'
],
true
,
$server
[
'weight'
]);
}
}
...
...
laravel/container.php
View file @
c7ddbbb0
...
@@ -12,6 +12,9 @@ class IoC {
...
@@ -12,6 +12,9 @@ class IoC {
/**
/**
* Get the active container instance.
* Get the active container instance.
*
*
* The container is set early in the request cycle and can be access here for
* use as a service locator if dependency injection is not practical.
*
* @return Container
* @return Container
*/
*/
public
static
function
container
()
public
static
function
container
()
...
...
laravel/controller.php
View file @
c7ddbbb0
<?php
namespace
Laravel
;
<?php
namespace
Laravel
;
abstract
class
Controller
{
abstract
class
Controller
extends
Resolver
{
/**
/**
* A stub method that will be called before every request to the controller.
* A stub method that will be called before every request to the controller.
*
*
* If a value is returned by the method, it will be halt the request
process
* If a value is returned by the method, it will be halt the request
cycle
* and will be considered the response to the request.
* and will be considered the response to the request.
*
*
* @return mixed
* @return mixed
*/
*/
public
function
before
()
{}
public
function
before
()
{}
/**
* Magic Method for getting items from the application instance.
*/
public
function
__get
(
$key
)
{
return
IoC
::
resolve
(
'laravel.application'
)
->
$key
;
}
/**
/**
* Magic Method to handle calls to undefined functions on the controller.
* Magic Method to handle calls to undefined functions on the controller.
*/
*/
public
function
__call
(
$method
,
$parameters
)
public
function
__call
(
$method
,
$parameters
)
{
return
$this
->
response
->
error
(
'404'
);
}
{
return
IoC
::
resolve
(
'laravel.application'
)
->
responder
->
error
(
'404'
);
}
}
}
\ No newline at end of file
laravel/download.php
View file @
c7ddbbb0
...
@@ -25,22 +25,25 @@ class Download extends Response {
...
@@ -25,22 +25,25 @@ class Download extends Response {
*
*
* @param string $path
* @param string $path
* @param string $name
* @param string $name
* @param array $headers
* @return Response
* @return Response
*/
*/
public
function
of
(
$path
,
$name
=
null
)
public
function
of
(
$path
,
$name
=
null
,
$headers
=
array
()
)
{
{
if
(
is_null
(
$name
))
$name
=
basename
(
$path
);
if
(
is_null
(
$name
))
$name
=
basename
(
$path
);
$response
=
parent
::
__construct
(
$this
->
file
->
get
(
$path
));
$headers
=
array_merge
(
array
(
'Content-Description'
=>
'File Transfer'
,
$response
->
header
(
'Content-Description'
,
'File Transfer'
);
'Content-Type'
=>
$this
->
mime
(
$this
->
file
->
extension
(
$path
)),
$response
->
header
(
'Content-Type'
,
$this
->
file
->
mime
(
$this
->
file
->
extension
(
$path
)));
'Content-Disposition'
=>
'attachment; filename="'
.
$name
.
'"'
,
$response
->
header
(
'Content-Disposition'
,
'attachment; filename="'
.
$name
.
'"'
);
'Content-Transfer-Encoding'
=>
'binary'
,
$response
->
header
(
'Content-Transfer-Encoding'
,
'binary'
);
'Expires'
=
=>
0
,
$response
->
header
(
'Expires'
,
0
);
'Cache-Control'
=>
'must-revalidate, post-check=0, pre-check=0'
,
$response
->
header
(
'Cache-Control'
,
'must-revalidate, post-check=0, pre-check=0'
);
'Pragma'
=>
'public'
,
$response
->
header
(
'Pragma'
,
'public'
);
'Content-Length'
=>
$this
->
file
-
size
(
$path
),
$response
->
header
(
'Content-Length'
,
$this
->
file
->
size
(
$path
));
),
$headers
);
$response
=
parent
::
__construct
(
$this
->
file
->
get
(
$path
),
200
,
$headers
);
return
$response
;
return
$response
;
}
}
...
...
laravel/form.php
View file @
c7ddbbb0
...
@@ -23,13 +23,6 @@ class Form {
...
@@ -23,13 +23,6 @@ class Form {
*/
*/
private
$url
;
private
$url
;
/**
* The CSRF token for the session.
*
* @var string
*/
public
$token
;
/**
/**
* All of the label names that have been created.
* All of the label names that have been created.
*
*
...
@@ -44,31 +37,20 @@ class Form {
...
@@ -44,31 +37,20 @@ class Form {
* Create a new form writer instance.
* Create a new form writer instance.
*
*
* @param Request $request
* @param Request $request
* @param string $token
* @param HTML $html
* @param URL $url
* @return void
* @return void
*/
*/
public
function
__construct
(
Request
$request
,
HTML
$html
,
URL
$url
,
$token
)
public
function
__construct
(
Request
$request
,
HTML
$html
,
URL
$url
)
{
{
$this
->
url
=
$url
;
$this
->
url
=
$url
;
$this
->
html
=
$html
;
$this
->
html
=
$html
;
$this
->
token
=
$token
;
$this
->
request
=
$request
;
$this
->
request
=
$request
;
}
}
/**
/**
* Open a HTML form.
* Open a HTML form.
*
*
* <code>
* // Open a POST form for the current URI
* echo Form::open();
*
* // Open a POST form to a specified URI
* echo Form::open('user/login');
*
* // Open a PUT form to a specified URI
* echo Form::open('user/profile', 'put');
* </code>
*
* Note: If PUT or DELETE is specified as the form method, a hidden input field will be generated
* Note: If PUT or DELETE is specified as the form method, a hidden input field will be generated
* containing the request method. PUT and DELETE are not supported by HTML forms, so the
* containing the request method. PUT and DELETE are not supported by HTML forms, so the
* hidden field will allow us to "spoof" PUT and DELETE requests.
* hidden field will allow us to "spoof" PUT and DELETE requests.
...
@@ -180,15 +162,21 @@ class Form {
...
@@ -180,15 +162,21 @@ class Form {
*/
*/
public
function
token
()
public
function
token
()
{
{
return
$this
->
input
(
'hidden'
,
'csrf_token'
,
$this
->
token
);
return
$this
->
input
(
'hidden'
,
'csrf_token'
,
$this
->
raw_token
()
);
}
}
/**
/**
*
Create a HTML label element
.
*
Get the CSRF token for the current session
.
*
*
* <code>
* @return string
* echo Form::label('email', 'E-Mail Address');
*/
* </code>
public
function
raw_token
()
{
return
IoC
::
container
()
->
resolve
(
'laravel.session'
)
->
get
(
'csrf_token'
);
}
/**
* Create a HTML label element.
*
*
* @param string $name
* @param string $name
* @param string $value
* @param string $value
...
@@ -208,14 +196,6 @@ class Form {
...
@@ -208,14 +196,6 @@ class Form {
* If an ID attribute is not specified and a label has been generated matching the input
* If an ID attribute is not specified and a label has been generated matching the input
* element name, the label name will be used as the element ID.
* element name, the label name will be used as the element ID.
*
*
* <code>
* // Generate a text type input element
* echo Form::input('text', 'email');
*
* // Generate a hidden type input element with a specified value
* echo Form::input('hidden', 'secret', 'This is a secret.');
* </code>
*
* @param string $name
* @param string $name
* @param mixed $value
* @param mixed $value
* @param array $attributes
* @param array $attributes
...
@@ -365,11 +345,6 @@ class Form {
...
@@ -365,11 +345,6 @@ class Form {
/**
/**
* Create a HTML select element.
* Create a HTML select element.
*
*
* <code>
* // Generate a drop-down with the "S" item selected
* echo Form::select('sizes', array('L' => 'Large', 'S' => 'Small'), 'S');
* </code>
*
* @param string $name
* @param string $name
* @param array $options
* @param array $options
* @param string $selected
* @param string $selected
...
...
laravel/html.php
View file @
c7ddbbb0
...
@@ -144,14 +144,6 @@ class HTML {
...
@@ -144,14 +144,6 @@ class HTML {
*
*
* An array of parameters may be specified to fill in URI segment wildcards.
* An array of parameters may be specified to fill in URI segment wildcards.
*
*
* <code>
* // Link to the "login" route
* echo HTML::link_to_route('login', 'Login');
*
* // Link to the "profile" route, which has a URI of "/profile/(:any)"
* echo HTML::link_to_route('profile', 'Profile', array('taylor'));
* </code>
*
* @param string $name
* @param string $name
* @param string $title
* @param string $title
* @param array $parameters
* @param array $parameters
...
@@ -330,14 +322,6 @@ class HTML {
...
@@ -330,14 +322,6 @@ class HTML {
* Magic Method for handling dynamic static methods.
* Magic Method for handling dynamic static methods.
*
*
* This method primarily handles dynamic calls to create links to named routes.
* This method primarily handles dynamic calls to create links to named routes.
*
* <code>
* // Link to the "login" route
* echo HTML::link_to_login('Login');
*
* // Link to the "profile" route, which has a URI of "/profile/(:any)"
* echo HTML::link_to_profile('Profile', array('taylor'));
* </code>
*/
*/
public
function
__call
(
$method
,
$parameters
)
public
function
__call
(
$method
,
$parameters
)
{
{
...
...
laravel/loader.php
View file @
c7ddbbb0
...
@@ -7,14 +7,14 @@ class Loader {
...
@@ -7,14 +7,14 @@ class Loader {
*
*
* @var array
* @var array
*/
*/
p
ublic
$paths
;
p
rivate
$paths
;
/**
/**
* All of the class aliases.
* All of the class aliases.
*
*
* @var array
* @var array
*/
*/
p
ublic
$aliases
;
p
rivate
$aliases
;
/**
/**
* Bootstrap the auto-loader.
* Bootstrap the auto-loader.
...
...
laravel/package.php
View file @
c7ddbbb0
...
@@ -7,7 +7,7 @@ class Package {
...
@@ -7,7 +7,7 @@ class Package {
*
*
* @var array
* @var array
*/
*/
p
ublic
$loaded
=
array
();
p
rivate
$loaded
=
array
();
/**
/**
* Load a package or set of packages.
* Load a package or set of packages.
...
...
laravel/request.php
View file @
c7ddbbb0
...
@@ -9,6 +9,13 @@ class Request {
...
@@ -9,6 +9,13 @@ class Request {
*/
*/
public
$server
;
public
$server
;
/**
* The $_POST array for the request.
*
* @var array
*/
private
$post
;
/**
/**
* The route handling the current request.
* The route handling the current request.
*
*
...
@@ -27,12 +34,14 @@ class Request {
...
@@ -27,12 +34,14 @@ class Request {
* Create a new request instance.
* Create a new request instance.
*
*
* @param array $server
* @param array $server
* @param array $post
* @param string $url
* @param string $url
* @return void
* @return void
*/
*/
public
function
__construct
(
$server
,
$url
)
public
function
__construct
(
$server
,
$
post
,
$
url
)
{
{
$this
->
url
=
$url
;
$this
->
url
=
$url
;
$this
->
post
=
$post
;
$this
->
server
=
$server
;
$this
->
server
=
$server
;
}
}
...
@@ -84,7 +93,7 @@ class Request {
...
@@ -84,7 +93,7 @@ class Request {
*/
*/
public
function
method
()
public
function
method
()
{
{
return
(
$this
->
spoofed
())
?
$
_POST
[
'REQUEST_METHOD'
]
:
$this
->
server
[
'REQUEST_METHOD'
];
return
(
$this
->
spoofed
())
?
$
this
->
post
[
'REQUEST_METHOD'
]
:
$this
->
server
[
'REQUEST_METHOD'
];
}
}
/**
/**
...
@@ -96,7 +105,7 @@ class Request {
...
@@ -96,7 +105,7 @@ class Request {
*/
*/
public
function
spoofed
()
public
function
spoofed
()
{
{
return
is_array
(
$
_POST
)
and
array_key_exists
(
'REQUEST_METHOD'
,
$_POST
);
return
is_array
(
$
this
->
post
)
and
array_key_exists
(
'REQUEST_METHOD'
,
$this
->
post
);
}
}
/**
/**
...
...
laravel/response.php
View file @
c7ddbbb0
...
@@ -25,11 +25,12 @@ class Response_Factory {
...
@@ -25,11 +25,12 @@ class Response_Factory {
*
*
* @param mixed $content
* @param mixed $content
* @param int $status
* @param int $status
* @param array $headers
* @return Response
* @return Response
*/
*/
public
function
make
(
$content
,
$status
=
200
)
public
function
make
(
$content
,
$status
=
200
,
$headers
=
array
()
)
{
{
return
new
Response
(
$content
,
$status
);
return
new
Response
(
$content
,
$status
,
$headers
);
}
}
/**
/**
...
@@ -144,11 +145,13 @@ class Response {
...
@@ -144,11 +145,13 @@ class Response {
*
*
* @param mixed $content
* @param mixed $content
* @param int $status
* @param int $status
* @param array $headers
* @return void
* @return void
*/
*/
public
function
__construct
(
$content
,
$status
=
200
)
public
function
__construct
(
$content
,
$status
=
200
,
$headers
=
array
()
)
{
{
$this
->
content
=
$content
;
$this
->
content
=
$content
;
$this
->
headers
=
$headers
;
$this
->
status
=
$status
;
$this
->
status
=
$status
;
}
}
...
...
laravel/session/cookie.php
View file @
c7ddbbb0
laravel/session/driver.php
View file @
c7ddbbb0
<?php
namespace
Laravel\Session
;
<?php
namespace
Laravel\Session
;
use
Laravel\Str
;
use
Laravel\Str
;
use
Laravel\Input
_Engine
;
use
Laravel\Input
;
use
Laravel\Cookie
;
use
Laravel\Cookie
;
abstract
class
Driver
{
abstract
class
Driver
{
...
@@ -67,11 +67,6 @@ abstract class Driver {
...
@@ -67,11 +67,6 @@ abstract class Driver {
/**
/**
* Determine if the session or flash data contains an item.
* Determine if the session or flash data contains an item.
*
*
* <code>
* // Determine if "name" item exists in the session
* $exists = Session::driver()->has('name');
* </code>
*
* @param string $key
* @param string $key
* @return bool
* @return bool
*/
*/
...
@@ -86,14 +81,6 @@ abstract class Driver {
...
@@ -86,14 +81,6 @@ abstract class Driver {
* A default value may also be specified, and will be returned in the requested
* A default value may also be specified, and will be returned in the requested
* item does not exist in the session.
* item does not exist in the session.
*
*
* <code>
* // Get the "name" item from the session
* $name = Session::driver()->get('name');
*
* // Get the "name" item from the session or return "Fred"
* $name = Session::driver()->get('name', 'Fred');
* </code>
*
* @param string $key
* @param string $key
* @param mixed $default
* @param mixed $default
* @return mixed
* @return mixed
...
@@ -111,11 +98,6 @@ abstract class Driver {
...
@@ -111,11 +98,6 @@ abstract class Driver {
/**
/**
* Write an item to the session.
* Write an item to the session.
*
*
* <code>
* // Write the "name" item to the session
* Session::driver()->put('name', 'Fred');
* </code>
*
* @param string $key
* @param string $key
* @param mixed $value
* @param mixed $value
* @return Driver
* @return Driver
...
@@ -133,11 +115,6 @@ abstract class Driver {
...
@@ -133,11 +115,6 @@ abstract class Driver {
* Flash data only exists for the next request. After that, it will be removed from
* Flash data only exists for the next request. After that, it will be removed from
* the session. Flash data is useful for temporary status or welcome messages.
* the session. Flash data is useful for temporary status or welcome messages.
*
*
* <code>
* // Write the "name" item to the session flash data
* Session::driver()->flash('name', 'Fred');
* </code>
*
* @param string $key
* @param string $key
* @param mixed $value
* @param mixed $value
* @return Driver
* @return Driver
...
@@ -152,11 +129,6 @@ abstract class Driver {
...
@@ -152,11 +129,6 @@ abstract class Driver {
/**
/**
* Remove an item from the session.
* Remove an item from the session.
*
*
* <code>
* // Remove the "name" item from the session
* Session::driver()->forget('name');
* </code>
*
* @param string $key
* @param string $key
* @return Driver
* @return Driver
*/
*/
...
@@ -196,11 +168,11 @@ abstract class Driver {
...
@@ -196,11 +168,11 @@ abstract class Driver {
* The input of the current request will also be flashed to the session so it is
* The input of the current request will also be flashed to the session so it is
* available for the next request via the "old" method on the input class.
* available for the next request via the "old" method on the input class.
*
*
* @param Laravel\Input
_Engine
$input
* @param Laravel\Input $input
* @param array $config
* @param array $config
* @return void
* @return void
*/
*/
public
function
close
(
Input
_Engine
$input
,
$config
)
public
function
close
(
Input
$input
,
$config
)
{
{
$this
->
flash
(
'laravel_old_input'
,
$input
->
get
())
->
age
();
$this
->
flash
(
'laravel_old_input'
,
$input
->
get
())
->
age
();
...
@@ -259,11 +231,6 @@ abstract class Driver {
...
@@ -259,11 +231,6 @@ abstract class Driver {
/**
/**
* Magic Method for retrieving items from the session.
* Magic Method for retrieving items from the session.
*
* <code>
* // Get the "name" item from the session
* $name = $application->session->name;
* </code>
*/
*/
public
function
__get
(
$key
)
public
function
__get
(
$key
)
{
{
...
@@ -272,11 +239,6 @@ abstract class Driver {
...
@@ -272,11 +239,6 @@ abstract class Driver {
/**
/**
* Magic Method for writings items to the session.
* Magic Method for writings items to the session.
*
* <code>
* // Write "Fred" to the session "name" item
* $application->session->name = 'Fred';
* </code>
*/
*/
public
function
__set
(
$key
,
$value
)
public
function
__set
(
$key
,
$value
)
{
{
...
...
laravel/session/manager.php
View file @
c7ddbbb0
...
@@ -32,7 +32,7 @@ class Manager {
...
@@ -32,7 +32,7 @@ class Manager {
* @param string $driver
* @param string $driver
* @return Session\Driver
* @return Session\Driver
*/
*/
public
static
function
driver
(
$driver
)
public
function
driver
(
$driver
)
{
{
if
(
in_array
(
$driver
,
array
(
'cookie'
,
'file'
,
'database'
,
'apc'
,
'memcached'
)))
if
(
in_array
(
$driver
,
array
(
'cookie'
,
'file'
,
'database'
,
'apc'
,
'memcached'
)))
{
{
...
...
laravel/str.php
View file @
c7ddbbb0
...
@@ -107,7 +107,7 @@ class Str {
...
@@ -107,7 +107,7 @@ class Str {
*
*
* @return string
* @return string
*/
*/
p
rivate
static
function
encoding
()
p
ublic
static
function
encoding
()
{
{
return
IoC
::
container
()
->
resolve
(
'laravel.config'
)
->
get
(
'application.encoding'
);
return
IoC
::
container
()
->
resolve
(
'laravel.config'
)
->
get
(
'application.encoding'
);
}
}
...
...
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