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
Merge requests
!9
feat: add WooTemplateResolver
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
feat: add WooTemplateResolver
feat/woo-template
into
master
Overview
0
Commits
1
Pipelines
1
Changes
2
Merged
Bartek Jaskulski
requested to merge
feat/woo-template
into
master
1 year ago
Overview
0
Commits
1
Pipelines
1
Changes
2
Expand
Signed-off-by: Bart Jaskulski
bjaskulski@protonmail.com
👍
0
👎
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
c4d9b51b
1 commit,
1 year ago
2 files
+
41
−
1
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/Resolver/WooTemplateResolver.php
0 → 100644
+
35
−
0
Options
<?php
declare
(
strict_types
=
1
);
namespace
WPDesk\View\Resolver
;
use
WPDesk\View\Renderer\Renderer
;
use
WPDesk\View\Resolver\Exception\CanNotResolve
;
/**
* Locate templates, respecting WooCommerce template load order, prepending custom path to seek for templates. This supports user's template overrides by default.
*/
class
WooTemplateResolver
implements
Resolver
{
/** @var string */
private
$base_path
;
public
function
__construct
(
string
$base_path
)
{
if
(
!
function_exists
(
'wc_locate_template'
)
)
{
throw
new
\RuntimeException
(
sprintf
(
'The "%s" resolver needs the WooCommerce plugin. Make sure it is installed and active.'
,
__CLASS__
)
);
}
$this
->
base_path
=
$base_path
;
}
public
function
resolve
(
$name
,
Renderer
$renderer
=
null
):
string
{
$template
=
wc_locate_template
(
$name
,
''
,
$this
->
base_path
);
if
(
$template
===
''
)
{
throw
new
CanNotResolve
(
"Cannot resolve template
{
$name
}
"
);
}
return
$template
;
}
}
Loading