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
f4f82d17
Commit
f4f82d17
authored
Jul 26, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added View::of method and $view->partial() method.
parent
989ba674
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
8 deletions
+33
-8
view.php
system/view.php
+33
-8
No files found.
system/view.php
View file @
f4f82d17
...
...
@@ -49,6 +49,25 @@ class View {
return
new
static
(
$view
,
$data
);
}
/**
* Create a new named view instance.
*
* @param string $view
* @param array $data
* @return View
*/
public
static
function
of
(
$view
,
$data
=
array
())
{
$views
=
Config
::
get
(
'view.names'
);
if
(
!
array_key_exists
(
$view
,
$views
))
{
throw
new
\Exception
(
"Named view [
$view
] is not defined."
);
}
return
static
::
make
(
$views
[
$view
],
$data
);
}
/**
* Get the parsed content of the view.
*
...
...
@@ -98,6 +117,19 @@ class View {
}
}
/**
* Add a view instance to the view data.
*
* @param string $key
* @param string $view
* @param array $data
* @return View
*/
public
function
partial
(
$key
,
$view
,
$data
=
array
())
{
return
$this
->
bind
(
$key
,
View
::
make
(
$view
,
$data
));
}
/**
* Add a key / value pair to the view data.
*
...
...
@@ -118,14 +150,7 @@ class View {
{
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
());
return
static
::
of
(
substr
(
$method
,
3
),
Arr
::
get
(
$parameters
,
0
,
array
()));
}
}
...
...
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