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
Show 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 {
...
@@ -57,11 +57,6 @@ class View {
list
(
$this
->
module
,
$this
->
path
,
$this
->
view
)
=
static
::
parse
(
$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
();
$this
->
compose
();
}
}
...
@@ -145,7 +140,7 @@ class View {
...
@@ -145,7 +140,7 @@ class View {
$view
=
substr
(
$view
,
strpos
(
$view
,
':'
)
+
2
);
$view
=
substr
(
$view
,
strpos
(
$view
,
':'
)
+
2
);
}
}
return
array
(
$module
,
$path
,
str_replace
(
'.'
,
'/'
,
$view
)
);
return
array
(
$module
,
$path
,
$view
);
}
}
/**
/**
...
@@ -211,23 +206,40 @@ class View {
...
@@ -211,23 +206,40 @@ class View {
*/
*/
public
function
get
()
public
function
get
()
{
{
foreach
(
$this
->
data
as
&
$data
)
$view
=
str_replace
(
'.'
,
'/'
,
$this
->
view
);
{
if
(
$data
instanceof
View
or
$data
instanceof
Response
)
if
(
!
file_exists
(
$this
->
path
.
$view
.
EXT
)
)
{
{
$data
=
(
string
)
$data
;
throw
new
\Exception
(
"View [
$view
] does not exist."
);
}
}
}
$this
->
get_sub_views
();
extract
(
$this
->
data
,
EXTR_SKIP
);
extract
(
$this
->
data
,
EXTR_SKIP
);
ob_start
();
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
();
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.
* Add a view instance to the view data.
*
*
...
@@ -238,7 +250,7 @@ class View {
...
@@ -238,7 +250,7 @@ class View {
*/
*/
public
function
partial
(
$key
,
$view
,
$data
=
array
())
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