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
319dcbe7
Commit
319dcbe7
authored
Jun 23, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:taylorotwell/laravel into develop
parents
3392971c
d7aca820
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
48 additions
and
55 deletions
+48
-55
hydrator.php
system/db/eloquent/hydrator.php
+3
-2
lang.php
system/lang.php
+18
-31
rule.php
system/validation/rule.php
+14
-10
format_of.php
system/validation/rules/format_of.php
+1
-1
presence_of.php
system/validation/rules/presence_of.php
+1
-1
size_of.php
system/validation/rules/size_of.php
+1
-1
uniqueness_of.php
system/validation/rules/uniqueness_of.php
+0
-1
with_callback.php
system/validation/rules/with_callback.php
+2
-2
validator.php
system/validator.php
+3
-3
view.php
system/view.php
+5
-3
No files found.
system/db/eloquent/hydrator.php
View file @
319dcbe7
...
@@ -78,8 +78,9 @@ class Hydrator {
...
@@ -78,8 +78,9 @@ class Hydrator {
// -----------------------------------------------------
// -----------------------------------------------------
// Get the relationship Eloquent model.
// Get the relationship Eloquent model.
//
//
// We temporarily spoof the "belongs_to" key to allow
// We temporarily spoof the belongs_to key to allow the
// the query to be fetched without any problems.
// query to be fetched without any problems, since the
// belongs_to method actually gets the attribute.
// -----------------------------------------------------
// -----------------------------------------------------
$eloquent
->
attributes
[
$spoof
=
$include
.
'_id'
]
=
0
;
$eloquent
->
attributes
[
$spoof
=
$include
.
'_id'
]
=
0
;
...
...
system/lang.php
View file @
319dcbe7
...
@@ -2,13 +2,6 @@
...
@@ -2,13 +2,6 @@
class
Lang
{
class
Lang
{
/**
* All of the loaded language files.
*
* @var array
*/
private
static
$loaded
=
array
();
/**
/**
* All of the loaded language lines.
* All of the loaded language lines.
*
*
...
@@ -55,24 +48,30 @@ class Lang {
...
@@ -55,24 +48,30 @@ class Lang {
}
}
/**
/**
* Get the language line
for a given language
.
* Get the language line.
*
*
* @param
string $language
* @param
mixed $default
* @return string
* @return string
*/
*/
public
function
get
(
$language
=
null
)
public
function
get
(
$default
=
null
)
{
if
(
is_null
(
$language
))
{
{
$language
=
Config
::
get
(
'application.language'
);
$language
=
Config
::
get
(
'application.language'
);
}
list
(
$file
,
$line
)
=
$this
->
parse
(
$this
->
key
);
list
(
$file
,
$line
)
=
$this
->
parse
(
$this
->
key
);
$this
->
load
(
$file
,
$language
);
$this
->
load
(
$file
,
$language
);
// --------------------------------------------------------------
// If the language file did not exist, return the default value.
// --------------------------------------------------------------
if
(
!
array_key_exists
(
$language
.
$file
,
static
::
$lines
))
{
return
$default
;
}
// --------------------------------------------------------------
// --------------------------------------------------------------
// Get the language line from the appropriate file array.
// Get the language line from the appropriate file array.
// If the line doesn't exist, return the default value.
// --------------------------------------------------------------
// --------------------------------------------------------------
if
(
array_key_exists
(
$line
,
static
::
$lines
[
$language
.
$file
]))
if
(
array_key_exists
(
$line
,
static
::
$lines
[
$language
.
$file
]))
{
{
...
@@ -80,7 +79,7 @@ class Lang {
...
@@ -80,7 +79,7 @@ class Lang {
}
}
else
else
{
{
throw
new
\Exception
(
"Language line [
$line
] does not exist for language [
$language
]"
)
;
return
$default
;
}
}
// --------------------------------------------------------------
// --------------------------------------------------------------
...
@@ -127,28 +126,16 @@ class Lang {
...
@@ -127,28 +126,16 @@ class Lang {
private
function
load
(
$file
,
$language
)
private
function
load
(
$file
,
$language
)
{
{
// --------------------------------------------------------------
// --------------------------------------------------------------
// If we have already loaded the language file, bail out.
// If we have already loaded the language file or the file
// doesn't exist, bail out.
// --------------------------------------------------------------
// --------------------------------------------------------------
if
(
in_array
(
$language
.
$file
,
static
::
$loaded
))
if
(
array_key_exists
(
$language
.
$file
,
static
::
$lines
)
or
!
file_exists
(
$path
=
APP_PATH
.
'lang/'
.
$language
.
'/'
.
$file
.
EXT
))
{
{
return
;
return
;
}
}
// --------------------------------------------------------------
// Load the language file into the array of lines. The array
// is keyed by the language and file name.
// --------------------------------------------------------------
if
(
file_exists
(
$path
=
APP_PATH
.
'lang/'
.
$language
.
'/'
.
$file
.
EXT
))
{
static
::
$lines
[
$language
.
$file
]
=
require
$path
;
static
::
$lines
[
$language
.
$file
]
=
require
$path
;
}
}
else
{
throw
new
\Exception
(
"Language file [
$file
] does not exist for language [
$language
]."
);
}
static
::
$loaded
[]
=
$language
.
$file
;
}
/**
/**
* Set the place-holder replacements.
* Set the place-holder replacements.
...
...
system/validation/rule.php
View file @
319dcbe7
...
@@ -5,7 +5,7 @@ use System\Lang;
...
@@ -5,7 +5,7 @@ use System\Lang;
abstract
class
Rule
{
abstract
class
Rule
{
/**
/**
* The attributes being validated.
* The attributes being validated
by the rule
.
*
*
* @var array
* @var array
*/
*/
...
@@ -22,7 +22,6 @@ abstract class Rule {
...
@@ -22,7 +22,6 @@ abstract class Rule {
* Create a new validation Rule instance.
* Create a new validation Rule instance.
*
*
* @param array $attributes
* @param array $attributes
* @param Validator $class
* @return void
* @return void
*/
*/
public
function
__construct
(
$attributes
)
public
function
__construct
(
$attributes
)
...
@@ -39,11 +38,6 @@ abstract class Rule {
...
@@ -39,11 +38,6 @@ abstract class Rule {
*/
*/
public
function
validate
(
$attributes
,
$errors
)
public
function
validate
(
$attributes
,
$errors
)
{
{
if
(
is_null
(
$this
->
message
))
{
throw
new
\Exception
(
"An error message must be specified for every Eloquent validation rule."
);
}
foreach
(
$this
->
attributes
as
$attribute
)
foreach
(
$this
->
attributes
as
$attribute
)
{
{
if
(
!
$this
->
check
(
$attribute
,
$attributes
))
if
(
!
$this
->
check
(
$attribute
,
$attributes
))
...
@@ -56,18 +50,28 @@ abstract class Rule {
...
@@ -56,18 +50,28 @@ abstract class Rule {
/**
/**
* Prepare the message to be added to the error collector.
* Prepare the message to be added to the error collector.
*
*
* Attribute and size place-holders will replace with their actual values.
*
* @param string $attribute
* @param string $attribute
* @return string
* @return string
*/
*/
private
function
prepare_message
(
$attribute
)
private
function
prepare_message
(
$attribute
)
{
{
if
(
is_null
(
$this
->
message
))
{
throw
new
\Exception
(
"An error message must be specified for every Eloquent validation rule."
);
}
$message
=
$this
->
message
;
$message
=
$this
->
message
;
// ---------------------------------------------------------
// Replace any place-holders with their actual values.
//
// Attribute place-holders are loaded from the language
// directory. If the line doesn't exist, the attribute
// name will be used instead.
// ---------------------------------------------------------
if
(
strpos
(
$message
,
':attribute'
))
if
(
strpos
(
$message
,
':attribute'
))
{
{
$message
=
str_replace
(
':attribute'
,
Lang
::
line
(
'attributes.'
.
$attribute
)
->
get
(),
$message
);
$message
=
str_replace
(
':attribute'
,
Lang
::
line
(
'attributes.'
.
$attribute
)
->
get
(
$attribute
),
$message
);
}
}
if
(
$this
instanceof
Rules\Size_Of
)
if
(
$this
instanceof
Rules\Size_Of
)
...
...
system/validation/rules/format_of.php
View file @
319dcbe7
...
@@ -5,7 +5,7 @@ use System\Validation\Rule;
...
@@ -5,7 +5,7 @@ use System\Validation\Rule;
class
Format_Of
extends
Rule
{
class
Format_Of
extends
Rule
{
/**
/**
* The regular expression that will be used to
evalu
ate the attribute.
* The regular expression that will be used to
valid
ate the attribute.
*
*
* @var string
* @var string
*/
*/
...
...
system/validation/rules/presence_of.php
View file @
319dcbe7
...
@@ -12,7 +12,7 @@ class Presence_Of extends Rule {
...
@@ -12,7 +12,7 @@ class Presence_Of extends Rule {
public
$allow_empty
=
false
;
public
$allow_empty
=
false
;
/**
/**
* Indicates
a
null should be considered present.
* Indicates null should be considered present.
*
*
* @var bool
* @var bool
*/
*/
...
...
system/validation/rules/size_of.php
View file @
319dcbe7
...
@@ -119,7 +119,7 @@ class Size_Of extends Rule {
...
@@ -119,7 +119,7 @@ class Size_Of extends Rule {
}
}
/**
/**
* Set the minimum and maxim
ize
size of the attribute.
* Set the minimum and maxim
um
size of the attribute.
*
*
* @param int $minimum
* @param int $minimum
* @param int $maximum
* @param int $maximum
...
...
system/validation/rules/uniqueness_of.php
View file @
319dcbe7
<?php
namespace
System\Validation\Rules
;
<?php
namespace
System\Validation\Rules
;
use
System\DB
;
use
System\DB
;
use
System\DB\Eloquent
;
use
System\Validation\Rule
;
use
System\Validation\Rule
;
class
Uniqueness_Of
extends
Rule
{
class
Uniqueness_Of
extends
Rule
{
...
...
system/validation/rules/with_callback.php
View file @
319dcbe7
...
@@ -5,7 +5,7 @@ use System\Validation\Rule;
...
@@ -5,7 +5,7 @@ use System\Validation\Rule;
class
With_Callback
extends
Rule
{
class
With_Callback
extends
Rule
{
/**
/**
* The callback.
* The callback
that will be used to validate the attribute
.
*
*
* @var function
* @var function
*/
*/
...
@@ -27,7 +27,7 @@ class With_Callback extends Rule {
...
@@ -27,7 +27,7 @@ class With_Callback extends Rule {
if
(
!
is_callable
(
$this
->
callback
))
if
(
!
is_callable
(
$this
->
callback
))
{
{
throw
new
\Exception
(
"
A
validation callback for the [
$attribute
] attribute is not callable."
);
throw
new
\Exception
(
"
The
validation callback for the [
$attribute
] attribute is not callable."
);
}
}
return
call_user_func
(
$this
->
callback
,
$attributes
[
$attribute
]);
return
call_user_func
(
$this
->
callback
,
$attributes
[
$attribute
]);
...
...
system/validator.php
View file @
319dcbe7
...
@@ -24,7 +24,7 @@ class Validator {
...
@@ -24,7 +24,7 @@ class Validator {
public
$rules
=
array
();
public
$rules
=
array
();
/**
/**
* Create a new
Eloquent v
alidator instance.
* Create a new
V
alidator instance.
*
*
* @param mixed $target
* @param mixed $target
* @return void
* @return void
...
@@ -41,7 +41,7 @@ class Validator {
...
@@ -41,7 +41,7 @@ class Validator {
}
}
/**
/**
* Create a new
Eloquent v
alidator instance.
* Create a new
V
alidator instance.
*
*
* @param mixed $target
* @param mixed $target
* @return Validator
* @return Validator
...
@@ -52,7 +52,7 @@ class Validator {
...
@@ -52,7 +52,7 @@ class Validator {
}
}
/**
/**
* Determine if the
model passe
s all of the validation rules.
* Determine if the
attributes pas
s all of the validation rules.
*
*
* @return bool
* @return bool
*/
*/
...
...
system/view.php
View file @
319dcbe7
...
@@ -95,6 +95,9 @@ class View {
...
@@ -95,6 +95,9 @@ class View {
// We include the view into the local scope within a
// We include the view into the local scope within a
// try / catch block to catch any exceptions that may
// try / catch block to catch any exceptions that may
// occur while the view is rendering.
// occur while the view is rendering.
//
// Otherwise, a white screen of death will be shown
// if an exception occurs while rendering the view.
// -----------------------------------------------------
// -----------------------------------------------------
try
try
{
{
...
@@ -111,9 +114,8 @@ class View {
...
@@ -111,9 +114,8 @@ class View {
/**
/**
* Get the full path to the view.
* Get the full path to the view.
*
*
* Views are cascaded, so the application directory views
* Views are cascaded, so the application directory views will take
* will take precedence over the system directory's views
* precedence over system directory views of the same name.
* of the same name.
*
*
* @return string
* @return string
*/
*/
...
...
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