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
8130f2da
Commit
8130f2da
authored
Aug 07, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring view class.
parent
ea3c59d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
27 deletions
+9
-27
view.php
system/view.php
+9
-27
No files found.
system/view.php
View file @
8130f2da
...
...
@@ -75,48 +75,32 @@ class View {
/**
* Create a new view instance from a view name.
*
* The view names for the active module will be searched first, followed by
* the view names for the application directory, followed by the view names
* for all other modules.
*
* @param string $name
* @param array $data
* @return View
*/
private
static
function
of
(
$name
,
$data
=
array
())
{
// Search the active module first, then the application module, then all other modules.
$modules
=
array_unique
(
array_merge
(
array
(
ACTIVE_MODULE
,
'application'
),
Config
::
get
(
'application.modules'
)));
foreach
(
$modules
as
$module
)
{
static
::
load_composers
(
$module
);
if
(
!
is_null
(
$view
=
static
::
find_view_for_name
(
$name
,
static
::
$composers
[
$module
])))
{
return
new
static
(
$view
,
$data
);
}
}
throw
new
\Exception
(
"Named view [
$name
] is not defined."
);
}
/**
* Find the view for a given name in an array of composers.
*
* @param string $name
* @param array $composers
* @return string
*/
private
static
function
find_view_for_name
(
$name
,
$composers
)
foreach
(
static
::
$composers
[
$module
]
as
$key
=>
$value
)
{
foreach
(
$composers
as
$key
=>
$value
)
if
(
$name
===
$value
or
(
isset
(
$value
[
'name'
])
and
$name
===
$value
[
'name'
])
)
{
if
(
is_string
(
$value
)
and
$value
==
$name
)
{
return
$key
;
return
new
static
(
$key
,
$data
);
}
elseif
(
is_array
(
$value
)
and
isset
(
$value
[
'name'
])
and
$value
[
'name'
]
==
$name
)
{
return
$key
;
}
}
throw
new
\Exception
(
"Named view [
$name
] is not defined."
);
}
/**
...
...
@@ -127,8 +111,6 @@ class View {
*/
private
static
function
parse
(
$view
)
{
// Check for a module qualifier. If a module name is present, we need to extract it from
// the view name, otherwise, we will use "application" as the module.
$module
=
(
strpos
(
$view
,
'::'
)
!==
false
)
?
substr
(
$view
,
0
,
strpos
(
$view
,
':'
))
:
'application'
;
$path
=
(
$module
==
'application'
)
?
VIEW_PATH
:
MODULE_PATH
.
$module
.
'/views/'
;
...
...
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