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
77dc8d20
Commit
77dc8d20
authored
Sep 17, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring various things.
parent
1b75302d
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
139 additions
and
120 deletions
+139
-120
arr.php
laravel/arr.php
+37
-10
asset.php
laravel/asset.php
+32
-10
bootstrap.php
laravel/bootstrap.php
+9
-2
config.php
laravel/config.php
+36
-82
container.php
laravel/config/container.php
+2
-0
manager.php
laravel/database/manager.php
+5
-4
form.php
laravel/form.php
+1
-1
request.php
laravel/request.php
+12
-9
response.php
laravel/response.php
+3
-2
index.php
public/index.php
+2
-0
No files found.
laravel/arr.php
View file @
77dc8d20
<?php
namespace
Laravel
;
use
Closure
;
class
Arr
{
/**
* Get an item from an array.
*
* If the specified key is null, the entire array will be returned. The array may
* also be accessed using JavaScript "dot" style notation. Retrieving items nested
* in multiple arrays is supported.
* This method supports accessing arrays through JavaScript "dot" style syntax
* for conveniently digging deep into nested arrays. Like most other Laravel
* "get" methods, a default value may be provided.
*
* <code>
* // Get the value of $array['user']['name']
* $value = Arr::get($array, 'user.name');
*
* // Get a value from the array, but return a default if it doesn't exist
* $value = Arr::get($array, 'user.name', 'Taylor');
* </code>
*
* @param array $array
* @param string $key
...
...
@@ -24,7 +30,7 @@ class Arr {
{
if
(
!
is_array
(
$array
)
or
!
array_key_exists
(
$segment
,
$array
))
{
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
return
(
$default
instanceof
\
Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
$array
=
$array
[
$segment
];
...
...
@@ -36,9 +42,16 @@ class Arr {
/**
* Set an array item to a given value.
*
* This method is primarly helpful for setting the value in an array with
* a variable depth, such as configuration arrays. Like the Arr::get
* method, JavaScript "dot" syntax is supported.
* This method supports accessing arrays through JavaScript "dot" style syntax
* for conveniently digging deep into nested arrays.
*
* <code>
* // Set the $array['user']['name'] value in the array
* Arr::set($array, 'user.name', 'Taylor');
*
* // Set the $array['db']['driver']['name'] value in the array
* Arr::set($array, 'db.driver.name', 'SQLite');
* </code>
*
* @param array $array
* @param string $key
...
...
@@ -69,6 +82,20 @@ class Arr {
/**
* Return the first element in an array which passes a given truth test.
*
* The truth test is passed as a closure, and simply returns true or false.
* The array key and value will be passed to the closure on each iteration.
*
* Like the "get" method, a default value may be specified, and will be
* returned if no matching array elements are found by the method.
*
* <code>
* // Get the first string from an array with a length of 3
* $value = Arr::first($array, function($k, $v) {return strlen($v) == 3;});
*
* // Return a default value if no matching array elements are found
* $value = Arr::first($array, function($k, $v) {return;}, 'Default');
* </code>
*
* @param array $array
* @param Closure $callback
* @return mixed
...
...
@@ -80,7 +107,7 @@ class Arr {
if
(
call_user_func
(
$callback
,
$key
,
$value
))
return
$value
;
}
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
return
(
$default
instanceof
\
Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
}
\ No newline at end of file
laravel/asset.php
View file @
77dc8d20
...
...
@@ -35,10 +35,10 @@ class Asset {
* expressive code and a clean API.
*
* <code>
* // Get the default asset container
* // Get
an instance of
the default asset container
* $container = Asset::container();
*
* // Get
the "footer" asset
container
* // Get
an instance of the "footer"
container
* $container = Asset::container('footer');
* </code>
*
...
...
@@ -58,12 +58,9 @@ class Asset {
/**
* Magic Method for calling methods on the default Asset container.
*
* This provides a convenient API, allowing the developer to skip the
* "container" method when using the default container.
*
* <code>
* //
Add a JavaScript file to the defaul
t container
* Asset::
script
('jquery', 'js/jquery.js');
* //
Call the "add" method on the default asse
t container
* Asset::
add
('jquery', 'js/jquery.js');
*
* // Get all of the styles from the default container
* echo Asset::styles();
...
...
@@ -125,10 +122,13 @@ class Asset_Container {
*
* <code>
* // Add an asset to the container
* Asset::add('jquery', 'js/jquery.js');
* Asset::container()->add('style', 'style.css');
*
* // Add an asset to the container with attributes
* Asset::container()->add('style', 'style.css', array(), array('media' => 'print'));
*
* // Add an asset t
hat has
dependencies
* Asset::
add('jquery', 'js/
jquery.js', array('jquery-ui'));
* // Add an asset t
o the container with
dependencies
* Asset::
container()->add('jquery', '
jquery.js', array('jquery-ui'));
* </code>
*
* @param string $name
...
...
@@ -147,6 +147,17 @@ class Asset_Container {
/**
* Add a CSS file to the registered assets.
*
* <code>
* // Add a CSS file to the registered assets
* Asset::container()->style('common', 'common.css');
*
* // Add a CSS file with dependencies to the registered assets
* Asset::container()->style('common', 'common.css', array('reset'));
*
* // Add a CSS file with attributes to the registered assets
* Asset::container()->style('common', 'common.css', array(), array('media' => 'print'));
* </code>
*
* @param string $name
* @param string $source
* @param array $dependencies
...
...
@@ -168,6 +179,17 @@ class Asset_Container {
/**
* Add a JavaScript file to the registered assets.
*
* <code>
* // Add a CSS file to the registered assets
* Asset::container()->script('jquery', 'jquery.js');
*
* // Add a CSS file with dependencies to the registered assets
* Asset::container()->script('jquery', 'jquery.js', array('jquery-ui'));
*
* // Add a CSS file with attributes to the registered assets
* Asset::container()->script('loader', 'loader.js', array(), array('defer'));
* </code>
*
* @param string $name
* @param string $source
* @param array $dependencies
...
...
laravel/bootstrap.php
View file @
77dc8d20
...
...
@@ -49,7 +49,9 @@ if (file_exists($path = CONFIG_PATH.'container'.EXT))
$dependencies
=
array_merge
(
$dependencies
,
require
$path
);
}
if
(
isset
(
$_SERVER
[
'LARAVEL_ENV'
])
and
file_exists
(
$path
=
CONFIG_PATH
.
$_SERVER
[
'LARAVEL_ENV'
]
.
'/container'
.
EXT
))
$env
=
(
isset
(
$_SERVER
[
'LARAVEL_ENV'
]))
?
$_SERVER
[
'LARAVEL_ENV'
]
:
null
;
if
(
!
is_null
(
$env
)
and
file_exists
(
$path
=
CONFIG_PATH
.
$env
.
'/container'
.
EXT
))
{
$dependencies
=
array_merge
(
$dependencies
,
require
$path
);
}
...
...
@@ -62,3 +64,8 @@ IoC::$container = $container;
// Register the auto-loader on the auto-loader stack.
// --------------------------------------------------------------
spl_autoload_register
(
array
(
$container
->
resolve
(
'laravel.loader'
),
'load'
));
// --------------------------------------------------------------
// Set the application environment configuration option.
// --------------------------------------------------------------
$container
->
resolve
(
'laravel.config'
)
->
set
(
'application.env'
,
$env
);
\ No newline at end of file
laravel/config.php
View file @
77dc8d20
...
...
@@ -5,33 +5,32 @@ class Config {
/**
* All of the loaded configuration items.
*
* The configuration arrays are keyed by their owning file name.
*
* @var array
*/
protected
$items
=
array
();
/**
* The paths to the configuration files.
*
* @var array
*/
protected
$
paths
=
array
();
protected
$
config
=
array
();
/**
* Create a new configuration manager instance.
*
* @param array $
paths
* @param array $
config
* @return void
*/
public
function
__construct
(
$
paths
)
public
function
__construct
(
$
config
)
{
$this
->
paths
=
$paths
;
$this
->
config
=
$config
;
}
/**
* Determine if a configuration item or file exists.
*
* <code>
* // Determine if the "options" configuration file exists
* $options = Config::has('options');
*
* // Determine if a specific configuration item exists
* $timezone = Config::has('application.timezone');
* </code>
*
* @param string $key
* @return bool
*/
...
...
@@ -43,18 +42,23 @@ class Config {
/**
* Get a configuration item.
*
* If the name of a configuration file is passed without specifying an item, the
* entire configuration array will be returned.
* Configuration items are stored in the application/config directory, and provide
* general configuration options for a wide range of Laravel facilities.
*
* The arrays may be accessed using JavaScript style "dot" notation to drill deep
* intot he configuration files. For example, asking for "database.connectors.sqlite"
* would return the connector closure for SQLite stored in the database configuration
* file. If no specific item is specfied, the entire configuration array is returned.
*
* Like most Laravel "get" functions, a default value may be provided, and it will
* be returned if the requested file or item doesn't exist.
*
* <code>
* // Get the "timezone" option from the
"application"
file
* // Get the "timezone" option from the
application config
file
* $timezone = Config::get('application.timezone');
*
* // Get the SQLite connection configuration from the "database" file
* $sqlite = Config::get('database.connections.sqlite');
*
* // Get a configuration option and return "Fred" if it doesn't exist
* $option = Config::get('config.option', 'Fred');
* // Get an option, but return a default value if it doesn't exist
* $value = Config::get('some.option', 'Default');
* </code>
*
* @param string $key
...
...
@@ -63,30 +67,25 @@ class Config {
*/
public
function
get
(
$key
,
$default
=
null
)
{
list
(
$file
,
$key
)
=
$this
->
parse
(
$key
);
if
(
!
$this
->
load
(
$file
))
{
return
(
$default
instanceof
\Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
if
(
is_null
(
$key
))
return
$this
->
items
[
$file
];
return
Arr
::
get
(
$this
->
items
[
$file
],
$key
,
$default
);
return
Arr
::
get
(
$this
->
items
,
$key
,
$default
);
}
/**
* Set a configuration item.
*
* If a specific configuration item is not specified, the entire configuration
* array will be replaced with the given value.
* Configuration items are stored in the application/config directory, and provide
* general configuration options for a wide range of Laravel facilities.
*
* Like the "get" method, this method uses JavaScript style "dot" notation to access
* and manipulate the arrays in the configuration files. Also, like the "get" method,
* if no specific item is specified, the entire configuration array will be set.
*
* <code>
* // Set the "timezone" option in the "application"
file
* // Set the "timezone" option in the "application"
array
* Config::set('application.timezone', 'America/Chicago');
*
* // Set the entire "session"
array to an empty
array
* Config::set('session',
array()
);
* // Set the entire "session"
configuration
array
* Config::set('session',
$array
);
* </code>
*
* @param string $key
...
...
@@ -95,52 +94,7 @@ class Config {
*/
public
function
set
(
$key
,
$value
)
{
list
(
$file
,
$key
)
=
$this
->
parse
(
$key
);
$this
->
load
(
$file
);
(
is_null
(
$key
))
?
Arr
::
set
(
$this
->
items
,
$file
,
$value
)
:
Arr
::
set
(
$this
->
items
[
$file
],
$key
,
$value
);
}
/**
* Parse a configuration key and return its file and key segments.
*
* Configuration keys follow a {file}.{key} convention.
*
* @param string $key
* @return array
*/
protected
function
parse
(
$key
)
{
$segments
=
explode
(
'.'
,
$key
);
$key
=
(
count
(
$segments
)
>
1
)
?
implode
(
'.'
,
array_slice
(
$segments
,
1
))
:
null
;
return
array
(
$segments
[
0
],
$key
);
}
/**
* Load all of the configuration items from a module configuration file.
*
* If the configuration file has already been loaded, it will not be loaded again.
*
* @param string $file
* @return bool
*/
protected
function
load
(
$file
)
{
if
(
isset
(
$this
->
items
[
$file
]))
return
true
;
$config
=
array
();
foreach
(
$this
->
paths
as
$directory
)
{
$config
=
(
file_exists
(
$path
=
$directory
.
$file
.
EXT
))
?
array_merge
(
$config
,
require
$path
)
:
$config
;
}
if
(
count
(
$config
)
>
0
)
$this
->
items
[
$file
]
=
$config
;
return
isset
(
$this
->
items
[
$file
]);
Arr
::
set
(
$this
->
items
,
$key
,
$value
);
}
}
\ No newline at end of file
laravel/config/container.php
View file @
77dc8d20
...
...
@@ -108,6 +108,8 @@ return array(
(
$request
->
spoofed
())
?
$input
=
$_POST
:
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
}
unset
(
$input
[
'_REQUEST_METHOD_'
]);
return
new
Input
(
$container
->
resolve
(
'laravel.file'
),
$container
->
resolve
(
'laravel.cookie'
),
$input
,
$_FILES
);
}),
...
...
laravel/database/manager.php
View file @
77dc8d20
...
...
@@ -23,8 +23,7 @@ class Manager {
/**
* Get a database connection.
*
* If no database name is specified, the default connection will be returned as
* defined in the database configuration file.
* If no database name is specified, the default connection will be returned.
*
* Note: Database connections are managed as singletons.
*
...
...
@@ -46,7 +45,9 @@ class Manager {
// This provides the developer the maximum amount of freedom in establishing their
// database connections, and allows the framework to remain agonstic to ugly database
// specific PDO connection details. Less code. Less bugs.
$this
->
connections
[
$connection
]
=
new
Connection
(
call_user_func
(
$this
->
config
[
'connectors'
][
$connection
],
$this
->
config
));
$pdo
=
call_user_func
(
$this
->
config
[
'connectors'
][
$connection
]);
$this
->
connections
[
$connection
]
=
new
Connection
(
$pdo
,
$this
->
config
));
}
return
$this
->
connections
[
$connection
];
...
...
laravel/form.php
View file @
77dc8d20
...
...
@@ -81,7 +81,7 @@ class Form {
$attributes
[
'accept-charset'
]
=
$this
->
html
->
encoding
;
}
$append
=
(
$method
==
'PUT'
or
$method
==
'DELETE'
)
?
$this
->
hidden
(
'REQUEST_METHOD'
,
$method
)
:
''
;
$append
=
(
$method
==
'PUT'
or
$method
==
'DELETE'
)
?
$this
->
hidden
(
'
_
REQUEST_METHOD'
,
$method
)
:
''
;
return
'<form'
.
$this
->
html
->
attributes
(
$attributes
)
.
'>'
.
$append
.
PHP_EOL
;
}
...
...
laravel/request.php
View file @
77dc8d20
...
...
@@ -9,13 +9,6 @@ class Request {
*/
public
$server
;
/**
* The route handling the current request.
*
* @var Routing\Route
*/
public
$route
;
/**
* The $_POST array for the request.
*
...
...
@@ -40,6 +33,13 @@ class Request {
*/
protected
$uri
;
/**
* The route handling the current request.
*
* @var Routing\Route
*/
public
$route
;
/**
* Create a new request instance.
*
...
...
@@ -84,7 +84,10 @@ class Request {
throw
new
\Exception
(
'Unable to determine the request URI.'
);
}
if
(
$uri
===
false
)
throw
new
\Exception
(
'Malformed request URI. Request terminated.'
);
if
(
$uri
===
false
)
{
throw
new
\Exception
(
'Malformed request URI. Request terminated.'
);
}
foreach
(
array
(
parse_url
(
$this
->
url
,
PHP_URL_PATH
),
'/index.php'
)
as
$value
)
{
...
...
@@ -117,7 +120,7 @@ class Request {
*/
public
function
method
()
{
return
(
$this
->
spoofed
())
?
$this
->
post
[
'REQUEST_METHOD'
]
:
$this
->
server
[
'REQUEST_METHOD'
];
return
(
$this
->
spoofed
())
?
$this
->
post
[
'
_
REQUEST_METHOD'
]
:
$this
->
server
[
'REQUEST_METHOD'
];
}
/**
...
...
laravel/response.php
View file @
77dc8d20
...
...
@@ -263,8 +263,9 @@ class Response {
/**
* Send the response to the browser.
*
* All of the response header will be sent to the browser first, followed by the content
* of the response instance, which will be evaluated and rendered by the render method.
* All of the response header will be sent to the browser first, followed by
* the content of the response instance, which will be evaluated and rendered
* by the render method.
*
* @return void
*/
...
...
public/index.php
View file @
77dc8d20
...
...
@@ -49,3 +49,5 @@ $public = __DIR__;
|--------------------------------------------------------------------------
*/
require
$laravel
.
'/laravel.php'
;
echo
elapsed
();
\ 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