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
54c69d8c
Commit
54c69d8c
authored
Sep 27, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring.
parent
ed3e3e73
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
36 deletions
+89
-36
blade.php
laravel/blade.php
+4
-8
core.php
laravel/bootstrap/core.php
+3
-5
container.php
laravel/config/container.php
+6
-0
connection.php
laravel/database/connection.php
+26
-5
manager.php
laravel/database/manager.php
+8
-0
loader.php
laravel/loader.php
+39
-17
validator.php
laravel/validation/validator.php
+3
-1
No files found.
laravel/blade.php
View file @
54c69d8c
...
...
@@ -21,11 +21,7 @@ class Blade {
*/
public
static
function
parse_string
(
$value
)
{
$value
=
static
::
rewrite_echos
(
$value
);
$value
=
static
::
rewrite_openings
(
$value
);
$value
=
static
::
rewrite_closings
(
$value
);
return
$value
;
return
static
::
closings
(
static
::
openings
(
static
::
echos
(
$value
)));
}
/**
...
...
@@ -34,7 +30,7 @@ class Blade {
* @param string $value
* @return string
*/
protected
static
function
rewrite_
echos
(
$value
)
protected
static
function
echos
(
$value
)
{
return
preg_replace
(
'/\{\{(.+)\}\}/'
,
'<?php echo $1; ?>'
,
$value
);
}
...
...
@@ -45,7 +41,7 @@ class Blade {
* @param string $value
* @return string
*/
protected
static
function
rewrite_
openings
(
$value
)
protected
static
function
openings
(
$value
)
{
return
preg_replace
(
'/@(if|elseif|foreach|for|while)(\s*\(.*?\))\:/'
,
'<?php $1$2: ?>'
,
$value
);
}
...
...
@@ -56,7 +52,7 @@ class Blade {
* @param string $value
* @return string
*/
protected
static
function
rewrite_
closings
(
$value
)
protected
static
function
closings
(
$value
)
{
$value
=
preg_replace
(
'/(\s*)@(else)(.*?)\:/'
,
'$1<?php $2$3: ?>'
,
$value
);
$value
=
preg_replace
(
'/(\s*)@(endif|endforeach|endfor|endwhile)(\s*)/'
,
'$1<?php $2; ?> $3'
,
$value
);
...
...
laravel/bootstrap/core.php
View file @
54c69d8c
...
...
@@ -17,6 +17,8 @@ define('CONFIG_PATH', APP_PATH.'config/');
define
(
'CONTROLLER_PATH'
,
APP_PATH
.
'controllers/'
);
define
(
'DATABASE_PATH'
,
STORAGE_PATH
.
'database/'
);
define
(
'LANG_PATH'
,
APP_PATH
.
'language/'
);
define
(
'LIBRARY_PATH'
,
APP_PATH
.
'libraries/'
);
define
(
'MODEL_PATH'
,
APP_PATH
.
'models/'
);
define
(
'ROUTE_PATH'
,
APP_PATH
.
'routes/'
);
define
(
'SESSION_PATH'
,
STORAGE_PATH
.
'sessions/'
);
define
(
'SYS_CONFIG_PATH'
,
SYS_PATH
.
'config/'
);
...
...
@@ -68,11 +70,7 @@ IoC::$container = $container;
* Register the application auto-loader. The auto-loader is responsible for the lazy-loading
* of all of the Laravel core classes, as well as the developer created libraries and models.
*/
spl_autoload_register
(
array
(
'Laravel\\Loader'
,
'load'
));
Loader
::
$paths
=
array
(
BASE_PATH
,
APP_PATH
.
'models/'
,
APP_PATH
.
'libraries/'
,
APP_PATH
);
Loader
::
$aliases
=
Config
::
get
(
'aliases'
);
spl_autoload_register
(
array
(
$container
->
resolve
(
'laravel.loader'
),
'load'
));
/**
* Define a few convenient global functions.
...
...
laravel/config/container.php
View file @
54c69d8c
...
...
@@ -64,6 +64,12 @@ return array(
}),
'laravel.loader'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Loader
(
array
(
BASE_PATH
,
MODEL_PATH
,
LIBRARY_PATH
,
BASE_PATH
),
Config
::
get
(
'aliases'
));
}),
'laravel.request'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Request
(
$c
->
resolve
(
'laravel.uri'
),
$_SERVER
,
$_POST
);
...
...
laravel/database/connection.php
View file @
54c69d8c
<?php
namespace
Laravel\Database
;
use
PDO
;
use
PDOStatement
;
<?php
namespace
Laravel\Database
;
use
PDO
,
PDOStatement
;
class
Connection
{
...
...
@@ -49,6 +46,14 @@ class Connection {
/**
* Execute a SQL query against the connection and return a scalar result.
*
* <code>
* // Get the total number of rows on a table
* $count = DB::connection()->scalar('select count(*) from users');
*
* // Get the sum of payment amounts from a table
* $sum = DB::connection()->scalar('select sum(amount) from payments')
* </code>
*
* @param string $sql
* @param array $bindings
* @return int|float
...
...
@@ -63,13 +68,21 @@ class Connection {
/**
* Execute a SQL query against the connection and return the first result.
*
* <code>
* // Execute a query against the database connection
* $user = DB::connection()->first('select * from users');
*
* // Execute a query with bound parameters
* $user = DB::connection()->first('select * from users where id = ?', array($id));
* </code>
*
* @param string $sql
* @param array $bindings
* @return object
*/
public
function
first
(
$sql
,
$bindings
=
array
())
{
return
(
count
(
$results
=
$this
->
query
(
$sql
,
$bindings
))
>
0
)
?
$results
[
0
]
:
null
;
if
(
count
(
$results
=
$this
->
query
(
$sql
,
$bindings
))
>
0
)
return
$results
[
0
]
;
}
/**
...
...
@@ -82,6 +95,14 @@ class Connection {
* DELETE -> Number of Rows affected.
* ELSE -> Boolean true / false depending on success.
*
* <code>
* // Execute a query against the database connection
* $users = DB::connection()->query('select * from users');
*
* // Execute a query with bound parameters
* $user = DB::connection()->query('select * from users where id = ?', array($id));
* </code>
*
* @param string $sql
* @param array $bindings
* @return mixed
...
...
laravel/database/manager.php
View file @
54c69d8c
...
...
@@ -18,6 +18,14 @@ class Manager {
*
* Note: Database connections are managed as singletons.
*
* <code>
* // Get the default database connection for the application
* $connection = DB::connection();
*
* // Get a specific connection by passing the connection name
* $connection = DB::connection('mysql');
* </code>
*
* @param string $connection
* @return Connection
*/
...
...
laravel/loader.php
View file @
54c69d8c
...
...
@@ -7,32 +7,56 @@ class Loader {
*
* @var array
*/
p
ublic
static
$paths
=
array
();
p
rotected
$paths
=
array
();
/**
* The class aliases defined for the application.
*
* @var array
*/
public
static
$aliases
=
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
;
}
/**
* Load the file for a given class.
*
* <code>
* // Load the file for the "User" class
* Loader::load('User');
*
* // Load the file for the "Repositories\User" class
* Loader::load('Repositories\\User');
* </code>
*
* @param string $class
* @return void
*/
public
static
function
load
(
$class
)
public
function
load
(
$class
)
{
// All Laravel core classes follow a namespace to directory convention.
So, we will
// replace all of the namespace slashes with directory slashes.
// All Laravel core classes follow a namespace to directory convention.
//
We will
replace all of the namespace slashes with directory slashes.
$file
=
strtolower
(
str_replace
(
'\\'
,
'/'
,
$class
));
// First, we'll check to determine if an alias exists. If it does, we will define the
// alias and bail out. Aliases are defined for most developer used core classes.
if
(
array_key_exists
(
$class
,
static
::
$aliases
))
return
class_alias
(
static
::
$aliases
[
$class
],
$class
);
// 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
))
{
return
class_alias
(
$this
->
aliases
[
$class
],
$class
);
}
foreach
(
static
::
$
paths
as
$path
)
foreach
(
$this
->
paths
as
$path
)
{
if
(
file_exists
(
$path
=
$path
.
$file
.
EXT
))
{
...
...
@@ -46,15 +70,13 @@ class Loader {
/**
* Register a class alias with the auto-loader.
*
* Note: Aliases are lazy-loaded, so the aliased class will not be included until it is needed.
*
* @param string $alias
* @param string $class
* @return void
*/
public
static
function
alias
(
$alias
,
$class
)
public
function
alias
(
$alias
,
$class
)
{
static
::
$
aliases
[
$alias
]
=
$class
;
$this
->
aliases
[
$alias
]
=
$class
;
}
/**
...
...
@@ -63,9 +85,9 @@ class Loader {
* @param string $path
* @return void
*/
public
static
function
path
(
$path
)
public
function
path
(
$path
)
{
static
::
$
paths
[]
=
rtrim
(
$path
,
'/'
)
.
'/'
;
$this
->
paths
[]
=
rtrim
(
$path
,
'/'
)
.
'/'
;
}
/**
...
...
@@ -74,9 +96,9 @@ class Loader {
* @param string $alias
* @return void
*/
public
static
function
forget_alias
(
$alias
)
public
function
forget_alias
(
$alias
)
{
unset
(
static
::
$
aliases
[
$alias
]);
unset
(
$this
->
aliases
[
$alias
]);
}
}
\ No newline at end of file
laravel/validation/validator.php
View file @
54c69d8c
...
...
@@ -285,7 +285,9 @@ class Validator {
$value
=
$this
->
attributes
[
$attribute
];
return
(
array_key_exists
(
$attribute
,
$_FILES
))
?
$value
[
'size'
]
/
1024
:
Str
::
length
(
trim
(
$value
));
$files
=
IoC
::
container
()
->
resolve
(
'laravel.input'
)
->
files
();
return
(
array_key_exists
(
$attribute
,
$files
)
?
$value
[
'size'
]
/
1024
:
Str
::
length
(
trim
(
$value
));
}
/**
...
...
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