Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 09d1543

Browse files
committed
Stop using deleted StaticContentType
1 parent 60b62b3 commit 09d1543

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

src/Admin/Content/StaticContentAdmin.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
use Sonata\AdminBundle\Datagrid\DatagridMapper;
1515
use Sonata\AdminBundle\Datagrid\ListMapper;
1616
use Sonata\AdminBundle\Form\FormMapper;
17-
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
18-
use Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\Form\Type\StaticContentType;
1917
use Symfony\Cmf\Bundle\ContentBundle\Model\StaticContentBase;
18+
use Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Admin\AbstractAdmin;
19+
use Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType;
20+
use Symfony\Component\Form\Extension\Core\Type\TextType;
21+
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
2022

21-
class StaticContentAdmin extends Admin
23+
class StaticContentAdmin extends AbstractAdmin
2224
{
2325
protected $translationDomain = 'CmfSonataPhpcrAdminIntegrationBundle';
2426

@@ -37,25 +39,31 @@ protected function configureListFields(ListMapper $listMapper)
3739

3840
protected function configureFormFields(FormMapper $formMapper)
3941
{
40-
$builder = $formMapper->getFormBuilder()->getFormFactory()->createBuilder(StaticContentType::class, null, [
41-
'readonly_parent_document' => (bool) $this->id($this->getSubject()),
42-
'label_format' => 'form.label_%name%',
43-
'translation_domain' => 'CmfSonataPhpcrAdminIntegrationBundle',
44-
]);
45-
42+
$editView = (bool) $this->id($this->getSubject());
4643
$formMapper
4744
->tab('form.tab_general')
4845
->with('form.group_content', ['class' => 'col-md-9'])
49-
->add($builder->get('title'))
50-
->add($builder->get('body'))
46+
->add('title', TextType::class)
47+
->add('body', TextareaType::class)
5148
->end()
5249

5350
->with('form.group_location', ['class' => 'col-md-3'])
54-
->add($builder->get('parentDocument'))
55-
->add($builder->get('name'))
51+
->ifTrue($editView)
52+
->add('parentDocument', TextType::class, ['disabled' => true])
53+
->ifEnd()
54+
->ifFalse($editView)
55+
->add('parentDocument', TreeSelectType::class, [
56+
'widget' => 'browser',
57+
'root_node' => $this->getRootPath(),
58+
])
59+
->ifend()
60+
61+
->add('name', TextType::class)
5662
->end()
5763
->end()
5864
;
65+
66+
$this->addTransformerToField($formMapper->getFormBuilder(), 'parentDocument');
5967
}
6068

6169
protected function configureDatagridFilters(DatagridMapper $datagridMapper)

src/Resources/config/content.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<services>
77
<service
88
id="cmf_sonata_phpcr_admin_integration.content.admin"
9-
class="Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Admin\Content\StaticContentAdmin">
9+
class="Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Admin\Content\StaticContentAdmin"
10+
parent="cmf_sonata_phpcr_admin_integration.abstract_admin">
1011
<tag
1112
name="sonata.admin"
1213
manager_type="doctrine_phpcr"

0 commit comments

Comments
 (0)