create first class form and adapt config for injecting form process in
Smarty
This commit is contained in:
@@ -21,6 +21,10 @@
|
|||||||
-->
|
-->
|
||||||
</templateDirectives>
|
</templateDirectives>
|
||||||
|
|
||||||
|
<forms>
|
||||||
|
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
|
||||||
|
</forms>
|
||||||
|
|
||||||
|
|
||||||
<commands>
|
<commands>
|
||||||
<command class="Thelia\Command\CacheClear"/>
|
<command class="Thelia\Command\CacheClear"/>
|
||||||
@@ -72,6 +76,15 @@
|
|||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service id="smart.plugin.form" class="Thelia\Core\Template\Smarty\Plugins\Form" scope="request">
|
||||||
|
<tag name="thelia.parser.register_plugin"/>
|
||||||
|
|
||||||
|
<argument type="service" id="request"/>
|
||||||
|
<call method="setFormDefinition">
|
||||||
|
<argument>%thelia.parser.forms%</argument>
|
||||||
|
</call>
|
||||||
|
</service>
|
||||||
|
|
||||||
<service id="smarty.plugin.translation" class="Thelia\Core\Template\Smarty\Plugins\Translation" >
|
<service id="smarty.plugin.translation" class="Thelia\Core\Template\Smarty\Plugins\Translation" >
|
||||||
<tag name="thelia.parser.register_plugin"/>
|
<tag name="thelia.parser.register_plugin"/>
|
||||||
</service>
|
</service>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Alias;
|
use Symfony\Component\DependencyInjection\Alias;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\DependencyInjection\SimpleXMLElement;
|
use Symfony\Component\DependencyInjection\SimpleXMLElement;
|
||||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||||
@@ -62,6 +63,8 @@ class XmlFileLoader extends FileLoader
|
|||||||
|
|
||||||
$this->parseCommands($xml);
|
$this->parseCommands($xml);
|
||||||
|
|
||||||
|
$this->parseForms($xml);
|
||||||
|
|
||||||
$this->parseDefinitions($xml, $path);
|
$this->parseDefinitions($xml, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$commandConfig = $this->container->getParameter("command.definition");
|
$commandConfig = $this->container->getParameter("command.definition");
|
||||||
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
|
} catch (ParameterNotFoundException $e) {
|
||||||
$commandConfig = array();
|
$commandConfig = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +113,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$loopConfig = $this->container->getParameter("Thelia.parser.loops");
|
$loopConfig = $this->container->getParameter("Thelia.parser.loops");
|
||||||
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
|
} catch (ParameterNotFoundException $e) {
|
||||||
$loopConfig = array();
|
$loopConfig = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +124,25 @@ class XmlFileLoader extends FileLoader
|
|||||||
$this->container->setParameter("Thelia.parser.loops", $loopConfig);
|
$this->container->setParameter("Thelia.parser.loops", $loopConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function parseForms(SimpleXMLElement $xml)
|
||||||
|
{
|
||||||
|
if (false === $forms = $xml->xpath('//config:forms/config:form')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$formConfig = $this->container->getParameter("Thelia.parser.forms");
|
||||||
|
} catch (ParameterNotFoundException $e) {
|
||||||
|
$formConfig = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($forms as $form) {
|
||||||
|
$formConfig[$form->getAttributeAsPhp('name')] = $formConfig->getAttributeAsPhp('class');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->container->setParameter('Thelia.parser.forms', $formConfig);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parse Filters property
|
* parse Filters property
|
||||||
*
|
*
|
||||||
@@ -133,7 +155,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$filterConfig = $this->container->getParameter("Thelia.parser.filters");
|
$filterConfig = $this->container->getParameter("Thelia.parser.filters");
|
||||||
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
|
} catch (ParameterNotFoundException $e) {
|
||||||
$filterConfig = array();
|
$filterConfig = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +178,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$baseParamConfig = $this->container->getParameter("Thelia.parser.templateDirectives");
|
$baseParamConfig = $this->container->getParameter("Thelia.parser.templateDirectives");
|
||||||
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
|
} catch (ParameterNotFoundException $e) {
|
||||||
$baseParamConfig = array();
|
$baseParamConfig = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
core/lib/Thelia/Form/CustomerCreation.php
Normal file
25
core/lib/Thelia/Form/CustomerCreation.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?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/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
class CustomerCreation {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user