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
Expand all
Hide 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
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| Here, you can specify any class aliases that you would like registered
| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
|
| Aliases make it more convenient to use namespaced classes. Instead of
| referring to the class using its full namespace, you may simply use
| the alias defined here.
|
| We have already aliased common Laravel classes to make your life easier.
|
*/
'Arr'
=>
'Laravel\\Arr'
,
'Asset'
=>
'Laravel\\Asset'
,
'Auth'
=>
'Laravel\\
Facades\\Auth'
,
'Benchmark'
=>
'Laravel\\Benchmark'
,
'Cache'
=>
'Laravel\\Cache'
,
'Config'
=>
'Laravel\\Config'
,
'Controller'
=>
'Laravel\\Controller'
,
'Cookie'
=>
'Laravel\\
Facades\\Cookie'
,
'Crypter'
=>
'Laravel\\
Facades\\Crypter'
,
'DB'
=>
'Laravel\\Database\\Manager'
,
'Eloquent'
=>
'Laravel\\Database\\Eloquent\\Model'
,
'File'
=>
'Laravel\\File'
,
'Form'
=>
'Laravel\\Form'
,
'Hasher'
=>
'Laravel\\Facades\\Hasher'
,
'HTML'
=>
'Laravel\\HTML'
,
'Inflector'
=>
'Laravel\\Inflector'
,
'Input'
=>
'Laravel\\
Facades\\Input'
,
'IoC'
=>
'Laravel\\IoC'
,
'Lang'
=>
'Laravel\\Lang'
,
'Loader'
=>
'Laravel\\Loader'
,
'Messages'
=>
'Laravel\\Validation\\Messages'
,
'Package'
=>
'Laravel\\Facades\\Package'
,
'URI'
=>
'Laravel\\
Facades\\URI'
,
'URL'
=>
'Laravel\\URL'
,
'Redirect'
=>
'Laravel\\Redirect'
,
'Request'
=>
'Laravel\\
Facades\\Request'
,
'Response'
=>
'Laravel\\Response'
,
'Session'
=>
'Laravel\\Facades\\Session'
,
'Str'
=>
'Laravel\\Str'
,
'Validator'
=>
'Laravel\\Validation\\Validator'
,
'View'
=>
'Laravel\\
Facades\\View'
,
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| Here, you can specify any class aliases that you would like registered
| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
|
| Aliases make it more convenient to use namespaced classes. Instead of
| referring to the class using its full namespace, you may simply use
| the alias defined here.
|
| We have already aliased common Laravel classes to make your life easier.
|
*/
'Arr'
=>
'Laravel\\Arr'
,
'Asset'
=>
'Laravel\\Asset'
,
'Auth'
=>
'Laravel\\
Auth'
,
'Benchmark'
=>
'Laravel\\Benchmark'
,
'Cache'
=>
'Laravel\\Cache'
,
'Config'
=>
'Laravel\\Config'
,
'Controller'
=>
'Laravel\\Controller'
,
'Cookie'
=>
'Laravel\\
Cookie'
,
'Crypter'
=>
'Laravel\\
Crypter'
,
'DB'
=>
'Laravel\\Database\\Manager'
,
'Eloquent'
=>
'Laravel\\Database\\Eloquent\\Model'
,
'File'
=>
'Laravel\\File'
,
'Form'
=>
'Laravel\\Form'
,
'Hasher'
=>
'Laravel\\Facades\\Hasher'
,
'HTML'
=>
'Laravel\\HTML'
,
'Inflector'
=>
'Laravel\\Inflector'
,
'Input'
=>
'Laravel\\
Input'
,
'IoC'
=>
'Laravel\\IoC'
,
'Lang'
=>
'Laravel\\Lang'
,
'Loader'
=>
'Laravel\\Loader'
,
'Messages'
=>
'Laravel\\Validation\\Messages'
,
'Package'
=>
'Laravel\\Facades\\Package'
,
'URI'
=>
'Laravel\\
URI'
,
'URL'
=>
'Laravel\\URL'
,
'Redirect'
=>
'Laravel\\Redirect'
,
'Request'
=>
'Laravel\\
Request'
,
'Response'
=>
'Laravel\\Response'
,
'Session'
=>
'Laravel\\Facades\\Session'
,
'Str'
=>
'Laravel\\Str'
,
'Validator'
=>
'Laravel\\Validation\\Validator'
,
'View'
=>
'Laravel\\
View'
,
);
\ No newline at end of file
application/config/application.php
View file @
71b0ab8b
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| The URL used to access your application. No trailing slash.
|
*/
'url'
=>
'http://localhost'
,
/*
|--------------------------------------------------------------------------
| Application Index
|--------------------------------------------------------------------------
|
| If you are including the "index.php" in your URLs, you can ignore this.
|
| However, if you are using mod_rewrite or something similar to get
| cleaner URLs, set this option to an empty string.
|
*/
'index'
=>
'index.php'
,
/*
|--------------------------------------------------------------------------
| Application Language
|--------------------------------------------------------------------------
|
| The default language of your application. This language will be used by
| Lang library as the default language when doing string localization.
|
*/
'language'
=>
'en'
,
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| The default timezone of your application. This timezone will be used when
| Laravel needs a date, such as when writing to a log file.
|
*/
'timezone'
=>
'UTC'
,
/*
|--------------------------------------------------------------------------
| Application Character Encoding
|--------------------------------------------------------------------------
|
| The default character encoding used by your application. This is the
| character encoding that will be used by the Str, Text, and Form classes.
|
*/
'encoding'
=>
'UTF-8'
,
/*
|--------------------------------------------------------------------------
| A
pplication Key
|--------------------------------------------------------------------------
|
|
Your application key should be a 32 character string that is totally
| r
andom and secret. This key is used by the encryption class to generate
|
secure, encrypted strings.
|
*/
'key'
=>
''
,
/*
|
--------------------------------------------------------------------------
| SSL Link Generation
|--------------------------------------------------------------------------
|
| Many sites use SSL to protect their users data. However, you may not
| always be able to use SSL on your development machine, meaning all HTTPS
|
will be broken during development.
|
|
For this reason, you may wish to disable the generation of HTTPS links
|
throughout your application. This option does just that. All attempts to
|
generate HTTPS links will generate regular HTTP links instead.
|
*/
'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
(),
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| The URL used to access your application. No trailing slash.
|
*/
'url'
=>
'http://localhost'
,
/*
|--------------------------------------------------------------------------
| Application Index
|--------------------------------------------------------------------------
|
| If you are including the "index.php" in your URLs, you can ignore this.
|
| However, if you are using mod_rewrite or something similar to get
| cleaner URLs, set this option to an empty string.
|
*/
'index'
=>
'index.php'
,
/*
|--------------------------------------------------------------------------
| Application Language
|--------------------------------------------------------------------------
|
| The default language of your application. This language will be used by
| Lang library as the default language when doing string localization.
|
*/
'language'
=>
'en'
,
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| The default timezone of your application. This timezone will be used when
| Laravel needs a date, such as when writing to a log file.
|
*/
'timezone'
=>
'UTC'
,
/*
|--------------------------------------------------------------------------
| Application Character Encoding
|--------------------------------------------------------------------------
|
| The default character encoding used by your application. This is the
| character encoding that will be used by the Str, Text, and Form classes.
|
*/
'encoding'
=>
'UTF-8'
,
/*
|--------------------------------------------------------------------------
| A
uto-Loaded Packages
|--------------------------------------------------------------------------
|
|
The packages that should be auto-loaded each time Laravel handles a
| r
equest. 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
|
--------------------------------------------------------------------------
|
|
Your application key should be a 32 character string that is totally
|
random and secret. This key is used by the encryption class to generate
| secure, encrypted strings.
|
*/
'key'
=>
''
,
/*
|--------------------------------------------------------------------------
|
SSL Link Generation
|
--------------------------------------------------------------------------
|
|
Many sites use SSL to protect their users data. However, you may not
|
always be able to use SSL on your development machine, meaning all HTTPS
|
will be broken during development.
|
|
For this reason, you may wish to disable the generation of HTTPS links
|
throughout your application. This option does just that. All attempts to
|
generate HTTPS links will generate regular HTTP links instead.
|
*/
'
ssl'
=>
true
,
);
\ No newline at end of file
application/config/auth.php
View file @
71b0ab8b
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Retrieve The Current User
|--------------------------------------------------------------------------
|
| This closure is called by the Auth::user() method when attempting to
| retrieve a user by their ID stored in the session.
|
| Simply return an object representing the user with the given ID. Or, if
| no user with the given ID is registered to use your application, you do
| not need to return anything.
|
| Of course, a simple, elegant authentication solution is already provided
| for you using Eloquent and the default Laravel hashing engine.
|
*/
'user'
=>
function
(
$id
)
{
if
(
!
is_null
(
$id
))
return
User
::
find
(
$id
);
},
/*
|--------------------------------------------------------------------------
| Authenticate User Credentials
|--------------------------------------------------------------------------
|
| This closure is called by the Auth::attempt() method when attempting to
| authenticate a user that is logging into your application.
|
| If the provided credentials are correct, simply return an object that
| represents the user being authenticated. If the credentials are not
| valid, don't return anything.
|
| Note: If a user object is returned, it must have an "id" property.
|
*/
'attempt'
=>
function
(
$username
,
$password
)
{
if
(
!
is_null
(
$user
=
User
::
where
(
'email'
,
'='
,
$username
)
->
first
()))
{
if
(
Hasher
::
check
(
$password
,
$user
->
password
))
return
$user
;
}
},
/*
|--------------------------------------------------------------------------
| Logout
|--------------------------------------------------------------------------
|
| Here you may do anything that needs to be done when a user logs out of
| your application, such as call the logout method on a third-party API
| you are using for authentication, or anything else you desire.
|
*/
'logout'
=>
function
(
$user
)
{}
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Retrieve The Current User
|--------------------------------------------------------------------------
|
| This closure is called by the Auth::user() method when attempting to
| retrieve a user by their ID stored in the session.
|
| Simply return an object representing the user with the given ID. Or, if
| no user with the given ID is registered to use your application, you do
| not need to return anything.
|
| Of course, a simple, elegant authentication solution is already provided
| for you using Eloquent and the default Laravel hashing engine.
|
*/
'user'
=>
function
(
$id
)
{
if
(
!
is_null
(
$id
))
return
User
::
find
(
$id
);
},
/*
|--------------------------------------------------------------------------
| Authenticate User Credentials
|--------------------------------------------------------------------------
|
| This closure is called by the Auth::attempt() method when attempting to
| authenticate a user that is logging into your application.
|
| If the provided credentials are correct, simply return an object that
| represents the user being authenticated. If the credentials are not
| valid, don't return anything.
|
| Note: If a user object is returned, it must have an "id" property.
|
*/
'attempt'
=>
function
(
$username
,
$password
)
{
if
(
!
is_null
(
$user
=
User
::
where
(
'email'
,
'='
,
$username
)
->
first
()))
{
if
(
Hasher
::
check
(
$password
,
$user
->
password
))
return
$user
;
}
},
/*
|--------------------------------------------------------------------------
| Logout
|--------------------------------------------------------------------------
|
| Here you may do anything that needs to be done when a user logs out of
| your application, such as call the logout method on a third-party API
| you are using for authentication, or anything else you desire.
|
*/
'logout'
=>
function
(
$user
)
{}
);
\ No newline at end of file
application/config/cache.php
View file @
71b0ab8b
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Cache Driver
|--------------------------------------------------------------------------
|
| The name of the default cache driver for your application.
|
| Caching can be used to increase the performance of your application
| by storing commonly accessed data in memory or in a file.
|
| Supported Drivers: 'file', 'memcached', 'apc'.
|
*/
'driver'
=>
'file'
,
/*
|--------------------------------------------------------------------------
| Cache Key
|--------------------------------------------------------------------------
|
| This key will be prepended to item keys stored using Memcached and APC to
| prevent collisions with other applications on the server.
|
*/
'key'
=>
'laravel'
,
/*
|--------------------------------------------------------------------------
| Memcached Servers
|--------------------------------------------------------------------------
|
| The Memcached servers used by your application.
|
| Memcached is a free and open source, high-performance, distributed memory
| object caching system, generic in nature, but intended for use in speeding
| up dynamic web applications by alleviating database load.
|
| For more information about Memcached, check out: http://memcached.org
|
*/
'servers'
=>
array
(
array
(
'host'
=>
'127.0.0.1'
,
'port'
=>
11211
,
'weight'
=>
100
),
),
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Cache Driver
|--------------------------------------------------------------------------
|
| The name of the default cache driver for your application.
|
| Caching can be used to increase the performance of your application
| by storing commonly accessed data in memory or in a file.
|
| Supported Drivers: 'file', 'memcached', 'apc'.
|
*/
'driver'
=>
'file'
,
/*
|--------------------------------------------------------------------------
| Cache Key
|--------------------------------------------------------------------------
|
| This key will be prepended to item keys stored using Memcached and APC to
| prevent collisions with other applications on the server.
|
*/
'key'
=>
'laravel'
,
/*
|--------------------------------------------------------------------------
| Memcached Servers
|--------------------------------------------------------------------------
|
| The Memcached servers used by your application.
|
| Memcached is a free and open source, high-performance, distributed memory
| object caching system, generic in nature, but intended for use in speeding
| up dynamic web applications by alleviating database load.
|
| For more information about Memcached, check out: http://memcached.org
|
*/
'servers'
=>
array
(
array
(
'host'
=>
'127.0.0.1'
,
'port'
=>
11211
,
'weight'
=>
100
),
),
);
\ No newline at end of file
application/config/database.php
View file @
71b0ab8b
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Default Database Connection
|--------------------------------------------------------------------------
|
| The name of your default database connection.
|
| This connection will be the default for all database operations unless a
| different connection is specified when performing the operation.
|
*/
'default'
=>
'sqlite'
,
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| All of the database connections used by your application.
|
| Supported Drivers: 'mysql', 'pgsql', 'sqlite'.
|
| Note: When using the SQLite driver, the path and "sqlite" extention will
| be added automatically. You only need to specify the database name.
|
| Using a driver that isn't supported? You can still establish a PDO
| connection. Simply specify a driver and DSN option:
|
| 'odbc' => array(
| 'driver' => 'odbc',
| 'dsn' => 'your-dsn',
| 'username' => 'username',
| 'password' => 'password',
| )
|
| Note: When using an unsupported driver, Eloquent and the fluent query
| builder may not work as expected.
|
*/
'connections'
=>
array
(
'sqlite'
=>
array
(
'driver'
=>
'sqlite'
,
'database'
=>
'application'
,
),
'mysql'
=>
array
(
'driver'
=>
'mysql'
,
'host'
=>
'localhost'
,
'database'
=>
'database'
,
'username'
=>
'root'
,
'password'
=>
'password'
,
'charset'
=>
'utf8'
,
),
'pgsql'
=>
array
(
'driver'
=>
'pgsql'
,
'host'
=>
'localhost'
,
'database'
=>
'database'
,
'username'
=>
'root'
,
'password'
=>
'password'
,
'charset'
=>
'utf8'
,
),
),
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Default Database Connection
|--------------------------------------------------------------------------
|
| The name of your default database connection.
|
| This connection will be the default for all database operations unless a
| different connection is specified when performing the operation.
|
*/
'default'
=>
'sqlite'
,
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| All of the database connections used by your application.
|
| Supported Drivers: 'mysql', 'pgsql', 'sqlite'.
|
| Note: When using the SQLite driver, the path and "sqlite" extention will
| be added automatically. You only need to specify the database name.
|
| Using a driver that isn't supported? You can still establish a PDO
| connection. Simply specify a driver and DSN option:
|
| 'odbc' => array(
| 'driver' => 'odbc',
| 'dsn' => 'your-dsn',
| 'username' => 'username',
| 'password' => 'password',
| )
|
| Note: When using an unsupported driver, Eloquent and the fluent query
| builder may not work as expected.
|
*/
'connections'
=>
array
(
'sqlite'
=>
array
(
'driver'
=>
'sqlite'
,
'database'
=>
'application'
,
),
'mysql'
=>
array
(
'driver'
=>
'mysql'
,
'host'
=>
'localhost'
,
'database'
=>
'database'
,
'username'
=>
'root'
,
'password'
=>
'password'
,
'charset'
=>
'utf8'
,
),
'pgsql'
=>
array
(
'driver'
=>
'pgsql'
,
'host'
=>
'localhost'
,
'database'
=>
'database'
,
'username'
=>
'root'
,
'password'
=>
'password'
,
'charset'
=>
'utf8'
,
),
),
);
\ No newline at end of file
application/config/error.php
View file @
71b0ab8b
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Error Detail
|--------------------------------------------------------------------------
|
| Detailed error messages contain information about the file in which
| an error occurs, a stack trace, and a snapshot of the source code
| in which the error occured.
|
| If your application is in production, consider turning off error details
| for enhanced security and user experience.
|
*/
'detail'
=>
true
,
/*
|--------------------------------------------------------------------------
| Error Logging
|--------------------------------------------------------------------------
|
| Error Logging will use the "logger" function defined below to log error
| messages, which gives you complete freedom to determine how error
| messages are logged. Enjoy the flexibility.
|
*/
'log'
=>
false
,
/*
|--------------------------------------------------------------------------
| Error Handler
|--------------------------------------------------------------------------
|
| Because of the various ways of managing error logging, you get complete
| flexibility in Laravel to manage error logging as you see fit.
|
| This function will be called when an error occurs in your application.
| You are free to handle the exception any way your heart desires.
|
| The error "severity" passed to the method is a human-readable severity
| level such as "Parsing Error" or "Fatal Error".
|
*/
'handler'
=>
function
(
$exception
,
$severity
,
$message
,
$config
)
{
if
(
$config
[
'detail'
])
{
$data
=
compact
(
'exception'
,
'severity'
,
'message'
);
$response
=
Response
::
view
(
'error.exception'
,
$data
)
->
status
(
500
);
}
else
{
$response
=
Response
::
error
(
'500'
);
}
$response
->
send
();
},
/*
|--------------------------------------------------------------------------
| Error Logger
|--------------------------------------------------------------------------
|
| Because of the various ways of managing error logging, you get complete
| flexibility to manage error logging as you see fit.
|
| This function will be called when an error occurs in your application
| and error loggins is enabled. You can log the error however you like.
|
| A simple logging system has been setup for you. By default, all errors
| will be logged to the storage/log.txt file.
|
*/
'logger'
=>
function
(
$exception
,
$severity
,
$message
,
$config
)
{
File
::
append
(
STORAGE_PATH
.
'log.txt'
,
date
(
'Y-m-d H:i:s'
)
.
' '
.
$severity
.
' - '
.
$message
.
PHP_EOL
);
}
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Error Detail
|--------------------------------------------------------------------------
|
| Detailed error messages contain information about the file in which
| an error occurs, a stack trace, and a snapshot of the source code
| in which the error occured.
|
| If your application is in production, consider turning off error details
| for enhanced security and user experience.
|
*/
'detail'
=>
true
,
/*
|--------------------------------------------------------------------------
| Error Logging
|--------------------------------------------------------------------------
|
| Error Logging will use the "logger" function defined below to log error
| messages, which gives you complete freedom to determine how error
| messages are logged. Enjoy the flexibility.
|
*/
'log'
=>
false
,
/*
|--------------------------------------------------------------------------
| Error Handler
|--------------------------------------------------------------------------
|
| Because of the various ways of managing error logging, you get complete
| flexibility in Laravel to manage error logging as you see fit.
|
| This function will be called when an error occurs in your application.
| You are free to handle the exception any way your heart desires.
|
| The error "severity" passed to the method is a human-readable severity
| level such as "Parsing Error" or "Fatal Error".
|
*/
'handler'
=>
function
(
$exception
,
$severity
,
$message
,
$config
)
{
if
(
$config
[
'detail'
])
{
$data
=
compact
(
'exception'
,
'severity'
,
'message'
);
$response
=
Response
::
view
(
'error.exception'
,
$data
)
->
status
(
500
);
}
else
{
$response
=
Response
::
error
(
'500'
);
}
$response
->
send
();
},
/*
|--------------------------------------------------------------------------
| Error Logger
|--------------------------------------------------------------------------
|
| Because of the various ways of managing error logging, you get complete
| flexibility to manage error logging as you see fit.
|
| This function will be called when an error occurs in your application
| and error loggins is enabled. You can log the error however you like.
|
| A simple logging system has been setup for you. By default, all errors
| will be logged to the storage/log.txt file.
|
*/
'logger'
=>
function
(
$exception
,
$severity
,
$message
,
$config
)
{
File
::
append
(
STORAGE_PATH
.
'log.txt'
,
date
(
'Y-m-d H:i:s'
)
.
' '
.
$severity
.
' - '
.
$message
.
PHP_EOL
);
}
);
\ No newline at end of file
application/config/session.php
View file @
71b0ab8b
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Session Driver
|--------------------------------------------------------------------------
|
| The name of the session driver for your application.
|
| Since HTTP is stateless, sessions are used to maintain "state" across
| multiple requests from the same user of your application.
|
| Supported Drivers: 'cookie', 'file', 'database', 'memcached', 'apc'.
|
*/
'driver'
=>
''
,
/*
|--------------------------------------------------------------------------
| Session Database
|--------------------------------------------------------------------------
|
| The database table on which the session should be stored.
|
| This option is only relevant when using the "database" session driver.
|
*/
'table'
=>
'sessions'
,
/*
|--------------------------------------------------------------------------
| Session Garbage Collection Probability
|--------------------------------------------------------------------------
|
| Some session drivers require the manual clean-up of expired sessions.
| This option specifies the probability of session garbage collection
| occuring for any given request.
|
| For example, the default value states that garbage collection has about
| a 2% (2 / 100) chance of occuring for any given request.
|
*/
'sweepage'
=>
array
(
2
,
100
),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| The number of minutes a session can be idle before expiring.
|
*/
'lifetime'
=>
60
,
/*
|--------------------------------------------------------------------------
| Session Expiration On Close
|--------------------------------------------------------------------------
|
| Determines if the session should expire when the user's web browser closes.
|
*/
'expire_on_close'
=>
false
,
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The path for which the session cookie is available.
|
*/
'path'
=>
'/'
,
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| The domain for which the session cookie is available.
|
*/
'domain'
=>
null
,
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Session Driver
|--------------------------------------------------------------------------
|
| The name of the session driver for your application.
|
| Since HTTP is stateless, sessions are used to maintain "state" across
| multiple requests from the same user of your application.
|
| Supported Drivers: 'cookie', 'file', 'database', 'memcached', 'apc'.
|
*/
'driver'
=>
''
,
/*
|--------------------------------------------------------------------------
| Session Database
|--------------------------------------------------------------------------
|
| The database table on which the session should be stored.
|
| This option is only relevant when using the "database" session driver.
|
*/
'table'
=>
'sessions'
,
/*
|--------------------------------------------------------------------------
| Session Garbage Collection Probability
|--------------------------------------------------------------------------
|
| Some session drivers require the manual clean-up of expired sessions.
| This option specifies the probability of session garbage collection
| occuring for any given request.
|
| For example, the default value states that garbage collection has about
| a 2% (2 / 100) chance of occuring for any given request.
|
*/
'sweepage'
=>
array
(
2
,
100
),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| The number of minutes a session can be idle before expiring.
|
*/
'lifetime'
=>
60
,
/*
|--------------------------------------------------------------------------
| Session Expiration On Close
|--------------------------------------------------------------------------
|
| Determines if the session should expire when the user's web browser closes.
|
*/
'expire_on_close'
=>
false
,
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The path for which the session cookie is available.
|
*/
'path'
=>
'/'
,
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| The domain for which the session cookie is available.
|
*/
'domain'
=>
null
,
);
\ No newline at end of file
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
<?php
namespace
Laravel
;
use
Closure
;
class
Config
{
/**
* The paths to the configuration files.
*
* @var array
*/
public
static
$paths
=
array
(
SYS_CONFIG_PATH
,
CONFIG_PATH
);
/**
* All of the loaded configuration items.
*
* The configuration arrays are keyed by their owning file name.
*
* @var array
*/
protected
static
$items
=
array
();
/**
* Determine if a configuration item or file exists.
*
* <code>
* // Determine if the "session" configuration file exists
* $exists = Config::has('session');
*
* // Determine if the "timezone" option exists in the "application" configuration array
* $exists = Config::has('application.timezone');
* </code>
*
* @param string $key
* @return bool
*/
public
static
function
has
(
$key
)
{
return
!
is_null
(
static
::
get
(
$key
));
}
/**
* Get a configuration item.
*
* If no item is requested, the entire configuration array will be returned.
*
* <code>
* // Get the "session" configuration array
* $session = Config::get('session');
*
* // Get the "timezone" option from the "application" configuration file
* $timezone = Config::get('application.timezone');
* </code>
*
* @param string $key
* @param string $default
* @return array
*/
public
static
function
get
(
$key
,
$default
=
null
)
{
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
if
(
!
static
::
load
(
$file
))
{
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
if
(
is_null
(
$key
))
return
static
::
$items
[
$file
];
return
Arr
::
get
(
static
::
$items
[
$file
],
$key
,
$default
);
}
/**
* Set a configuration item's value.
*
* <code>
* // Set the "session" configuration array
* Config::set('session', $array);
*
* // Set the "timezone" option in the "application" configuration file
* Config::set('application.timezone', 'UTC');
* </code>
*
* @param string $key
* @param mixed $value
* @return void
*/
public
static
function
set
(
$key
,
$value
)
{
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
static
::
load
(
$file
);
(
is_null
(
$key
))
?
Arr
::
set
(
static
::
$items
,
$file
,
$value
)
:
Arr
::
set
(
static
::
$items
[
$file
],
$key
,
$value
);
}
/**
* Parse a configuration key and return its file and key segments.
*
* @param string $key
* @return array
*/
protected
static
function
parse
(
$key
)
{
$segments
=
explode
(
'.'
,
$key
);
// If there is only one segment after exploding on dots, we will return NULL
// as the key value, causing the entire configuration array to be returned.
$key
=
(
count
(
$segments
)
>
1
)
?
implode
(
'.'
,
array_slice
(
$segments
,
1
))
:
null
;
return
array
(
$segments
[
0
],
$key
);
}
/**
* Load all of the configuration items from a configuration file.
*
* @param string $file
* @return bool
*/
protected
static
function
load
(
$file
)
{
if
(
isset
(
static
::
$items
[
$file
]))
return
true
;
$config
=
array
();
// Configuration files cascade. Typically, the system configuration array is loaded
// first, followed by the application array, providing the convenient cascading
// of configuration options from system to application.
foreach
(
static
::
$paths
as
$directory
)
{
if
(
file_exists
(
$path
=
$directory
.
$file
.
EXT
))
{
$config
=
array_merge
(
$config
,
require
$path
);
}
}
// If configuration options were actually found, they will be loaded into the
// array containing all of the options for all files. The array is keyed by the
// configuration file name.
if
(
count
(
$config
)
>
0
)
static
::
$items
[
$file
]
=
$config
;
return
isset
(
static
::
$items
[
$file
]);
}
/**
* Add a directory to the configuration manager's search paths.
*
* @param string $path
* @return void
*/
public
static
function
glance
(
$path
)
{
static
::
$paths
[]
=
$path
;
}
<?php
namespace
Laravel
;
use
Closure
;
class
Config
{
/**
* The paths to the configuration files.
*
* @var array
*/
public
static
$paths
=
array
(
SYS_CONFIG_PATH
,
CONFIG_PATH
);
/**
* All of the loaded configuration items.
*
* The configuration arrays are keyed by their owning file name.
*
* @var array
*/
protected
static
$items
=
array
();
/**
* Determine if a configuration item or file exists.
*
* <code>
* // Determine if the "session" configuration file exists
* $exists = Config::has('session');
*
* // Determine if the "timezone" option exists in the "application" configuration array
* $exists = Config::has('application.timezone');
* </code>
*
* @param string $key
* @return bool
*/
public
static
function
has
(
$key
)
{
return
!
is_null
(
static
::
get
(
$key
));
}
/**
* Get a configuration item.
*
* If no item is requested, the entire configuration array will be returned.
*
* <code>
* // Get the "session" configuration array
* $session = Config::get('session');
*
* // Get the "timezone" option from the "application" configuration file
* $timezone = Config::get('application.timezone');
* </code>
*
* @param string $key
* @param string $default
* @return array
*/
public
static
function
get
(
$key
,
$default
=
null
)
{
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
if
(
!
static
::
load
(
$file
))
{
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
if
(
is_null
(
$key
))
return
static
::
$items
[
$file
];
return
Arr
::
get
(
static
::
$items
[
$file
],
$key
,
$default
);
}
/**
* Set a configuration item's value.
*
* <code>
* // Set the "session" configuration array
* Config::set('session', $array);
*
* // Set the "timezone" option in the "application" configuration file
* Config::set('application.timezone', 'UTC');
* </code>
*
* @param string $key
* @param mixed $value
* @return void
*/
public
static
function
set
(
$key
,
$value
)
{
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
static
::
load
(
$file
);
(
is_null
(
$key
))
?
Arr
::
set
(
static
::
$items
,
$file
,
$value
)
:
Arr
::
set
(
static
::
$items
[
$file
],
$key
,
$value
);
}
/**
* Parse a configuration key and return its file and key segments.
*
* @param string $key
* @return array
*/
protected
static
function
parse
(
$key
)
{
$segments
=
explode
(
'.'
,
$key
);
// If there is only one segment after exploding on dots, we will return NULL
// as the key value, causing the entire configuration array to be returned.
$key
=
(
count
(
$segments
)
>
1
)
?
implode
(
'.'
,
array_slice
(
$segments
,
1
))
:
null
;
return
array
(
$segments
[
0
],
$key
);
}
/**
* Load all of the configuration items from a configuration file.
*
* @param string $file
* @return bool
*/
protected
static
function
load
(
$file
)
{
if
(
isset
(
static
::
$items
[
$file
]))
return
true
;
$config
=
array
();
// Configuration files cascade. Typically, the system configuration array is loaded
// first, followed by the application array, providing the convenient cascading
// of configuration options from system to application.
foreach
(
static
::
$paths
as
$directory
)
{
if
(
file_exists
(
$path
=
$directory
.
$file
.
EXT
))
{
$config
=
array_merge
(
$config
,
require
$path
);
}
}
// If configuration options were actually found, they will be loaded into the
// array containing all of the options for all files. The array is keyed by the
// configuration file name.
if
(
count
(
$config
)
>
0
)
static
::
$items
[
$file
]
=
$config
;
return
isset
(
static
::
$items
[
$file
]);
}
/**
* Add a directory to the configuration manager's search paths.
*
* @param string $path
* @return void
*/
public
static
function
glance
(
$path
)
{
static
::
$paths
[]
=
$path
;
}
}
\ No newline at end of file
laravel/config/container.php
View file @
71b0ab8b
This diff is collapsed.
Click to expand it.
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'
;
}
class
URI
extends
Facade
{
public
static
$resolve
=
'laravel.uri'
;
}
class
View
extends
Facade
{
public
static
$resolve
=
'laravel.view'
;
}
\ No newline at end of file
class
Session
extends
Facade
{
public
static
$resolve
=
'laravel.session'
;
}
\ 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
->
path
=
$path
;
$this
->
composer
=
$composer
;
$this
->
compiled
=
$compiled
;
$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
)
{
$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