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
c11ee765
Commit
c11ee765
authored
Nov 11, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #151 from sparksp/develop/ioc-container
Got rid of all IoC::container() calls
parents
9dbe7a29
b4fe148d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
34 additions
and
34 deletions
+34
-34
manager.php
laravel/cache/manager.php
+3
-3
container.php
laravel/container.php
+8
-8
facades.php
laravel/facades.php
+2
-2
form.php
laravel/form.php
+2
-2
input.php
laravel/input.php
+3
-3
laravel.php
laravel/laravel.php
+2
-2
redirect.php
laravel/redirect.php
+2
-2
request.php
laravel/request.php
+2
-2
controller.php
laravel/routing/controller.php
+6
-6
auth.php
laravel/security/auth.php
+4
-4
No files found.
laravel/cache/manager.php
View file @
c11ee765
...
@@ -32,12 +32,12 @@ class Manager {
...
@@ -32,12 +32,12 @@ class Manager {
if
(
!
array_key_exists
(
$driver
,
static
::
$drivers
))
if
(
!
array_key_exists
(
$driver
,
static
::
$drivers
))
{
{
if
(
!
IoC
::
container
()
->
registered
(
"laravel.cache.
{
$driver
}
"
))
if
(
!
IoC
::
registered
(
"laravel.cache.
{
$driver
}
"
))
{
{
throw
new
\Exception
(
"Cache driver [
$driver
] is not supported."
);
throw
new
\Exception
(
"Cache driver [
$driver
] is not supported."
);
}
}
return
static
::
$drivers
[
$driver
]
=
IoC
::
co
ntainer
()
->
co
re
(
"cache.
{
$driver
}
"
);
return
static
::
$drivers
[
$driver
]
=
IoC
::
core
(
"cache.
{
$driver
}
"
);
}
}
return
static
::
$drivers
[
$driver
];
return
static
::
$drivers
[
$driver
];
...
@@ -62,4 +62,4 @@ class Manager {
...
@@ -62,4 +62,4 @@ class Manager {
return
call_user_func_array
(
array
(
static
::
driver
(),
$method
),
$parameters
);
return
call_user_func_array
(
array
(
static
::
driver
(),
$method
),
$parameters
);
}
}
}
}
\ No newline at end of file
laravel/container.php
View file @
c11ee765
...
@@ -107,7 +107,7 @@ class Container {
...
@@ -107,7 +107,7 @@ class Container {
*
*
* <code>
* <code>
* // Register an object and its resolver
* // Register an object and its resolver
* IoC::
container()->
register('mailer', function($c) {return new Mailer;});
* IoC::register('mailer', function($c) {return new Mailer;});
* </code>
* </code>
*
*
* @param string $name
* @param string $name
...
@@ -153,7 +153,7 @@ class Container {
...
@@ -153,7 +153,7 @@ class Container {
*
*
* <code>
* <code>
* // Register an instance as a singleton in the container
* // Register an instance as a singleton in the container
* IoC::
container()->
instance('mailer', new Mailer);
* IoC::instance('mailer', new Mailer);
* </code>
* </code>
*
*
* @param string $name
* @param string $name
...
@@ -170,13 +170,13 @@ class Container {
...
@@ -170,13 +170,13 @@ class Container {
*
*
* <code>
* <code>
* // Resolve the "laravel.router" class from the container
* // Resolve the "laravel.router" class from the container
* $input = IoC::co
ntainer()->co
re('router');
* $input = IoC::core('router');
*
*
* // Equivalent resolution using the "resolve" method
* // Equivalent resolution using the "resolve" method
* $input = IoC::
container()->
resolve('laravel.router');
* $input = IoC::resolve('laravel.router');
*
*
* // Pass an array of parameters to the resolver
* // Pass an array of parameters to the resolver
* $input = IoC::co
ntainer()->co
re('router', array('test'));
* $input = IoC::core('router', array('test'));
* </code>
* </code>
*
*
* @param string $name
* @param string $name
...
@@ -193,10 +193,10 @@ class Container {
...
@@ -193,10 +193,10 @@ class Container {
*
*
* <code>
* <code>
* // Get an instance of the "mailer" object registered in the container
* // Get an instance of the "mailer" object registered in the container
* $mailer = IoC::
container()->
resolve('mailer');
* $mailer = IoC::resolve('mailer');
*
*
* // Pass an array of parameters to the resolver
* // Pass an array of parameters to the resolver
* $mailer = IoC::
container()->
resolve('mailer', array('test'));
* $mailer = IoC::resolve('mailer', array('test'));
* </code>
* </code>
*
*
* @param string $name
* @param string $name
...
@@ -222,4 +222,4 @@ class Container {
...
@@ -222,4 +222,4 @@ class Container {
return
$object
;
return
$object
;
}
}
}
}
\ No newline at end of file
laravel/facades.php
View file @
c11ee765
...
@@ -27,7 +27,7 @@ abstract class Facade {
...
@@ -27,7 +27,7 @@ abstract class Facade {
*/
*/
public
static
function
__callStatic
(
$method
,
$parameters
)
public
static
function
__callStatic
(
$method
,
$parameters
)
{
{
$class
=
IoC
::
container
()
->
resolve
(
static
::
$resolve
);
$class
=
IoC
::
resolve
(
static
::
$resolve
);
$count
=
count
(
$parameters
);
$count
=
count
(
$parameters
);
...
@@ -59,4 +59,4 @@ abstract class Facade {
...
@@ -59,4 +59,4 @@ abstract class Facade {
}
}
class
Session
extends
Facade
{
public
static
$resolve
=
'laravel.session'
;
}
class
Session
extends
Facade
{
public
static
$resolve
=
'laravel.session'
;
}
\ No newline at end of file
laravel/form.php
View file @
c11ee765
...
@@ -149,7 +149,7 @@ class Form {
...
@@ -149,7 +149,7 @@ class Form {
*/
*/
public
static
function
token
()
public
static
function
token
()
{
{
$token
=
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
token
();
$token
=
IoC
::
core
(
'session'
)
->
token
();
return
static
::
input
(
'hidden'
,
'csrf_token'
,
$token
);
return
static
::
input
(
'hidden'
,
'csrf_token'
,
$token
);
}
}
...
@@ -540,4 +540,4 @@ class Form {
...
@@ -540,4 +540,4 @@ class Form {
}
}
}
}
}
}
\ No newline at end of file
laravel/input.php
View file @
c11ee765
...
@@ -72,7 +72,7 @@ class Input {
...
@@ -72,7 +72,7 @@ class Input {
{
{
if
(
Config
::
$items
[
'session'
][
'driver'
]
!==
''
)
if
(
Config
::
$items
[
'session'
][
'driver'
]
!==
''
)
{
{
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
flash
(
Input
::
old_input
,
static
::
get
());
IoC
::
core
(
'session'
)
->
flash
(
Input
::
old_input
,
static
::
get
());
}
}
}
}
...
@@ -109,7 +109,7 @@ class Input {
...
@@ -109,7 +109,7 @@ class Input {
throw
new
\Exception
(
'A session driver must be specified in order to access old input.'
);
throw
new
\Exception
(
'A session driver must be specified in order to access old input.'
);
}
}
$old
=
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
get
(
Input
::
old_input
,
array
());
$old
=
IoC
::
core
(
'session'
)
->
get
(
Input
::
old_input
,
array
());
return
Arr
::
get
(
$old
,
$key
,
$default
);
return
Arr
::
get
(
$old
,
$key
,
$default
);
}
}
...
@@ -153,4 +153,4 @@ class Input {
...
@@ -153,4 +153,4 @@ class Input {
return
array_key_exists
(
$key
,
$_FILES
)
?
File
::
upload
(
$key
,
$path
,
$_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 @
c11ee765
...
@@ -103,7 +103,7 @@ if (Config::$items['session']['driver'] !== '')
...
@@ -103,7 +103,7 @@ if (Config::$items['session']['driver'] !== '')
$id
=
Cookie
::
get
(
Config
::
$items
[
'session'
][
'cookie'
]);
$id
=
Cookie
::
get
(
Config
::
$items
[
'session'
][
'cookie'
]);
IoC
::
container
()
->
instance
(
'laravel.session'
,
new
Session\Manager
(
$driver
,
$id
));
IoC
::
instance
(
'laravel.session'
,
new
Session\Manager
(
$driver
,
$id
));
}
}
/**
/**
...
@@ -198,4 +198,4 @@ if (Config::$items['session']['driver'] !== '')
...
@@ -198,4 +198,4 @@ if (Config::$items['session']['driver'] !== '')
IoC
::
core
(
'session'
)
->
save
(
$driver
);
IoC
::
core
(
'session'
)
->
save
(
$driver
);
}
}
$response
->
send
();
$response
->
send
();
\ No newline at end of file
laravel/redirect.php
View file @
c11ee765
...
@@ -61,7 +61,7 @@ class Redirect extends Response {
...
@@ -61,7 +61,7 @@ class Redirect extends Response {
throw
new
\Exception
(
'A session driver must be set before setting flash data.'
);
throw
new
\Exception
(
'A session driver must be set before setting flash data.'
);
}
}
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
flash
(
$key
,
$value
);
IoC
::
core
(
'session'
)
->
flash
(
$key
,
$value
);
return
$this
;
return
$this
;
}
}
...
@@ -94,4 +94,4 @@ class Redirect extends Response {
...
@@ -94,4 +94,4 @@ class Redirect extends Response {
throw
new
\Exception
(
"Method [
$method
] is not defined on the Redirect class."
);
throw
new
\Exception
(
"Method [
$method
] is not defined on the Redirect class."
);
}
}
}
}
\ No newline at end of file
laravel/request.php
View file @
c11ee765
...
@@ -154,7 +154,7 @@ class Request {
...
@@ -154,7 +154,7 @@ class Request {
*/
*/
public
static
function
forged
()
public
static
function
forged
()
{
{
return
Input
::
get
(
'csrf_token'
)
!==
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
token
();
return
Input
::
get
(
'csrf_token'
)
!==
IoC
::
core
(
'session'
)
->
token
();
}
}
/**
/**
...
@@ -179,4 +179,4 @@ class Request {
...
@@ -179,4 +179,4 @@ class Request {
return
static
::
$route
;
return
static
::
$route
;
}
}
}
}
\ No newline at end of file
laravel/routing/controller.php
View file @
c11ee765
...
@@ -68,9 +68,9 @@ abstract class Controller {
...
@@ -68,9 +68,9 @@ abstract class Controller {
// If the controller is registered in the IoC container, we will resolve
// If the controller is registered in the IoC container, we will resolve
// it out of the container. Using constructor injection on controllers
// it out of the container. Using constructor injection on controllers
// via the container allows more flexible and testable applications.
// via the container allows more flexible and testable applications.
if
(
IoC
::
container
()
->
registered
(
'controllers.'
.
$controller
))
if
(
IoC
::
registered
(
'controllers.'
.
$controller
))
{
{
return
IoC
::
container
()
->
resolve
(
'controllers.'
.
$controller
);
return
IoC
::
resolve
(
'controllers.'
.
$controller
);
}
}
$controller
=
str_replace
(
' '
,
'_'
,
ucwords
(
str_replace
(
'.'
,
' '
,
$controller
)))
.
'_Controller'
;
$controller
=
str_replace
(
' '
,
'_'
,
ucwords
(
str_replace
(
'.'
,
' '
,
$controller
)))
.
'_Controller'
;
...
@@ -216,17 +216,17 @@ abstract class Controller {
...
@@ -216,17 +216,17 @@ abstract class Controller {
* $mailer = $this->mailer;
* $mailer = $this->mailer;
*
*
* // Equivalent call using the IoC container instance
* // Equivalent call using the IoC container instance
* $mailer = IoC::
container()->
resolve('mailer');
* $mailer = IoC::resolve('mailer');
* </code>
* </code>
*/
*/
public
function
__get
(
$key
)
public
function
__get
(
$key
)
{
{
if
(
IoC
::
container
()
->
registered
(
$key
))
if
(
IoC
::
registered
(
$key
))
{
{
return
IoC
::
container
()
->
resolve
(
$key
);
return
IoC
::
resolve
(
$key
);
}
}
throw
new
\Exception
(
"Attempting to access undefined property [
$key
] on controller."
);
throw
new
\Exception
(
"Attempting to access undefined property [
$key
] on controller."
);
}
}
}
}
\ No newline at end of file
laravel/security/auth.php
View file @
c11ee765
...
@@ -74,7 +74,7 @@ class Auth {
...
@@ -74,7 +74,7 @@ class Auth {
{
{
if
(
!
is_null
(
static
::
$user
))
return
static
::
$user
;
if
(
!
is_null
(
static
::
$user
))
return
static
::
$user
;
$id
=
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
get
(
Auth
::
user_key
);
$id
=
IoC
::
core
(
'session'
)
->
get
(
Auth
::
user_key
);
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
...
@@ -152,7 +152,7 @@ class Auth {
...
@@ -152,7 +152,7 @@ class Auth {
if
(
$remember
)
static
::
remember
(
$user
->
id
);
if
(
$remember
)
static
::
remember
(
$user
->
id
);
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
put
(
Auth
::
user_key
,
$user
->
id
);
IoC
::
core
(
'session'
)
->
put
(
Auth
::
user_key
,
$user
->
id
);
}
}
/**
/**
...
@@ -195,7 +195,7 @@ class Auth {
...
@@ -195,7 +195,7 @@ class Auth {
Cookie
::
forget
(
Auth
::
remember_key
);
Cookie
::
forget
(
Auth
::
remember_key
);
IoC
::
co
ntainer
()
->
co
re
(
'session'
)
->
forget
(
Auth
::
user_key
);
IoC
::
core
(
'session'
)
->
forget
(
Auth
::
user_key
);
}
}
}
}
\ 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