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
7a202403
Commit
7a202403
authored
Sep 22, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some comments to the view class.
parent
5d67672d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
24 deletions
+66
-24
str.php
laravel/str.php
+3
-13
uri.php
laravel/uri.php
+8
-0
url.php
laravel/url.php
+35
-3
view.php
laravel/view.php
+20
-8
No files found.
laravel/str.php
View file @
7a202403
...
@@ -12,7 +12,7 @@ class Str {
...
@@ -12,7 +12,7 @@ class Str {
{
{
if
(
function_exists
(
'mb_strtolower'
))
if
(
function_exists
(
'mb_strtolower'
))
{
{
return
mb_strtolower
(
$value
,
static
::
encoding
(
));
return
mb_strtolower
(
$value
,
Config
::
get
(
'application.encoding'
));
}
}
return
strtolower
(
$value
);
return
strtolower
(
$value
);
...
@@ -44,7 +44,7 @@ class Str {
...
@@ -44,7 +44,7 @@ class Str {
{
{
if
(
function_exists
(
'mb_convert_case'
))
if
(
function_exists
(
'mb_convert_case'
))
{
{
return
mb_convert_case
(
$value
,
MB_CASE_TITLE
,
static
::
encoding
(
));
return
mb_convert_case
(
$value
,
MB_CASE_TITLE
,
Config
::
get
(
'application.encoding'
));
}
}
return
ucwords
(
strtolower
(
$value
));
return
ucwords
(
strtolower
(
$value
));
...
@@ -60,7 +60,7 @@ class Str {
...
@@ -60,7 +60,7 @@ class Str {
{
{
if
(
function_exists
(
'mb_strlen'
))
if
(
function_exists
(
'mb_strlen'
))
{
{
return
mb_strlen
(
$value
,
static
::
encoding
(
));
return
mb_strlen
(
$value
,
Config
::
get
(
'application.encoding'
));
}
}
return
strlen
(
$value
);
return
strlen
(
$value
);
...
@@ -99,14 +99,4 @@ class Str {
...
@@ -99,14 +99,4 @@ class Str {
return
implode
(
''
,
array_map
(
function
()
use
(
$pool
)
{
return
$pool
[
mt_rand
(
0
,
strlen
(
$pool
)
-
1
)];
},
range
(
0
,
$length
-
1
)));
return
implode
(
''
,
array_map
(
function
()
use
(
$pool
)
{
return
$pool
[
mt_rand
(
0
,
strlen
(
$pool
)
-
1
)];
},
range
(
0
,
$length
-
1
)));
}
}
/**
* Get the application encoding from the configuration class.
*
* @return string
*/
protected
static
function
encoding
()
{
return
Config
::
get
(
'application.encoding'
);
}
}
}
\ No newline at end of file
laravel/uri.php
View file @
7a202403
...
@@ -56,6 +56,14 @@ class URI {
...
@@ -56,6 +56,14 @@ class URI {
/**
/**
* Get a given URI segment from the URI for the current request.
* Get a given URI segment from the URI for the current request.
*
*
* <code>
* // Get the first URI segment for the request
* $first = URI::segment(1);
*
* // Return a default value if the URI segment doesn't exist
* $segment = URI::segment(3, 'Default');
* </code>
*
* @param int $segment
* @param int $segment
* @param mixed $default
* @param mixed $default
* @return string
* @return string
...
...
laravel/url.php
View file @
7a202403
...
@@ -7,6 +7,11 @@ class URL {
...
@@ -7,6 +7,11 @@ class URL {
*
*
* If the given URL is already well-formed, it will be returned unchanged.
* If the given URL is already well-formed, it will be returned unchanged.
*
*
* <code>
* // Create a URL to a location within the application
* $url = URL::to('user/profile');
* </code>
*
* @param string $url
* @param string $url
* @param bool $https
* @param bool $https
* @return string
* @return string
...
@@ -57,6 +62,14 @@ class URL {
...
@@ -57,6 +62,14 @@ class URL {
* parameter to the method. The values of this array will be used to fill the
* parameter to the method. The values of this array will be used to fill the
* wildcard segments of the route URI.
* wildcard segments of the route URI.
*
*
* <code>
* // Create a URL to the "profile" named route
* $url = URL::to_route('profile');
*
* // Create a URL to the "profile" named route with wildcard parameters
* $url = URL::to_route('profile', array($username));
* </code>
*
* @param string $name
* @param string $name
* @param array $parameters
* @param array $parameters
* @param bool $https
* @param bool $https
...
@@ -70,9 +83,9 @@ class URL {
...
@@ -70,9 +83,9 @@ class URL {
$uri
=
substr
(
$uris
[
0
],
strpos
(
$uris
[
0
],
'/'
));
$uri
=
substr
(
$uris
[
0
],
strpos
(
$uris
[
0
],
'/'
));
// Spin through each route parameter and replace the route wildcard
segment
// Spin through each route parameter and replace the route wildcard
// with the corresponding parameter passed to the method.
//
segment
with the corresponding parameter passed to the method.
foreach
(
$parameters
as
$parameter
)
foreach
(
(
array
)
$parameters
as
$parameter
)
{
{
$uri
=
preg_replace
(
'/\(.+?\)/'
,
$parameter
,
$uri
,
1
);
$uri
=
preg_replace
(
'/\(.+?\)/'
,
$parameter
,
$uri
,
1
);
}
}
...
@@ -100,6 +113,14 @@ class URL {
...
@@ -100,6 +113,14 @@ class URL {
/**
/**
* Generate a URL friendly "slug".
* Generate a URL friendly "slug".
*
*
* <code>
* // Returns "this-is-my-blog-post"
* $slug = URL::slug('This is my blog post!');
*
* // Returns "this_is_my_blog_post"
* $slug = URL::slug('This is my blog post!', '_');
* </code>
*
* @param string $title
* @param string $title
* @param string $separator
* @param string $separator
* @return string
* @return string
...
@@ -119,6 +140,17 @@ class URL {
...
@@ -119,6 +140,17 @@ class URL {
/**
/**
* Magic Method for dynamically creating URLs to named routes.
* Magic Method for dynamically creating URLs to named routes.
*
* <code>
* // Create a URL to the "profile" named route
* $url = URL::to_profile();
*
* // Create a URL to the "profile" named route with wildcard segments
* $url = URL::to_profile(array($username));
*
* // Create a URL to the "profile" named route using HTTPS
* $url = URL::to_secure_profile();
* </code>
*/
*/
public
static
function
__callStatic
(
$method
,
$parameters
)
public
static
function
__callStatic
(
$method
,
$parameters
)
{
{
...
...
laravel/view.php
View file @
7a202403
...
@@ -54,7 +54,7 @@ class View_Factory {
...
@@ -54,7 +54,7 @@ class View_Factory {
* @param array $data
* @param array $data
* @return View
* @return View
*/
*/
p
rotected
function
of
(
$name
,
$data
=
array
())
p
ublic
function
of
(
$name
,
$data
=
array
())
{
{
if
(
!
is_null
(
$view
=
$this
->
composer
->
name
(
$name
)))
if
(
!
is_null
(
$view
=
$this
->
composer
->
name
(
$name
)))
{
{
...
@@ -74,13 +74,9 @@ class View_Factory {
...
@@ -74,13 +74,9 @@ class View_Factory {
{
{
$view
=
str_replace
(
'.'
,
'/'
,
$view
);
$view
=
str_replace
(
'.'
,
'/'
,
$view
);
if
(
file_exists
(
$path
=
$this
->
path
.
$view
.
BLADE_EXT
)
)
foreach
(
array
(
BLADE_EXT
,
EXT
)
as
$extension
)
{
{
return
$path
;
if
(
file_exists
(
$path
=
$this
->
path
.
$view
.
$extension
))
return
$path
;
}
elseif
(
file_exists
(
$path
=
$this
->
path
.
$view
.
EXT
))
{
return
$path
;
}
}
throw
new
\Exception
(
'View ['
.
$view
.
'] does not exist.'
);
throw
new
\Exception
(
'View ['
.
$view
.
'] does not exist.'
);
...
@@ -219,6 +215,14 @@ class View {
...
@@ -219,6 +215,14 @@ class View {
* within your application views directory. Dots or slashes may used to
* within your application views directory. Dots or slashes may used to
* reference views within sub-directories.
* reference views within sub-directories.
*
*
* <code>
* // Create a new view instance
* $view = View::make('home.index');
*
* // Create a new view instance with bound data
* $view = View::make('home.index', array('name' => 'Taylor'));
* </code>
*
* @param string $view
* @param string $view
* @param array $data
* @param array $data
* @return View
* @return View
...
@@ -233,11 +237,19 @@ class View {
...
@@ -233,11 +237,19 @@ class View {
*
*
* View names are defined in the application composers file.
* View names are defined in the application composers file.
*
*
* <code>
* // Create an instance of the "layout" named view
* $view = View::of('layout');
*
* // Create an instance of the "layout" view with bound data
* $view = View::of('layout', array('name' => 'Taylor'));
* </code>
*
* @param string $name
* @param string $name
* @param array $data
* @param array $data
* @return View
* @return View
*/
*/
p
rotected
function
of
(
$name
,
$data
=
array
())
p
ublic
static
function
of
(
$name
,
$data
=
array
())
{
{
return
IoC
::
container
()
->
resolve
(
'laravel.view'
)
->
of
(
$name
,
$data
);
return
IoC
::
container
()
->
resolve
(
'laravel.view'
)
->
of
(
$name
,
$data
);
}
}
...
...
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