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

Commit f3e14da

Browse files
authored
Merge pull request #79 from symfony-cmf/revert-staticcontenttype
Stop using the deleted StaticContentType
2 parents 60b62b3 + 7ab9de9 commit f3e14da

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: php
22

33
php:
4-
- 5.5
5-
- 5.6
64
- 7.0
75
- hhvm
86

@@ -17,13 +15,13 @@ env:
1715
matrix: SYMFONY_VERSION=3.1.*
1816
global:
1917
- SYMFONY_DEPRECATIONS_HELPER=2080
20-
- SYMFONY_PHPUNIT_DIR=".phpunit" SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
18+
- SYMFONY_PHPUNIT_DIR=".phpunit" SYMFONY_PHPUNIT_REMOVE="symfony/yaml" SYMFONY_PHPUNIT_VERSION=5.7
2119

2220
matrix:
2321
include:
2422
#- php: 7.0
2523
# env: DEPS=dev SYMFONY_VERSION=3.3.*
26-
- php: 5.5
24+
- php: 5.6
2725
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
2826
- php: 7.1
2927
env: SYMFONY_VERSION=3.0.*
@@ -44,4 +42,3 @@ script: vendor/bin/simple-phpunit
4442

4543
notifications:
4644
irc: "irc.freenode.org#symfony-cmf"
47-

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,23 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^5.5.6|^7.0",
15+
"php": "^5.6|^7.0",
1616
"symfony/framework-bundle": "^2.8|^3.0",
1717
"sonata-project/doctrine-phpcr-admin-bundle": "^2.0",
1818
"sonata-project/admin-bundle": "^3.6.0",
1919
"symfony-cmf/tree-browser-bundle": "^2.0"
2020
},
2121
"require-dev": {
2222
"symfony-cmf/testing": "^2.0",
23-
"symfony-cmf/core-bundle": "^2.0",
23+
"symfony-cmf/core-bundle": "^2.0.0-RC2",
2424
"symfony-cmf/routing-bundle": "^2.0",
2525
"symfony-cmf/seo-bundle": "^2.0",
2626
"symfony-cmf/menu-bundle": "^2.0",
2727
"symfony-cmf/block-bundle": "^2.0",
2828
"symfony-cmf/content-bundle": "^2.0",
2929
"doctrine/orm": "^2.4",
3030
"doctrine/phpcr-odm": "^2.0",
31+
"doctrine/doctrine-bundle": "^1.3",
3132
"symfony/phpunit-bridge": "^3.2",
3233
"matthiasnoback/symfony-dependency-injection-test": "~0.6",
3334
"matthiasnoback/symfony-config-test": "^1.3.1",

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"

tests/Unit/Admin/Core/Extension/ChildExtensionTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,19 @@ public function testAlterNewInstance()
1919
{
2020
$parent = new \StdClass();
2121

22-
$modelManager = $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface');
22+
$modelManager = $this->createMock('Sonata\AdminBundle\Model\ModelManagerInterface');
2323
$modelManager->expects($this->any())
2424
->method('find')
2525
->will($this->returnValue($parent))
2626
;
2727

28-
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
29-
->disableOriginalConstructor()
30-
->getMock()
31-
;
28+
$request = $this->createMock('Symfony\Component\HttpFoundation\Request');
3229
$request->expects($this->any())
3330
->method('get')
3431
->will($this->returnValue('parent-id'))
3532
;
3633

37-
$admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
34+
$admin = $this->createMock('Sonata\AdminBundle\Admin\AdminInterface');
3835
$admin->expects($this->any())
3936
->method('getModelManager')
4037
->will($this->returnValue($modelManager))
@@ -48,7 +45,7 @@ public function testAlterNewInstance()
4845
->will($this->returnValue($request))
4946
;
5047

51-
$child = $this->getMock('Symfony\Cmf\Bundle\CoreBundle\Model\ChildInterface');
48+
$child = $this->createMock('Symfony\Cmf\Bundle\CoreBundle\Model\ChildInterface');
5249
$child->expects($this->once())
5350
->method('setParentObject')
5451
->with($this->equalTo($parent));

0 commit comments

Comments
 (0)