Fixed injection of TaxManager in TaxCreationForm instance

This commit is contained in:
Franck Allimant
2014-01-23 09:33:09 +01:00
parent 9d1c1e3979
commit 54db55467b
6 changed files with 47 additions and 22 deletions

View File

@@ -50,7 +50,7 @@ class ParserContext implements \IteratorAggregate
*/
public function addForm(BaseForm $form)
{
$this->set($form->getName(), $form);
$this->set(get_class($form)/*$form->getName()*/, $form);
return $this;
}

View File

@@ -97,15 +97,25 @@ class Form extends AbstractSmartyPlugin
throw new \InvalidArgumentException("Missing 'name' parameter in form arguments");
}
$instance = $this->createInstance($name);
if (!isset($this->formDefinition[$name])) {
throw new ElementNotFoundException(sprintf("%s form does not exists", $name));
}
$formClass = $this->formDefinition[$name];
// Check if parser context contains our form
$form = $this->parserContext->getForm($instance->getName());
$form = $this->parserContext->getForm($formClass);
if (null != $form) {
// Re-use the form
$instance = $form;
}
else {
// Create a new one
$class = new \ReflectionClass($formClass);
$instance = $class->newInstance($this->request, "form");
}
$instance->createView();
@@ -406,17 +416,6 @@ class Form extends AbstractSmartyPlugin
return $instance;
}
protected function createInstance($name)
{
if (!isset($this->formDefinition[$name])) {
throw new ElementNotFoundException(sprintf("%s form does not exists", $name));
}
$class = new \ReflectionClass($this->formDefinition[$name]);
return $class->newInstance($this->request, "form");
}
/**
* @return an array of SmartyPluginDescriptor
*/

View File

@@ -87,7 +87,7 @@ class Thelia extends Kernel
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
if ($this->isDebug()) {
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
$con->useDebug(true);
//$con->useDebug(true);
}
}