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
Hide 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 {
// -----------------------------------------------------
// Get the relationship Eloquent model.
//
// We temporarily spoof the "belongs_to" key to allow
// the query to be fetched without any problems.
// We temporarily spoof the belongs_to key to allow the
// query to be fetched without any problems, since the
// belongs_to method actually gets the attribute.
// -----------------------------------------------------
$eloquent
->
attributes
[
$spoof
=
$include
.
'_id'
]
=
0
;
...
...
system/lang.php
View file @
319dcbe7
...
...
@@ -2,13 +2,6 @@
class
Lang
{
/**
* All of the loaded language files.
*
* @var array
*/
private
static
$loaded
=
array
();
/**
* All of the loaded language lines.
*
...
...
@@ -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
*/
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
);
$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.
// If the line doesn't exist, return the default value.
// --------------------------------------------------------------
if
(
array_key_exists
(
$line
,
static
::
$lines
[
$language
.
$file
]))
{
...
...
@@ -80,7 +79,7 @@ class Lang {
}
else
{
throw
new
\Exception
(
"Language line [
$line
] does not exist for language [
$language
]"
)
;
return
$default
;
}
// --------------------------------------------------------------
...
...
@@ -127,27 +126,15 @@ class Lang {
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
;
}
// --------------------------------------------------------------
// 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
;
}
else
{
throw
new
\Exception
(
"Language file [
$file
] does not exist for language [
$language
]."
);
}
static
::
$loaded
[]
=
$language
.
$file
;
static
::
$lines
[
$language
.
$file
]
=
require
$path
;
}
/**
...
...
system/validation/rule.php
View file @
319dcbe7
...
...
@@ -5,7 +5,7 @@ use System\Lang;
abstract
class
Rule
{
/**
* The attributes being validated.
* The attributes being validated
by the rule
.
*
* @var array
*/
...
...
@@ -22,7 +22,6 @@ abstract class Rule {
* Create a new validation Rule instance.
*
* @param array $attributes
* @param Validator $class
* @return void
*/
public
function
__construct
(
$attributes
)
...
...
@@ -39,11 +38,6 @@ abstract class Rule {
*/
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
)
{
if
(
!
$this
->
check
(
$attribute
,
$attributes
))
...
...
@@ -56,18 +50,28 @@ abstract class Rule {
/**
* Prepare the message to be added to the error collector.
*
* Attribute and size place-holders will replace with their actual values.
*
* @param string $attribute
* @return string
*/
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
;
// ---------------------------------------------------------
// 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'
))
{
$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
)
...
...
system/validation/rules/format_of.php
View file @
319dcbe7
...
...
@@ -5,7 +5,7 @@ use System\Validation\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
*/
...
...
system/validation/rules/presence_of.php
View file @
319dcbe7
...
...
@@ -12,7 +12,7 @@ class Presence_Of extends Rule {
public
$allow_empty
=
false
;
/**
* Indicates
a
null should be considered present.
* Indicates null should be considered present.
*
* @var bool
*/
...
...
system/validation/rules/size_of.php
View file @
319dcbe7
...
...
@@ -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 $maximum
...
...
system/validation/rules/uniqueness_of.php
View file @
319dcbe7
<?php
namespace
System\Validation\Rules
;
use
System\DB
;
use
System\DB\Eloquent
;
use
System\Validation\Rule
;
class
Uniqueness_Of
extends
Rule
{
...
...
system/validation/rules/with_callback.php
View file @
319dcbe7
...
...
@@ -5,7 +5,7 @@ use System\Validation\Rule;
class
With_Callback
extends
Rule
{
/**
* The callback.
* The callback
that will be used to validate the attribute
.
*
* @var function
*/
...
...
@@ -27,7 +27,7 @@ class With_Callback extends Rule {
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
]);
...
...
system/validator.php
View file @
319dcbe7
...
...
@@ -24,7 +24,7 @@ class Validator {
public
$rules
=
array
();
/**
* Create a new
Eloquent v
alidator instance.
* Create a new
V
alidator instance.
*
* @param mixed $target
* @return void
...
...
@@ -41,7 +41,7 @@ class Validator {
}
/**
* Create a new
Eloquent v
alidator instance.
* Create a new
V
alidator instance.
*
* @param mixed $target
* @return 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
*/
...
...
system/view.php
View file @
319dcbe7
...
...
@@ -95,6 +95,9 @@ class View {
// We include the view into the local scope within a
// try / catch block to catch any exceptions that may
// occur while the view is rendering.
//
// Otherwise, a white screen of death will be shown
// if an exception occurs while rendering the view.
// -----------------------------------------------------
try
{
...
...
@@ -111,9 +114,8 @@ class View {
/**
* Get the full path to the view.
*
* Views are cascaded, so the application directory views
* will take precedence over the system directory's views
* of the same name.
* Views are cascaded, so the application directory views will take
* precedence over system directory views of the same name.
*
* @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