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
541cb903
Commit
541cb903
authored
Aug 05, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor view class.
parent
55e8f0e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
+26
-14
view.php
system/view.php
+26
-14
No files found.
system/view.php
View file @
541cb903
...
...
@@ -57,11 +57,6 @@ class View {
list
(
$this
->
module
,
$this
->
path
,
$this
->
view
)
=
static
::
parse
(
$view
);
if
(
!
file_exists
(
$this
->
path
.
$this
->
view
.
EXT
))
{
throw
new
\Exception
(
"View [
$view
] does not exist."
);
}
$this
->
compose
();
}
...
...
@@ -95,7 +90,7 @@ class View {
if
(
!
is_null
(
$view
=
static
::
find_view_for_name
(
$name
,
static
::
$composers
[
$module
])))
{
return
new
static
(
$view
,
$data
);
return
new
static
(
$view
,
$data
);
}
}
...
...
@@ -145,7 +140,7 @@ class View {
$view
=
substr
(
$view
,
strpos
(
$view
,
':'
)
+
2
);
}
return
array
(
$module
,
$path
,
str_replace
(
'.'
,
'/'
,
$view
)
);
return
array
(
$module
,
$path
,
$view
);
}
/**
...
...
@@ -211,23 +206,40 @@ class View {
*/
public
function
get
()
{
foreach
(
$this
->
data
as
&
$data
)
$view
=
str_replace
(
'.'
,
'/'
,
$this
->
view
);
if
(
!
file_exists
(
$this
->
path
.
$view
.
EXT
))
{
if
(
$data
instanceof
View
or
$data
instanceof
Response
)
{
$data
=
(
string
)
$data
;
}
throw
new
\Exception
(
"View [
$view
] does not exist."
);
}
$this
->
get_sub_views
();
extract
(
$this
->
data
,
EXTR_SKIP
);
ob_start
();
try
{
include
$this
->
path
.
$
this
->
view
.
EXT
;
}
catch
(
\Exception
$e
)
{
Error
::
handle
(
$e
);
}
try
{
include
$this
->
path
.
$view
.
EXT
;
}
catch
(
\Exception
$e
)
{
Error
::
handle
(
$e
);
}
return
ob_get_clean
();
}
/**
* Evaluate all of the view and response instances that are bound to the view.
*
* @return void
*/
private
function
get_sub_views
()
{
foreach
(
$this
->
data
as
&
$data
)
{
if
(
$data
instanceof
View
or
$data
instanceof
Response
)
{
$data
=
(
string
)
$data
;
}
}
}
/**
* Add a view instance to the view data.
*
...
...
@@ -238,7 +250,7 @@ class View {
*/
public
function
partial
(
$key
,
$view
,
$data
=
array
())
{
return
$this
->
bind
(
$key
,
static
::
make
(
$view
,
$data
));
return
$this
->
bind
(
$key
,
new
static
(
$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