49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace Trinity\Bundle\ContentManagerBundle\Form\Type;
|
||
|
||
use Propel\PropelBundle\Form\BaseAbstractType;
|
||
use Symfony\Component\Form\FormBuilderInterface;
|
||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||
|
||
class PageType extends BaseAbstractType
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||
{
|
||
if (null !== $builder->getData()) {
|
||
foreach ($builder->getData()->getConfiguration()->getBlocks() as $blockConfiguration) {
|
||
$type = $blockConfiguration->getType();
|
||
|
||
$builder->add(
|
||
sprintf('block_%s', $blockConfiguration->getName()),
|
||
new $type(),
|
||
$blockConfiguration->getOptions()
|
||
);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||
{
|
||
$resolver->setDefaults(
|
||
array(
|
||
'data_class' => 'Trinity\Bundle\ContentManagerBundle\Model\Page',
|
||
)
|
||
);
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function getName()
|
||
{
|
||
return 'page';
|
||
}
|
||
}
|