class Propel\PropelBundle\Model\Form\BaseAbstractType
This commit is contained in:
parent
6ce5c3a29e
commit
a7af5d92d9
61
Model/Form/BaseAbstractType.php
Normal file
61
Model/Form/BaseAbstractType.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Propel\PropelBundle\Model\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
abstract class BaseAbstractType extends AbstractType
|
||||
{
|
||||
private $options = array(
|
||||
'name' => '',
|
||||
);
|
||||
|
||||
function __construct($mergeOptions = null)
|
||||
{
|
||||
if ($mergeOptions) {
|
||||
$this->mergeOptions($mergeOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public function setOption($name, $value)
|
||||
{
|
||||
$this->options[$name] = $value;
|
||||
}
|
||||
|
||||
public function getOption($name)
|
||||
{
|
||||
return $this->options[$name];
|
||||
}
|
||||
|
||||
public function setOptions($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function mergeOptions($options)
|
||||
{
|
||||
$this->options = array_merge($this->options, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults($this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getOption('name');
|
||||
}
|
||||
}
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
namespace ##NAMESPACE##;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Propel\PropelBundle\Model\Form\BaseAbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
class ##CLASS## extends AbstractType
|
||||
{
|
||||
|
@ -13,41 +12,10 @@ class ##CLASS## extends AbstractType
|
|||
'name' => '##TYPE_NAME##',
|
||||
);
|
||||
|
||||
public function setOption($name, $value)
|
||||
{
|
||||
$this->options[$name] = $value;
|
||||
}
|
||||
|
||||
public function getOption($name)
|
||||
{
|
||||
return $this->options[$name];
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{##BUILD_CODE##
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults($this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getOption('name');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue