fix CS and add start Form plugin for smarty

This commit is contained in:
Manuel Raynaud
2013-06-24 10:21:59 +02:00
parent fc00bc9044
commit 2edc71e9c3
32 changed files with 436 additions and 388 deletions

View File

@@ -29,7 +29,6 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\KernelInterface;
class Application extends BaseApplication class Application extends BaseApplication
{ {
@@ -68,8 +67,7 @@ class Application extends BaseApplication
$container = $this->kernel->getContainer(); $container = $this->kernel->getContainer();
foreach($container->getParameter("command.definition") as $command) foreach ($container->getParameter("command.definition") as $command) {
{
$r = new \ReflectionClass($command); $r = new \ReflectionClass($command);
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) { if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) {
@@ -77,6 +75,5 @@ class Application extends BaseApplication
} }
} }
} }
} }

View File

@@ -24,7 +24,6 @@ namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Scope; use Symfony\Component\DependencyInjection\Scope;
use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass; use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass;

View File

@@ -1,6 +1,5 @@
<?php <?php
namespace Thelia\Core\Controller; namespace Thelia\Core\Controller;
use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver; use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver;

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\DependencyInjection\Compiler; namespace Thelia\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
@@ -34,8 +33,8 @@ use Symfony\Component\DependencyInjection\Reference;
* *
* *
*/ */
class RegisterParserPluginPass implements CompilerPassInterface { class RegisterParserPluginPass implements CompilerPassInterface
{
/** /**
* You can modify the container here before it is dumped to PHP code. * You can modify the container here before it is dumped to PHP code.
* *

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\DependencyInjection\Loader; namespace Thelia\Core\DependencyInjection\Loader;
use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader as XmlLoader;
use Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\Config\Util\XmlUtils;
use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;

View File

@@ -15,6 +15,7 @@
<xsd:element name="services" type="services" /> <xsd:element name="services" type="services" />
<xsd:element name="parameters" type="parameters"/> <xsd:element name="parameters" type="parameters"/>
<xsd:element name="commands" type="commands"/> <xsd:element name="commands" type="commands"/>
<xsd:element name="forms" type="forms" />
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
@@ -74,6 +75,17 @@
<xsd:attribute name="class" type="xsd:string" use="required" /> <xsd:attribute name="class" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="forms">
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="form" type="form" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="form">
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="class" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="filters"> <xsd:complexType name="filters">
<xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="filter" type="filter" /> <xsd:element name="filter" type="filter" />

View File

@@ -52,7 +52,8 @@ abstract class ActionEvent extends Event
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\HttpFoundation\Request $request
* @param string $action * @param string $action
*/ */
public function __construct(Request $request, $action) { public function __construct(Request $request, $action)
{
$this->request = $request; $this->request = $request;
$this->action = $action; $this->action = $action;
} }

View File

@@ -11,6 +11,6 @@ namespace Thelia\Core\Event;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
class DefaultActionEvent extends ActionEvent { class DefaultActionEvent extends ActionEvent
{
} }

View File

@@ -25,10 +25,8 @@ namespace Thelia\Core\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Factory\ActionEventFactory; use Thelia\Core\Factory\ActionEventFactory;
/** /**
* *
* Action are dispatch here. * Action are dispatch here.
@@ -41,7 +39,6 @@ use Thelia\Core\Factory\ActionEventFactory;
class ControllerListener implements EventSubscriberInterface class ControllerListener implements EventSubscriberInterface
{ {
public function onKernelController(FilterControllerEvent $event) public function onKernelController(FilterControllerEvent $event)
{ {
$dispatcher = $event->getDispatcher(); $dispatcher = $event->getDispatcher();

View File

@@ -78,7 +78,7 @@ class ViewListener implements EventSubscriberInterface
} else { } else {
$event->setResponse(new Response($content, $parser->getStatus() ?: 200)); $event->setResponse(new Response($content, $parser->getStatus() ?: 200));
} }
} catch(ResourceNotFoundException $e) { } catch (ResourceNotFoundException $e) {
$event->setResponse(new Response($e->getMessage(), 404)); $event->setResponse(new Response($e->getMessage(), 404));
} }

View File

@@ -24,8 +24,6 @@
namespace Thelia\Core\Factory; namespace Thelia\Core\Factory;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\ActionEventClass;
class ActionEventFactory class ActionEventFactory
{ {

View File

@@ -37,8 +37,8 @@ use Assetic\Cache\FilesystemCache;
* *
* @author Franck Allimant <franck@cqfdev.fr> * @author Franck Allimant <franck@cqfdev.fr>
*/ */
class AsseticHelper { class AsseticHelper
{
/** /**
* Generates assets from $asset_path in $output_path, using $filters. * Generates assets from $asset_path in $output_path, using $filters.
* *
@@ -51,8 +51,8 @@ class AsseticHelper {
* @throws \InvalidArgumentException if an invalid filter name is found * @throws \InvalidArgumentException if an invalid filter name is found
* @return string The URL to the generated asset file. * @return string The URL to the generated asset file.
*/ */
public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug) { public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug)
{
$asset_name = basename($asset_path); $asset_name = basename($asset_path);
$asset_dir = dirname($asset_path); $asset_dir = dirname($asset_path);
@@ -62,11 +62,11 @@ class AsseticHelper {
if (! empty($filters)) { if (! empty($filters)) {
$filter_list = explode(',', $filters); $filter_list = explode(',', $filters);
foreach($filter_list as $filter_name) { foreach ($filter_list as $filter_name) {
$filter_name = trim($filter_name); $filter_name = trim($filter_name);
switch($filter_name) { switch ($filter_name) {
case 'less' : case 'less' :
$fm->set('less', new Filter\LessphpFilter()); $fm->set('less', new Filter\LessphpFilter());
break; break;
@@ -92,8 +92,7 @@ class AsseticHelper {
break; break;
} }
} }
} } else {
else {
$filter_list = array(); $filter_list = array();
} }

View File

@@ -37,4 +37,3 @@ class Secure extends BaseParam
} }
} }
} }

View File

@@ -23,9 +23,8 @@
namespace Thelia\Core\Template\Element; namespace Thelia\Core\Template\Element;
class LoopResultRow
class LoopResultRow { {
protected $substitution = array(); protected $substitution = array();
public function set($key, $value) public function set($key, $value)

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Template\Exception; namespace Thelia\Core\Template\Exception;
class ResourceNotFoundException extends \RuntimeException
class ResourceNotFoundException extends \RuntimeException { {
} }

View File

@@ -21,14 +21,11 @@
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
/** /**
@@ -61,8 +58,8 @@ use Thelia\Model\CategoryQuery;
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class Category extends BaseLoop { class Category extends BaseLoop
{
public $id; public $id;
public $parent; public $parent;
public $current; public $current;
@@ -105,13 +102,13 @@ class Category extends BaseLoop {
$search->filterById(explode(',', $this->id), \Criteria::IN); $search->filterById(explode(',', $this->id), \Criteria::IN);
} }
if(!is_null($this->parent)) { if (!is_null($this->parent)) {
$search->filterByParent($this->parent); $search->filterByParent($this->parent);
} }
if($this->current == 1) { if ($this->current == 1) {
$search->filterById($this->request->get("category_id")); $search->filterById($this->request->get("category_id"));
} else if (null !== $this->current && $this->current == 0) { } elseif (null !== $this->current && $this->current == 0) {
$search->filterById($this->request->get("category_id"), \Criteria::NOT_IN); $search->filterById($this->request->get("category_id"), \Criteria::NOT_IN);
} }
@@ -123,14 +120,13 @@ class Category extends BaseLoop {
$search->filterByLink($this->link); $search->filterByLink($this->link);
} }
if($this->limit > -1) { if ($this->limit > -1) {
$search->limit($this->limit); $search->limit($this->limit);
} }
$search->filterByVisible($this->visible); $search->filterByVisible($this->visible);
$search->offset($this->offset); $search->offset($this->offset);
switch ($this->order) {
switch($this->order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE); $search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE);
break; break;
@@ -145,7 +141,7 @@ class Category extends BaseLoop {
break; break;
} }
if($this->random == 1) { if ($this->random == 1) {
$search->clearOrderByColumns(); $search->clearOrderByColumns();
$search->addAscendingOrderByColumn('RAND()'); $search->addAscendingOrderByColumn('RAND()');
} }

View File

@@ -25,8 +25,8 @@ namespace Thelia\Core\Template\Smarty\Assets;
use Thelia\Core\Template\Assets\AsseticHelper; use Thelia\Core\Template\Assets\AsseticHelper;
class SmartyAssetsManager { class SmartyAssetsManager
{
const ASSET_TYPE_AUTO = ''; const ASSET_TYPE_AUTO = '';
private $assetic_manager; private $assetic_manager;
@@ -40,16 +40,16 @@ class SmartyAssetsManager {
* @param string $web_root the disk path to the web root * @param string $web_root the disk path to the web root
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
*/ */
public function __construct($web_root, $path_relative_to_web_root) { public function __construct($web_root, $path_relative_to_web_root)
{
$this->web_root = $web_root; $this->web_root = $web_root;
$this->path_relative_to_web_root = $path_relative_to_web_root; $this->path_relative_to_web_root = $path_relative_to_web_root;
$this->assetic_manager = new AsseticHelper(); $this->assetic_manager = new AsseticHelper();
} }
public function processSmartyPluginCall($assetType, $params, $content, \Smarty_Internal_Template $template, &$repeat) { public function processSmartyPluginCall($assetType, $params, $content, \Smarty_Internal_Template $template, &$repeat)
{
// Opening tag (first call only) // Opening tag (first call only)
if ($repeat) { if ($repeat) {
$file = $params['file']; $file = $params['file'];
@@ -78,8 +78,7 @@ class SmartyAssetsManager {
); );
$template->assign('asset_url', $url); $template->assign('asset_url', $url);
} } elseif (isset($content)) {
else if (isset($content)) {
return $content; return $content;
} }
} }

View File

@@ -23,14 +23,12 @@
namespace Thelia\Core\Template\Smarty\Plugins; namespace Thelia\Core\Template\Smarty\Plugins;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface; use Thelia\Core\Template\Smarty\SmartyPluginInterface;
use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager; use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager;
class Assetic implements SmartyPluginInterface
class Assetic implements SmartyPluginInterface { {
public $asset_manager; public $asset_manager;
public function __construct() public function __construct()
@@ -42,7 +40,6 @@ class Assetic implements SmartyPluginInterface {
$this->asset_manager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root); $this->asset_manager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root);
} }
public function theliaBlockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat) public function theliaBlockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat)
{ {
return $this->asset_manager->processSmartyPluginCall('js', $params, $content, $template, $repeat); return $this->asset_manager->processSmartyPluginCall('js', $params, $content, $template, $repeat);

View File

@@ -0,0 +1,66 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Smarty\Plugins;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
class Form implements SmartyPluginInterface
{
protected $request;
protected $formDefinition = array();
public function __construct(Request $request)
{
$this->request = $request;
}
public function setFormDefinition($formDefinition)
{
foreach ($formDefinition as $name => $className) {
if (array_key_exists($name, $this->formDefinition)) {
throw new \InvalidArgumentException(sprintf("%s form name already exists for %s class", $name,
$className));
}
$this->formDefinition[$name] = $className;
}
}
public function generateForm($params, $content, $template, &$repeat)
{
}
/**
* @return an array of SmartyPluginDescriptor
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor("block", "form", $this, "generateForm")
);
}
}

View File

@@ -23,12 +23,11 @@
namespace Thelia\Core\Template\Smarty\Plugins; namespace Thelia\Core\Template\Smarty\Plugins;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface; use Thelia\Core\Template\Smarty\SmartyPluginInterface;
class Module implements SmartyPluginInterface { class Module implements SmartyPluginInterface
{
/** /**
* Process theliaModule template inclusion function * Process theliaModule template inclusion function
* *

View File

@@ -32,15 +32,16 @@ use Thelia\Core\Template\Element\Exception\InvalidElementException;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class TheliaLoop implements SmartyPluginInterface { class TheliaLoop implements SmartyPluginInterface
{
protected $loopDefinition = array(); protected $loopDefinition = array();
protected $request; protected $request;
protected $dispatcher; protected $dispatcher;
public function __construct(Request $request, EventDispatcherInterface $dispatcher) { public function __construct(Request $request, EventDispatcherInterface $dispatcher)
{
$this->request = $request; $this->request = $request;
$this->dispatcher = $dispatcher; $this->dispatcher = $dispatcher;
} }
@@ -55,8 +56,8 @@ class TheliaLoop implements SmartyPluginInterface {
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return string * @return string
*/ */
public function theliaLoop($params, $content, $template, &$repeat) { public function theliaLoop($params, $content, $template, &$repeat)
{
if (empty($params['name'])) if (empty($params['name']))
throw new \InvalidArgumentException("Missing 'name' parameter in loop arguments"); throw new \InvalidArgumentException("Missing 'name' parameter in loop arguments");
@@ -74,8 +75,7 @@ class TheliaLoop implements SmartyPluginInterface {
$loopResults = $loop->exec(); $loopResults = $loop->exec();
$template->assignByRef($name, $loopResults); $template->assignByRef($name, $loopResults);
} } else {
else {
$loopResults = $template->getTemplateVars($name); $loopResults = $template->getTemplateVars($name);
@@ -86,7 +86,7 @@ class TheliaLoop implements SmartyPluginInterface {
$loopResultRow = $loopResults->current(); $loopResultRow = $loopResults->current();
foreach($loopResultRow->getVarVal() as $var => $val) { foreach ($loopResultRow->getVarVal() as $var => $val) {
$template->assign(substr($var, 1), $val); $template->assign(substr($var, 1), $val);
@@ -100,12 +100,10 @@ class TheliaLoop implements SmartyPluginInterface {
if ($content !== null) { if ($content !== null) {
if ($loopResults->isEmpty()) $content = ""; if ($loopResults->isEmpty()) $content = "";
return $content; return $content;
} }
} }
/** /**
* Process {elseloop rel="loopname"} ... {/elseloop} block * Process {elseloop rel="loopname"} ... {/elseloop} block
* *
@@ -115,15 +113,14 @@ class TheliaLoop implements SmartyPluginInterface {
* @param unknown $repeat * @param unknown $repeat
* @return Ambigous <string, unknown> * @return Ambigous <string, unknown>
*/ */
public function theliaElseloop($params, $content, $template, &$repeat) { public function theliaElseloop($params, $content, $template, &$repeat)
{
// When encoutering close tag, check if loop has results. // When encoutering close tag, check if loop has results.
if ($repeat === false) { if ($repeat === false) {
return $this->checkEmptyLoop($params, $template) ? $content : ''; return $this->checkEmptyLoop($params, $template) ? $content : '';
} }
} }
/** /**
* Process {ifloop rel="loopname"} ... {/ifloop} block * Process {ifloop rel="loopname"} ... {/ifloop} block
* *
@@ -133,8 +130,8 @@ class TheliaLoop implements SmartyPluginInterface {
* @param unknown $repeat * @param unknown $repeat
* @return Ambigous <string, unknown> * @return Ambigous <string, unknown>
*/ */
public function theliaIfLoop($params, $content, $template, &$repeat) { public function theliaIfLoop($params, $content, $template, &$repeat)
{
// When encountering close tag, check if loop has results. // When encountering close tag, check if loop has results.
if ($repeat === false) { if ($repeat === false) {
return $this->checkEmptyLoop($params, $template) ? '' : $content; return $this->checkEmptyLoop($params, $template) ? '' : $content;
@@ -149,7 +146,8 @@ class TheliaLoop implements SmartyPluginInterface {
* @param unknown $template * @param unknown $template
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
protected function checkEmptyLoop($params, $template) { protected function checkEmptyLoop($params, $template)
{
if (empty($params['rel'])) if (empty($params['rel']))
throw new \InvalidArgumentException("Missing 'rel' parameter in ifloop/elseloop arguments"); throw new \InvalidArgumentException("Missing 'rel' parameter in ifloop/elseloop arguments");
@@ -194,7 +192,6 @@ class TheliaLoop implements SmartyPluginInterface {
); );
} }
/** /**
* Returns the value of a loop argument. * Returns the value of a loop argument.
* *
@@ -212,27 +209,26 @@ class TheliaLoop implements SmartyPluginInterface {
$faultActor = array(); $faultActor = array();
$faultDetails = array(); $faultDetails = array();
foreach($loop->defineArgs() as $name => $param){ foreach ($loop->defineArgs() as $name => $param) {
if(is_integer($name)){ if (is_integer($name)) {
$name = $param; $name = $param;
$param = $defaultItemsParams; $param = $defaultItemsParams;
} }
if(is_string($param) && array_key_exists($param, $shortcutItemParams)){ if (is_string($param) && array_key_exists($param, $shortcutItemParams)) {
$param = $shortcutItemParams[$param]; $param = $shortcutItemParams[$param];
} }
if(!is_array($param)){ if (!is_array($param)) {
$param = array('default' => $param); $param = array('default' => $param);
} }
$value = isset($smartyParam[$name]) ? $smartyParam[$name] : null; $value = isset($smartyParam[$name]) ? $smartyParam[$name] : null;
if($value == null){ if ($value == null) {
if(isset($param['default'])){ if (isset($param['default'])) {
$value = $param['default']; $value = $param['default'];
} } elseif ($param['required'] === true) {
else if($param['required'] === true){
$faultActor[] = $name; $faultActor[] = $name;
$faultDetails[] = sprintf('"%s" parameter is missing', $name); $faultDetails[] = sprintf('"%s" parameter is missing', $name);
continue; continue;
@@ -242,7 +238,7 @@ class TheliaLoop implements SmartyPluginInterface {
$loop->{$name} = $value; $loop->{$name} = $value;
} }
if(!empty($faultActor)){ if (!empty($faultActor)) {
$complement = sprintf('[%s]', implode(', ', $faultDetails)); $complement = sprintf('[%s]', implode(', ', $faultDetails));
throw new \InvalidArgumentException($complement); throw new \InvalidArgumentException($complement);

View File

@@ -23,13 +23,11 @@
namespace Thelia\Core\Template\Smarty\Plugins; namespace Thelia\Core\Template\Smarty\Plugins;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface; use Thelia\Core\Template\Smarty\SmartyPluginInterface;
class Translation implements SmartyPluginInterface { class Translation implements SmartyPluginInterface
{
/** /**
* Process translate function * Process translate function
* *
@@ -41,13 +39,11 @@ class Translation implements SmartyPluginInterface {
{ {
if (isset($params['l'])) { if (isset($params['l'])) {
$string = str_replace('\'', '\\\'', $params['l']); $string = str_replace('\'', '\\\'', $params['l']);
} } else {
else {
$string = ''; $string = '';
} }
// TODO // TODO
return "[$string]"; return "[$string]";
} }

View File

@@ -8,18 +8,16 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface;
use \Smarty; use \Smarty;
use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Template\Loop\Category;
use Thelia\Core\Template\Smarty\SmartyPluginInterface; use Thelia\Core\Template\Smarty\SmartyPluginInterface;
use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager;
use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\Exception\ResourceNotFoundException;
/** /**
* *
* @author Franck Allimant <franck@cqfdev.fr> * @author Franck Allimant <franck@cqfdev.fr>
*/ */
class SmartyParser extends Smarty implements ParserInterface { class SmartyParser extends Smarty implements ParserInterface
{
public $plugins = array(); public $plugins = array();
protected $request, $dispatcher; protected $request, $dispatcher;
@@ -68,14 +66,15 @@ class SmartyParser extends Smarty implements ParserInterface {
$this->status = 200; $this->status = 200;
} }
public function setTemplate($template_path_from_template_base) { public function setTemplate($template_path_from_template_base)
{
$this->template = $template_path_from_template_base; $this->template = $template_path_from_template_base;
$this->setTemplateDir(THELIA_TEMPLATE_DIR.$this->template); $this->setTemplateDir(THELIA_TEMPLATE_DIR.$this->template);
} }
public function getTemplate() { public function getTemplate()
{
return $this->template; return $this->template;
} }
@@ -86,8 +85,8 @@ class SmartyParser extends Smarty implements ParserInterface {
* @param array $parameters an associative array of names / value pairs * @param array $parameters an associative array of names / value pairs
* @return string the rendered template text * @return string the rendered template text
*/ */
public function render($realTemplateName, array $parameters) { public function render($realTemplateName, array $parameters)
{
$this->assign($parameters); $this->assign($parameters);
return $this->fetch($realTemplateName); return $this->fetch($realTemplateName);
@@ -144,7 +143,7 @@ class SmartyParser extends Smarty implements ParserInterface {
foreach ($this->plugins as $register_plugin) { foreach ($this->plugins as $register_plugin) {
$plugins = $register_plugin->getPluginDescriptors(); $plugins = $register_plugin->getPluginDescriptors();
if(!is_array($plugins)) { if (!is_array($plugins)) {
$plugins = array($plugins); $plugins = array($plugins);
} }

View File

@@ -29,8 +29,8 @@ namespace Thelia\Core\Template\Smarty;
* Class SmartyPluginDescriptor * Class SmartyPluginDescriptor
* @package Thelia\Core\Template\Smarty * @package Thelia\Core\Template\Smarty
*/ */
class SmartyPluginDescriptor { class SmartyPluginDescriptor
{
/** /**
* @var string Smarty plugin type (block, function, etc.) * @var string Smarty plugin type (block, function, etc.)
*/ */
@@ -59,35 +59,43 @@ class SmartyPluginDescriptor {
$this->method = $method; $this->method = $method;
} }
public function setType($type) { public function setType($type)
{
$this->type = $type; $this->type = $type;
} }
public function getType() { public function getType()
{
return $this->type; return $this->type;
} }
public function setName($name) { public function setName($name)
{
$this->name = $name; $this->name = $name;
} }
public function getName() { public function getName()
{
return $this->name; return $this->name;
} }
public function setClass($class) { public function setClass($class)
{
$this->class = $class; $this->class = $class;
} }
public function getClass() { public function getClass()
{
return $this->class; return $this->class;
} }
public function setMethod($method) { public function setMethod($method)
{
$this->method = $method; $this->method = $method;
} }
public function getMethod() { public function getMethod()
{
return $this->method; return $this->method;
} }
} }

View File

@@ -30,7 +30,8 @@ namespace Thelia\Core\Template\Smarty;
* Interface SmartyPluginInterface * Interface SmartyPluginInterface
* @package Thelia\Core\Template\Smarty * @package Thelia\Core\Template\Smarty
*/ */
interface SmartyPluginInterface { interface SmartyPluginInterface
{
/** /**
* @return an array of SmartyPluginDescriptor * @return an array of SmartyPluginDescriptor
*/ */

View File

@@ -35,14 +35,9 @@ namespace Thelia\Core;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\Util\XmlUtils;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Thelia\Core\Bundle; use Thelia\Core\Bundle;
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
use Thelia\Config\DatabaseConfiguration; use Thelia\Config\DatabaseConfiguration;
@@ -64,7 +59,7 @@ class Thelia extends Kernel
public function init() public function init()
{ {
parent::init(); parent::init();
if($this->debug) { if ($this->debug) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
} }
$this->initPropel(); $this->initPropel();
@@ -76,7 +71,7 @@ class Thelia extends Kernel
return ; return ;
} }
if(! Propel::isInit()) { if (! Propel::isInit()) {
$definePropel = new DefinePropel(new DatabaseConfiguration(), $definePropel = new DefinePropel(new DatabaseConfiguration(),
Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); Yaml::parse(THELIA_ROOT . '/local/config/database.yml'));
@@ -126,8 +121,7 @@ class Thelia extends Kernel
try { try {
$loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/Config")); $loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/Config"));
$loader->load("config.xml"); $loader->load("config.xml");
} } catch (\InvalidArgumentException $e) {
catch(\InvalidArgumentException $e) {
// FIXME: process module configuration exception // FIXME: process module configuration exception
} }
} }
@@ -166,6 +160,7 @@ class Thelia extends Kernel
$this->loadConfiguration($container); $this->loadConfiguration($container);
$container->customCompile(); $container->customCompile();
return $container; return $container;
} }

View File

@@ -141,7 +141,6 @@ class TheliaHttpKernel extends HttpKernel
$storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config"))); $storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
} }
$session = new Session\Session($storage); $session = new Session\Session($storage);
$session->start(); $session->start();