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
600e411a
Commit
600e411a
authored
Sep 21, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more refactoring on DI and IoC.
parent
4525eae2
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
36 additions
and
144 deletions
+36
-144
aliases.php
application/config/aliases.php
+1
-1
manager.php
laravel/cache/manager.php
+11
-37
container.php
laravel/config/container.php
+1
-9
controller.php
laravel/controller.php
+2
-8
cookie.php
laravel/cookie.php
+3
-23
facades.php
laravel/facades.php
+0
-2
laravel.php
laravel/laravel.php
+0
-5
paginator.php
laravel/paginator.php
+3
-32
cookie.php
laravel/session/drivers/cookie.php
+9
-20
validator.php
laravel/validation/validator.php
+6
-7
No files found.
application/config/aliases.php
View file @
600e411a
...
...
@@ -22,7 +22,7 @@ return array(
'Asset'
=>
'Laravel\\Asset'
,
'Auth'
=>
'Laravel\\Facades\\Auth'
,
'Benchmark'
=>
'Laravel\\Benchmark'
,
'Cache'
=>
'Laravel\\
Facades\\
Cache'
,
'Cache'
=>
'Laravel\\Cache'
,
'Config'
=>
'Laravel\\Config'
,
'Controller'
=>
'Laravel\\Controller'
,
'Cookie'
=>
'Laravel\\Cookie'
,
...
...
laravel/cache/manager.php
View file @
600e411a
<?php
namespace
Laravel\Cache
;
use
Laravel\
Container
;
use
Laravel\
IoC
;
class
Manager
{
/**
* All of the active cache drivers.
*
* @var
Cache\Driver
* @var
array
*/
public
$drivers
=
array
();
/**
* The application IoC container.
*
* @var Container
*/
private
$container
;
/**
* The default cache driver.
*
* @var string
*/
private
$default
;
/**
* Create a new cache manager instance.
*
* @param Container $container
* @return void
*/
public
function
__construct
(
Container
$container
,
$default
)
{
$this
->
default
=
$default
;
$this
->
container
=
$container
;
}
protected
static
$drivers
=
array
();
/**
* Get a cache driver instance.
...
...
@@ -46,21 +20,21 @@ class Manager {
* @param string $driver
* @return Cache\Driver
*/
public
function
driver
(
$driver
=
null
)
public
static
function
driver
(
$driver
=
null
)
{
if
(
is_null
(
$driver
))
$driver
=
$this
->
default
;
if
(
is_null
(
$driver
))
$driver
=
Config
::
get
(
'cache.default'
)
;
if
(
!
array_key_exists
(
$driver
,
$this
->
drivers
))
if
(
!
array_key_exists
(
$driver
,
static
::
$
drivers
))
{
if
(
!
$this
->
container
->
registered
(
'laravel.cache.'
.
$driver
))
if
(
!
IoC
::
container
()
->
registered
(
'laravel.cache.'
.
$driver
))
{
throw
new
\Exception
(
"Cache driver [
$driver
] is not supported."
);
}
return
$this
->
drivers
[
$driver
]
=
$this
->
container
->
resolve
(
'laravel.cache.'
.
$driver
);
return
static
::
$drivers
[
$driver
]
=
IoC
::
container
()
->
resolve
(
'laravel.cache.'
.
$driver
);
}
return
$this
->
drivers
[
$driver
];
return
static
::
$
drivers
[
$driver
];
}
/**
...
...
@@ -69,9 +43,9 @@ class Manager {
* Passing method calls to the driver instance provides a convenient API for the developer
* when always using the default cache driver.
*/
public
function
__call
(
$method
,
$parameters
)
public
static
function
__callStatic
(
$method
,
$parameters
)
{
return
call_user_func_array
(
array
(
$this
->
driver
(),
$method
),
$parameters
);
return
call_user_func_array
(
array
(
static
::
driver
(),
$method
),
$parameters
);
}
}
\ No newline at end of file
laravel/config/container.php
View file @
600e411a
...
...
@@ -54,12 +54,6 @@ return array(
|--------------------------------------------------------------------------
*/
'laravel.cache'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Cache\Manager
(
$c
,
Config
::
get
(
'cache.driver'
));
}),
'laravel.cache.apc'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Cache\Drivers\APC
(
Config
::
get
(
'cache.key'
));
...
...
@@ -129,9 +123,7 @@ return array(
'laravel.session.cookie'
=>
array
(
'resolver'
=>
function
(
$c
)
{
$cookies
=
$c
->
resolve
(
'laravel.cookie'
);
return
new
Session\Drivers\Cookie
(
$c
->
resolve
(
'laravel.crypter'
),
$cookies
);
return
new
Session\Drivers\Cookie
(
$c
->
resolve
(
'laravel.crypter'
));
}),
...
...
laravel/controller.php
View file @
600e411a
...
...
@@ -42,15 +42,9 @@ abstract class Controller {
*/
public
function
__get
(
$key
)
{
$container
=
IoC
::
container
();
if
(
$container
->
registered
(
'laravel.'
.
$key
))
{
return
$container
->
resolve
(
'laravel.'
.
$key
);
}
elseif
(
$container
->
registered
(
$key
))
if
(
IoC
::
container
()
->
registered
(
$key
))
{
return
$container
->
resolve
(
$key
);
return
IoC
::
container
()
->
resolve
(
$key
);
}
throw
new
\Exception
(
"Attempting to access undefined property [
$key
] on controller."
);
...
...
laravel/cookie.php
View file @
600e411a
...
...
@@ -2,13 +2,6 @@
class
Cookie
{
/**
* The cookies that will be sent to the browser at the end of the request.
*
* @var array
*/
protected
static
$queue
=
array
();
/**
* Determine if a cookie exists.
*
...
...
@@ -84,26 +77,13 @@ class Cookie {
*/
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
(
$_COOKIE
[
$name
]);
$time
=
(
$minutes
!=
0
)
?
time
()
+
(
$minutes
*
60
)
:
0
;
static
::
$queue
[]
=
compact
(
'name'
,
'value'
,
'time'
,
'path'
,
'domain'
,
'secure'
,
'http_only'
);
}
/**
* Send all of the cookies in the queue to the browser.
*
* This method is called automatically at the end of every request.
*
* @return void
*/
public
static
function
send
()
{
foreach
(
static
::
$queue
as
$cookie
)
{
call_user_func_array
(
'setcookie'
,
$cookie
);
}
return
setcookie
(
$name
,
$value
,
$time
,
$path
,
$domain
,
$secure
,
$http_only
);
}
/**
...
...
laravel/facades.php
View file @
600e411a
...
...
@@ -33,8 +33,6 @@ abstract class Facade {
}
class
Auth
extends
Facade
{
public
static
$resolve
=
'laravel.auth'
;
}
class
Cache
extends
Facade
{
public
static
$resolve
=
'laravel.cache'
;
}
class
Crypter
extends
Facade
{
public
static
$resolve
=
'laravel.crypter'
;
}
class
Hasher
extends
Facade
{
public
static
$resolve
=
'laravel.hasher'
;
}
class
Package
extends
Facade
{
public
static
$resolve
=
'laravel.package'
;
}
class
Session
extends
Facade
{
public
static
$resolve
=
'laravel.session'
;
}
\ No newline at end of file
laravel/laravel.php
View file @
600e411a
...
...
@@ -79,11 +79,6 @@ if (isset($session))
$session
->
close
(
$container
->
resolve
(
'laravel.session'
),
Config
::
get
(
'session'
));
}
// --------------------------------------------------------------
// Send the queued cookies to the browser.
// --------------------------------------------------------------
Cookie
::
send
();
// --------------------------------------------------------------
// Send the response to the browser.
// --------------------------------------------------------------
...
...
laravel/paginator.php
View file @
600e411a
<?php
namespace
Laravel
;
class
Paginator_Factory
{
protected
$request
;
protected
$html
;
protected
$lang
;
public
function
__construct
(
Request
$request
,
HTML
$html
,
Lang_Factory
$lang
)
{
$this
->
html
=
$html
;
$this
->
lang
=
$lang
;
$this
->
request
=
$request
;
}
public
function
make
(
$results
,
$total
,
$per_page
)
{
$page
=
Paginator
::
page
(
$total
,
$per_page
);
$last_page
=
ceil
(
$total
/
$per_page
);
return
new
Paginator
(
$this
->
request
,
$this
->
html
,
$this
->
lang
,
$results
,
$page
,
$total
,
$per_page
,
$last_page
);
}
}
class
Paginator
{
/**
...
...
@@ -87,13 +61,10 @@ class Paginator {
* @param int $last_page
* @return void
*/
protected
function
__construct
(
Request
$request
,
HTML
$html
,
Lang_Factory
$lang
,
$results
,
$page
,
$total
,
$per_page
,
$last_page
)
protected
function
__construct
(
$results
,
$page
,
$total
,
$per_page
,
$last_page
)
{
$this
->
html
=
$html
;
$this
->
lang
=
$lang
;
$this
->
page
=
$page
;
$this
->
total
=
$total
;
$this
->
request
=
$request
;
$this
->
results
=
$results
;
$this
->
per_page
=
$per_page
;
$this
->
last_page
=
$last_page
;
...
...
@@ -125,7 +96,7 @@ class Paginator {
*/
public
static
function
page
(
$total
,
$per_page
)
{
$page
=
I
oC
::
container
()
->
resolve
(
'laravel.input'
)
->
get
(
'page'
,
1
);
$page
=
I
nput
::
get
(
'page'
,
1
);
if
(
is_numeric
(
$page
)
and
$page
>
$last_page
=
ceil
(
$total
/
$per_page
))
{
...
...
@@ -273,7 +244,7 @@ class Paginator {
$append
.=
'&'
.
$key
.
'='
.
$value
;
}
return
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
$page
.
$append
,
$text
,
compact
(
'class'
),
Request
::
is_
secure
());
return
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
$page
.
$append
,
$text
,
compact
(
'class'
),
Request
::
secure
());
}
/**
...
...
laravel/session/drivers/cookie.php
View file @
600e411a
<?php
namespace
Laravel\Session\Drivers
;
use
Laravel\Cookie
as
C
;
use
Laravel\Security\Crypter
;
class
Cookie
implements
Driver
{
/**
* The cookie manager instance.
*
* @var Cookie
*/
private
$cookie
;
/**
* The crypter instance.
*
...
...
@@ -26,12 +20,10 @@ class Cookie implements Driver {
* Create a new Cookie session driver instance.
*
* @param Crypter $crypter
* @param Laravel\Cookie $cookie
* @return void
*/
public
function
__construct
(
Crypter
$crypter
,
\Laravel\Cookie
$cookie
)
public
function
__construct
(
Crypter
$crypter
)
{
$this
->
cookie
=
$cookie
;
$this
->
crypter
=
$crypter
;
}
...
...
@@ -45,9 +37,9 @@ class Cookie implements Driver {
*/
public
function
load
(
$id
)
{
if
(
$this
->
cookie
->
has
(
'session_payload'
))
if
(
C
::
has
(
'session_payload'
))
{
return
unserialize
(
$this
->
crypter
->
decrypt
(
$this
->
cookie
->
get
(
'session_payload'
)));
return
unserialize
(
$this
->
crypter
->
decrypt
(
C
::
get
(
'session_payload'
)));
}
}
...
...
@@ -59,15 +51,12 @@ class Cookie implements Driver {
* @return void
*/
public
function
save
(
$session
,
$config
)
{
if
(
!
headers_sent
())
{
extract
(
$config
);
$payload
=
$this
->
crypter
->
encrypt
(
serialize
(
$session
));
$this
->
cookie
->
put
(
'session_payload'
,
$payload
,
$lifetime
,
$path
,
$domain
);
}
C
::
put
(
'session_payload'
,
$payload
,
$lifetime
,
$path
,
$domain
);
}
/**
...
...
@@ -78,7 +67,7 @@ class Cookie implements Driver {
*/
public
function
delete
(
$id
)
{
$this
->
cookie
->
forget
(
'session_payload'
);
C
::
forget
(
'session_payload'
);
}
}
\ No newline at end of file
laravel/validation/validator.php
View file @
600e411a
...
...
@@ -4,6 +4,7 @@ use Closure;
use
Laravel\IoC
;
use
Laravel\Str
;
use
Laravel\Lang
;
use
Laravel\Database\Manager
as
Database
;
class
Validator
{
...
...
@@ -45,7 +46,7 @@ class Validator {
/**
* The database connection that should be used by the validator.
*
* @var D
B
\Connection
* @var D
atabase
\Connection
*/
public
$connection
;
...
...
@@ -324,7 +325,7 @@ class Validator {
{
if
(
!
isset
(
$parameters
[
1
]))
$parameters
[
1
]
=
$attribute
;
if
(
is_null
(
$this
->
connection
))
$this
->
connection
=
IoC
::
resolve
(
'laravel.database'
)
->
connection
();
if
(
is_null
(
$this
->
connection
))
$this
->
connection
=
Database
::
connection
();
return
$this
->
connection
->
table
(
$parameters
[
0
])
->
where
(
$parameters
[
1
],
'='
,
$this
->
attributes
[
$attribute
])
->
count
()
==
0
;
}
...
...
@@ -417,11 +418,9 @@ class Validator {
*/
protected
function
validate_mimes
(
$attribute
,
$parameters
)
{
$file
=
IoC
::
container
()
->
resolve
(
'laravel.file'
);
foreach
(
$parameters
as
$extension
)
{
if
(
$file
->
is
(
$extension
,
$this
->
attributes
[
$attribute
][
'tmp_name'
]))
return
true
;
if
(
File
::
is
(
$extension
,
$this
->
attributes
[
$attribute
][
'tmp_name'
]))
return
true
;
}
return
false
;
...
...
@@ -458,7 +457,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'
)
->
files
()))
return
(
array_key_exists
(
$attribute
,
I
nput
::
files
()))
?
rtrim
(
$message
,
'.'
)
.
' '
.
Lang
::
line
(
'validation.kilobytes'
)
->
get
(
$this
->
language
)
.
'.'
:
rtrim
(
$message
,
'.'
)
.
' '
.
Lang
::
line
(
'validation.characters'
)
->
get
(
$this
->
language
)
.
'.'
;
}
...
...
@@ -546,7 +545,7 @@ class Validator {
* @param Database\Connection $connection
* @return Validator
*/
public
function
connection
(
Database\Connection
$connection
)
public
function
connection
(
\Laravel\
Database\Connection
$connection
)
{
$this
->
connection
=
$connection
;
return
$this
;
...
...
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