From c745dd7ddef4716daeb1e24bbadf88ba8c05705e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 21 Jun 2013 10:39:32 +0200 Subject: [PATCH 1/4] add some phpdoc in smarty part --- .../Thelia/Core/Template/Smarty/SmartyPluginDescriptor.php | 6 ++++++ .../Thelia/Core/Template/Smarty/SmartyPluginInterface.php | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyPluginDescriptor.php b/core/lib/Thelia/Core/Template/Smarty/SmartyPluginDescriptor.php index 3e8fec8ad..6d598b0ce 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyPluginDescriptor.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyPluginDescriptor.php @@ -23,6 +23,12 @@ namespace Thelia\Core\Template\Smarty; +/** + * Class allowing to describe a smarty plugin + * + * Class SmartyPluginDescriptor + * @package Thelia\Core\Template\Smarty + */ class SmartyPluginDescriptor { /** diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyPluginInterface.php b/core/lib/Thelia/Core/Template/Smarty/SmartyPluginInterface.php index 87705c467..afbc7741f 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyPluginInterface.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyPluginInterface.php @@ -23,6 +23,13 @@ namespace Thelia\Core\Template\Smarty; +/** + * + * this interface must be implements when you want to add plugin to smarty using config process + * + * Interface SmartyPluginInterface + * @package Thelia\Core\Template\Smarty + */ interface SmartyPluginInterface { /** * @return an array of SmartyPluginDescriptor From 3473e48a3f4222bdf8235842eb2a2e918c2e09cb Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 21 Jun 2013 10:42:34 +0200 Subject: [PATCH 2/4] change thrown Exception if template not foud by a RuntimeException --- core/lib/Thelia/Core/Template/Smarty/SmartyParser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index e85f53284..387d0a820 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -31,6 +31,7 @@ class SmartyParser extends Smarty implements ParserInterface { * @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher * @param bool $template + * @param string $env Environment define for the kernel application. Used for the cache directory */ public function __construct(Request $request, EventDispatcherInterface $dispatcher, $template = false, $env = "prod") { @@ -165,6 +166,6 @@ class SmartyParser extends Smarty implements ParserInterface { if (file_exists($fileName)) return $fileName; - throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template)); + throw new \RuntimeException(sprintf("%s file not found in %s template", $file, $this->template)); } } \ No newline at end of file From e801717f0db2a5457cdf8499a6cc268ac712b49a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 21 Jun 2013 10:48:57 +0200 Subject: [PATCH 3/4] allow to activate debugging into Smarty --- core/lib/Thelia/Config/Resources/config.xml | 1 + core/lib/Thelia/Core/Template/Smarty/SmartyParser.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index a09cc086c..710cfabfd 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -53,6 +53,7 @@ false %kernel.environment% + %kernel.debug% diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 387d0a820..8e2497fbc 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -33,7 +33,7 @@ class SmartyParser extends Smarty implements ParserInterface { * @param bool $template * @param string $env Environment define for the kernel application. Used for the cache directory */ - public function __construct(Request $request, EventDispatcherInterface $dispatcher, $template = false, $env = "prod") + public function __construct(Request $request, EventDispatcherInterface $dispatcher, $template = false, $env = "prod", $debug = false) { parent::__construct(); @@ -53,6 +53,8 @@ class SmartyParser extends Smarty implements ParserInterface { $this->setCompileDir($compile_dir); $this->setCacheDir($cache_dir); + $this->debugging = $debug; + // Prevent smarty ErrorException: Notice: Undefined index bla bla bla... $this->error_reporting = E_ALL ^ E_NOTICE; From c246d33a1ed527011b77182f43b00b26ddce6d7f Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 21 Jun 2013 11:14:27 +0200 Subject: [PATCH 4/4] redefine ResourceNotFounsException into Template namespace --- .../Core/EventListener/ViewListener.php | 2 +- .../Exception/ResourceNotFoundException.php | 28 +++++++++++++++++++ .../Core/Template/Smarty/SmartyParser.php | 3 +- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 2b008dd17..894428760 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -28,7 +28,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserInterface; /** diff --git a/core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php b/core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php new file mode 100644 index 000000000..c3d627123 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Core\Template\Exception; + + +class ResourceNotFoundException extends \RuntimeException { + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 8e2497fbc..8f0763f3f 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -12,6 +12,7 @@ use Thelia\Core\Template\Loop\Category; use Thelia\Core\Template\Smarty\SmartyPluginInterface; use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager; +use Thelia\Core\Template\Exception\ResourceNotFoundException; /** * @@ -168,6 +169,6 @@ class SmartyParser extends Smarty implements ParserInterface { if (file_exists($fileName)) return $fileName; - throw new \RuntimeException(sprintf("%s file not found in %s template", $file, $this->template)); + throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template)); } } \ No newline at end of file