80 lines
1.6 KiB
PHP
80 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This file is part of the PropelBundle package.
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*
|
|
* @license MIT License
|
|
*/
|
|
|
|
namespace Propel\Bundle\PropelBundle\Form;
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
|
|
|
/**
|
|
* @author William DURAND <william.durand1@gmail.com>
|
|
*/
|
|
abstract class BaseAbstractType extends AbstractType
|
|
{
|
|
protected $options = array(
|
|
'name' => '',
|
|
);
|
|
|
|
public 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 configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults($this->options);
|
|
}
|
|
|
|
// BC for SF < 2.7
|
|
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
|
{
|
|
$this->configureOptions($resolver);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->getOption('name');
|
|
}
|
|
}
|