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
c1ca97d9
Commit
c1ca97d9
authored
Jul 22, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for named views.
parent
198e9591
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
5 deletions
+59
-5
view.php
application/config/view.php
+30
-0
redirect.php
system/redirect.php
+1
-1
view.php
system/view.php
+28
-4
No files found.
application/config/view.php
0 → 100644
View file @
c1ca97d9
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Named Views
|--------------------------------------------------------------------------
|
| Here you can define all of the named views for your application.
|
| Once you have defined the named view, you can create a View instance for
| that view using the View::of dynamic static method.
|
| For example, if you define a named view named "layout", you could create
| an instance of that View by calling: View::of_layout().
|
| For more info, check out: http://laravel.com/docs/start/views#named
|
| Note: The view path should be relative to the application/view directory.
|
*/
'names'
=>
array
(
'home'
=>
'home/index'
,
),
);
\ No newline at end of file
system/redirect.php
View file @
c1ca97d9
...
@@ -27,7 +27,7 @@ class Redirect {
...
@@ -27,7 +27,7 @@ class Redirect {
* @param string $method
* @param string $method
* @param int $status
* @param int $status
* @param bool $https
* @param bool $https
* @return Re
sponse
* @return Re
direct
*/
*/
public
static
function
to
(
$url
,
$method
=
'location'
,
$status
=
302
,
$https
=
false
)
public
static
function
to
(
$url
,
$method
=
'location'
,
$status
=
302
,
$https
=
false
)
{
{
...
...
system/view.php
View file @
c1ca97d9
...
@@ -16,6 +16,13 @@ class View {
...
@@ -16,6 +16,13 @@ class View {
*/
*/
public
$data
=
array
();
public
$data
=
array
();
/**
* The path to the view.
*
* @var string
*/
public
$path
;
/**
/**
* Create a new view instance.
* Create a new view instance.
*
*
...
@@ -27,6 +34,7 @@ class View {
...
@@ -27,6 +34,7 @@ class View {
{
{
$this
->
view
=
$view
;
$this
->
view
=
$view
;
$this
->
data
=
$data
;
$this
->
data
=
$data
;
$this
->
path
=
$this
->
find
();
}
}
/**
/**
...
@@ -38,7 +46,7 @@ class View {
...
@@ -38,7 +46,7 @@ class View {
*/
*/
public
static
function
make
(
$view
,
$data
=
array
())
public
static
function
make
(
$view
,
$data
=
array
())
{
{
return
new
s
elf
(
$view
,
$data
);
return
new
s
tatic
(
$view
,
$data
);
}
}
/**
/**
...
@@ -61,9 +69,7 @@ class View {
...
@@ -61,9 +69,7 @@ class View {
ob_start
();
ob_start
();
$path
=
$this
->
find
();
try
{
include
$this
->
path
;
}
catch
(
\Exception
$e
)
{
Error
::
handle
(
$e
);
}
try
{
include
$path
;
}
catch
(
\Exception
$e
)
{
Error
::
handle
(
$e
);
}
return
ob_get_clean
();
return
ob_get_clean
();
}
}
...
@@ -105,6 +111,24 @@ class View {
...
@@ -105,6 +111,24 @@ class View {
return
$this
;
return
$this
;
}
}
/**
* Magic Method for creating named view instances.
*/
public
static
function
__callStatic
(
$method
,
$parameters
)
{
if
(
strpos
(
$method
,
'of_'
)
===
0
)
{
$views
=
Config
::
get
(
'view.names'
);
if
(
!
array_key_exists
(
$view
=
substr
(
$method
,
3
),
$views
))
{
throw
new
\Exception
(
"Named view [
$view
] is not defined."
);
}
return
static
::
make
(
$views
[
$view
],
(
isset
(
$parameters
[
0
])
and
is_array
(
$parameters
[
0
]))
?
$parameters
[
0
]
:
array
());
}
}
/**
/**
* Magic Method for getting items from the view data.
* Magic Method for getting items from the view 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