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
3038ed7a
Commit
3038ed7a
authored
Jun 17, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix view handling to properly catch exceptions when rendering.
parent
4669911d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
43 deletions
+55
-43
view.php
system/view.php
+55
-43
No files found.
system/view.php
View file @
3038ed7a
...
@@ -48,47 +48,6 @@ class View {
...
@@ -48,47 +48,6 @@ class View {
return
new
self
(
$view
,
$data
);
return
new
self
(
$view
,
$data
);
}
}
/**
* Load the content of a view.
*
* @param string $view
* @return string
*/
private
function
load
(
$view
)
{
// -----------------------------------------------------
// Does the view exist in the application directory?
// -----------------------------------------------------
if
(
file_exists
(
$path
=
APP_PATH
.
'views/'
.
$view
.
EXT
))
{
return
file_get_contents
(
$path
);
}
// -----------------------------------------------------
// Does the view exist in the system directory?
// -----------------------------------------------------
elseif
(
file_exists
(
$path
=
SYS_PATH
.
'views/'
.
$view
.
EXT
))
{
return
file_get_contents
(
$path
);
}
else
{
throw
new
\Exception
(
"View [
$view
] doesn't exist."
);
}
}
/**
* Add a key / value pair to the view data.
*
* @param string $key
* @param mixed $value
* @return View
*/
public
function
bind
(
$key
,
$value
)
{
$this
->
data
[
$key
]
=
$value
;
return
$this
;
}
/**
/**
* Get the parsed content of the view.
* Get the parsed content of the view.
*
*
...
@@ -118,15 +77,68 @@ class View {
...
@@ -118,15 +77,68 @@ class View {
extract
(
$this
->
data
,
EXTR_SKIP
);
extract
(
$this
->
data
,
EXTR_SKIP
);
// -----------------------------------------------------
// -----------------------------------------------------
// Get the string content of the view.
// Start the output buffer so nothing escapes to the
// browser. The response will be sent later.
// -----------------------------------------------------
// -----------------------------------------------------
ob_start
();
ob_start
();
echo
eval
(
'?>'
.
$this
->
load
(
$this
->
view
));
$path
=
$this
->
find
();
// -----------------------------------------------------
// We include the view into the local scope within a
// try / catch block to catch any exceptions that may
// occur while the view is rendering.
// -----------------------------------------------------
try
{
include
$path
;
}
catch
(
\Exception
$e
)
{
Error
::
handle
(
$e
);
}
return
ob_get_clean
();
return
ob_get_clean
();
}
}
/**
* Get the full path to the view.
*
* Views are cascaded, so the application directory views
* will take precedence over the system directory's views
* of the same name.
*
* @return string
*/
private
function
find
()
{
if
(
file_exists
(
$path
=
APP_PATH
.
'views/'
.
$this
->
view
.
EXT
))
{
return
$path
;
}
elseif
(
file_exists
(
$path
=
SYS_PATH
.
'views/'
.
$this
->
view
.
EXT
))
{
return
$path
;
}
else
{
throw
new
\Exception
(
"View ["
.
$this
->
view
.
"] doesn't exist."
);
}
}
/**
* Add a key / value pair to the view data.
*
* @param string $key
* @param mixed $value
* @return View
*/
public
function
bind
(
$key
,
$value
)
{
$this
->
data
[
$key
]
=
$value
;
return
$this
;
}
/**
/**
* 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