This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
/
ContainerBlockAdmin.php
68 lines (58 loc) · 1.8 KB
/
ContainerBlockAdmin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Symfony\Cmf\Bundle\BlockBundle\Admin;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Symfony\Cmf\Bundle\BlockBundle\Document\ContainerBlock;
class ContainerBlockAdmin extends Admin
{
protected $translationDomain = 'SymfonyCmfBlockBundle';
/**
* Root path for the route content selection
* @var string
*/
protected $contentRoot;
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('id', 'text')
->add('name', 'text')
;
}
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('form.group_general')
->add('parentDocument', 'doctrine_phpcr_odm_tree', array('root_node' => $this->contentRoot, 'choice_list' => array(), 'select_root_node' => true))
->add('name', 'text')
->end()
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('name', 'doctrine_phpcr_nodename')
;
}
public function getNewInstance()
{
/** @var $new ContainerBlock */
$new = parent::getNewInstance();
if ($this->hasRequest()) {
$parentId = $this->getRequest()->query->get('parent');
if (null !== $parentId) {
$new->setParentDocument($this->getModelManager()->find(null, $parentId));
}
}
return $new;
}
public function setContentRoot($contentRoot)
{
$this->contentRoot = $contentRoot;
}
public function getExportFormats()
{
return array();
}
}