Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-view
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-view
Commits
4bf33c29
Commit
4bf33c29
authored
6 years ago
by
dyszczo
Browse files
Options
Downloads
Patches
Plain Diff
dir resolver implementation
parent
2501b350
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!8
feat/woo template
,
!3
Feature/implementation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Resolver/DirResolver.php
+50
-0
50 additions, 0 deletions
src/Resolver/DirResolver.php
with
50 additions
and
0 deletions
src/Resolver/DirResolver.php
0 → 100644
+
50
−
0
View file @
4bf33c29
<?php
namespace
WPDesk\View\Resolver
;
use
WPDesk\View\Renderer\Renderer
;
use
WPDesk\View\Resolver\Exception\CanNotResolve
;
/**
* Class should resolve name by serching in provided dir. If empty then current dir
*
* @package WPDesk\View\Resolver
*/
class
DirResolver
implements
Resolver
{
/** @var string */
private
$dir
;
/**
* Base path for templates ie. subdir
*
* @param $template_base_path
*/
public
function
__construct
(
$dir
)
{
$this
->
dir
=
$dir
;
}
/**
* Resolve name to full path
*
* @param string $name
* @param Renderer|null $renderer
*
* @return string
*/
public
function
resolve
(
$name
,
Renderer
$renderer
=
null
)
{
$dir
=
rtrim
(
$this
->
dir
,
'/'
);
$fullName
=
$dir
.
'/'
.
$name
.
'.php'
;
if
(
file_exists
(
$fullName
))
{
return
$fullName
;
}
throw
new
CanNotResolve
(
"Cannot resolve
{
$name
}
"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment