deblan.tv/vendor/trinity/src/Trinity/Bundle/ContentManagerBundle/Form/Type/NodeAddType.php

109 lines
2.5 KiB
PHP
Raw Normal View History

2015-03-02 21:57:49 +01:00
<?php
namespace Trinity\Bundle\ContentManagerBundle\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;
class NodeAddType extends NodeType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'title',
2015-05-04 19:34:46 +02:00
'text'
2015-03-02 21:57:49 +01:00
);
$builder->add(
'position',
'hidden',
array(
2015-05-04 19:34:46 +02:00
'mapped' => false,
'data' => 'after',
2015-03-02 21:57:49 +01:00
)
);
$builder->add(
'pageContentType',
'choice',
array(
2015-05-04 19:34:46 +02:00
'mapped' => false,
'choices' => self::getPageContentTypes(),
'required' => false,
2015-03-02 21:57:49 +01:00
)
);
$builder->add(
'pageModel',
'choice',
array(
2015-05-04 19:34:46 +02:00
'mapped' => false,
'choices' => $this->getPagesModels(),
'required' => true,
2015-03-02 21:57:49 +01:00
)
);
$builder->add(
'page',
'model',
array(
2015-05-04 19:34:46 +02:00
'class' => 'Trinity\Bundle\ContentManagerBundle\Model\Page',
'query' => \Trinity\Bundle\ContentManagerBundle\Model\PageQuery::getOrphansQuery(),
2015-03-02 21:57:49 +01:00
'required' => false,
)
);
$builder->add(
'nodeAliasId',
'choice',
array(
2015-05-04 19:34:46 +02:00
'choices' => \Trinity\Bundle\ContentManagerBundle\Model\MenuPeer::getMenuWithNodesForType(),
2015-03-02 21:57:49 +01:00
'required' => true,
)
);
$builder->add(
'url',
'text',
array(
'required' => false,
'attr' => array(
2015-05-04 19:34:46 +02:00
'placeholder' => 'https://',
2015-03-02 21:57:49 +01:00
),
)
);
}
public static function getPositions()
{
return array(
'above' => 'Above',
'after' => 'After',
'before' => 'Before',
);
}
public static function getPageContentTypes()
{
return array(
'newpage' => 'New page',
2015-05-04 19:34:46 +02:00
'page' => 'Page',
'alias' => 'Alias',
'url' => 'URL',
'nopage' => 'No page',
2015-03-02 21:57:49 +01:00
);
}
public static function validatorPageContentTypes()
{
return array_keys(self::getPageContentTypes());
}
public static function validatorPositions()
{
return array_keys(self::getPositions());
}
}