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

109 lines
2.5 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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',
'text'
);
$builder->add(
'position',
'hidden',
array(
'mapped' => false,
'data' => 'after',
)
);
$builder->add(
'pageContentType',
'choice',
array(
'mapped' => false,
'choices' => self::getPageContentTypes(),
'required' => false,
)
);
$builder->add(
'pageModel',
'choice',
array(
'mapped' => false,
'choices' => $this->getPagesModels(),
'required' => true,
)
);
$builder->add(
'page',
'model',
array(
'class' => 'Trinity\Bundle\ContentManagerBundle\Model\Page',
'query' => \Trinity\Bundle\ContentManagerBundle\Model\PageQuery::getOrphansQuery(),
'required' => false,
)
);
$builder->add(
'nodeAliasId',
'choice',
array(
'choices' => \Trinity\Bundle\ContentManagerBundle\Model\MenuPeer::getMenuWithNodesForType(),
'required' => true,
)
);
$builder->add(
'url',
'text',
array(
'required' => false,
'attr' => array(
'placeholder' => 'https://',
),
)
);
}
public static function getPositions()
{
return array(
'above' => 'Above',
'after' => 'After',
'before' => 'Before',
);
}
public static function getPageContentTypes()
{
return array(
'newpage' => 'New page',
'page' => 'Page',
'alias' => 'Alias',
'url' => 'URL',
'nopage' => 'No page',
);
}
public static function validatorPageContentTypes()
{
return array_keys(self::getPageContentTypes());
}
public static function validatorPositions()
{
return array_keys(self::getPositions());
}
}