Skip to content
Snippets Groups Projects
Commit ead0498f authored by dyszczo's avatar dyszczo
Browse files

remove php from resolvers. Only PHP renderer can add it

parent 5d140f3d
No related branches found
No related tags found
2 merge requests!8feat/woo template,!3Feature/implementation
Pipeline #5973 passed with stages
in 1 minute and 5 seconds
......@@ -29,7 +29,7 @@ class SimplePhpRenderer implements Renderer
/**
* @param string $template
* @param array $params
* @param array|null $params
*
* @return string
*/
......@@ -40,7 +40,7 @@ class SimplePhpRenderer implements Renderer
}
ob_start();
include($this->resolver->resolve($template));
include($this->resolver->resolve($template . '.php'));
return ob_get_clean();
}
......
......@@ -39,7 +39,7 @@ class DirResolver implements Resolver
public function resolve($name, Renderer $renderer = null)
{
$dir = rtrim($this->dir, '/');
$fullName = $dir . '/' . $name . '.php';
$fullName = $dir . '/' . $name;
if (file_exists($fullName)) {
return $fullName;
}
......
......@@ -40,7 +40,7 @@ class WPThemeResolver implements Resolver
{
$templateFile = locate_template(
[
trailingslashit($this->template_base_path) . $name . '.php',
trailingslashit($this->template_base_path) . $name,
]
);
if ( ! $templateFile) {
......
......@@ -28,7 +28,7 @@ class TestChainResolver extends \PHPUnit\Framework\TestCase
->andReturn(self::RESPONSE_OF_RESOLVER);
$resolver = new ChainResolver(new NullResolver(), new NullResolver(), $validResolver);
$this->assertEquals(self::RESPONSE_OF_RESOLVER, $resolver->resolve('whatever'));
$this->assertEquals(self::RESPONSE_OF_RESOLVER, $resolver->resolve('whatever.php'));
}
public function testUseFirstResolverFirst()
......@@ -39,7 +39,7 @@ class TestChainResolver extends \PHPUnit\Framework\TestCase
->andReturn(self::RESPONSE_OF_RESOLVER);
$resolver = new ChainResolver($validResolver, new NullResolver(), new NullResolver());
$this->assertEquals(self::RESPONSE_OF_RESOLVER, $resolver->resolve('whatever'));
$this->assertEquals(self::RESPONSE_OF_RESOLVER, $resolver->resolve('whatever.php'));
}
public function testThrowExceptionWhenBothCannotFind()
......
......@@ -5,7 +5,7 @@ use WPDesk\View\Resolver\Exception\CanNotResolve;
class TestDirResolver extends \PHPUnit\Framework\TestCase
{
const TEMPLATE_NAME = 'some_template';
const TEMPLATE_NAME = 'some_template.php';
const TEMPLATE_FILE = 'some_template.php';
const TEMPLATE_SUBDIR = 'templates';
......
......@@ -5,7 +5,7 @@ use WPDesk\View\Resolver\Exception\CanNotResolve;
class TestThemeResolver extends \PHPUnit\Framework\TestCase
{
const TEMPLATE_NAME = 'some_template';
const TEMPLATE_NAME = 'some_template.php';
const TEMPLATE_FILE = 'some_template.php';
const TEMPLATE_SUBDIR = 'templates';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment