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

Commit f9358ee

Browse files
committed
Added initial Symfony 3 support
1 parent 674de3b commit f9358ee

File tree

12 files changed

+78
-46
lines changed

12 files changed

+78
-46
lines changed

.travis.yml

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

33
php:
4-
- 5.3
5-
- 5.4
64
- 5.5
75
- 5.6
86
- 7.0
@@ -15,18 +13,17 @@ cache:
1513
- $HOME/.composer/cache/files
1614

1715
env:
18-
global: SYMFONY_DEPRECATIONS_HELPER=533
16+
matrix: SYMFONY_VERSION=2.8.*
17+
global: SYMFONY_DEPRECATIONS_HELPER=321
1918

2019
matrix:
2120
include:
21+
- php: 7.0
22+
env: DEPS=dev SYMFONY_VERSION=3.1.*
23+
- php: 5.5
24+
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
2225
- php: 5.6
23-
env: DEPS=dev SYMFONY_VERSION=2.8.*
24-
- php: 5.3
25-
env: SYMFONY_VERSION="^2.3.4" COMPOSER_FLAGS="--prefer-lowest"
26-
- php: 5.6
27-
env: SYMFONY_VERSION=2.3.*
28-
- php: 5.6
29-
env: SYMFONY_VERSION=2.7.*
26+
env: DEPS=dev COMPOSER_FLAGS="--prefer-stable" SYMFONY_VERSION=3.0.*
3027
fast_finish: true
3128

3229
before_install:

Admin/AbstractMenuNodeAdmin.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Sonata\AdminBundle\Form\FormMapper;
1616
use Sonata\AdminBundle\Show\ShowMapper;
1717
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
18+
use Symfony\Component\Form\Extension\Core\Type\TextType;
1819
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeBase;
1920

2021
/**
@@ -52,8 +53,8 @@ protected function configureFormFields(FormMapper $formMapper)
5253
{
5354
$formMapper
5455
->with('form.group_general')
55-
->add('name', 'text')
56-
->add('label', 'text')
56+
->add('name', TextType::class)
57+
->add('label', TextType::class)
5758
->end()
5859
;
5960
}

Admin/MenuAdmin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Cmf\Bundle\MenuBundle\Admin;
1313

1414
use Sonata\AdminBundle\Form\FormMapper;
15+
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeManagerType;
1516
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu;
1617

1718
class MenuAdmin extends AbstractMenuNodeAdmin
@@ -29,7 +30,7 @@ protected function configureFormFields(FormMapper $formMapper)
2930
if (!$isNew) {
3031
$formMapper
3132
->with('form.group_items', array())
32-
->add('children', 'doctrine_phpcr_odm_tree_manager', array(
33+
->add('children', TreeManagerType::class, array(
3334
'root' => $this->menuRoot,
3435
'edit_in_overlay' => false,
3536
'create_in_overlay' => false,

Admin/MenuNodeAdmin.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
namespace Symfony\Cmf\Bundle\MenuBundle\Admin;
1313

14+
use Symfony\Component\Form\Extension\Core\Type\TextType;
1415
use Symfony\Component\Form\FormEvent;
1516
use Symfony\Component\Form\FormEvents;
17+
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode;
1618
use Sonata\AdminBundle\Datagrid\ListMapper;
1719
use Sonata\AdminBundle\Form\FormMapper;
18-
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode;
20+
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\ChoiceFieldMaskType;
21+
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeModelType;
1922
use Knp\Menu\ItemInterface as MenuItemInterface;
2023
use Doctrine\Common\Util\ClassUtils;
2124

@@ -40,7 +43,7 @@ protected function configureFormFields(FormMapper $formMapper)
4043
{
4144
$formMapper
4245
->with('form.group_general')
43-
->add('parent', 'doctrine_phpcr_odm_tree', array(
46+
->add('parent', TreeModelType::class, array(
4447
'root_node' => $this->menuRoot,
4548
'choice_list' => array(),
4649
'select_root_node' => true,
@@ -54,7 +57,7 @@ protected function configureFormFields(FormMapper $formMapper)
5457
// Add the choice for the node links "target"
5558
$formMapper
5659
->with('form.group_general')
57-
->add('linkType', 'choice_field_mask', array(
60+
->add('linkType', ChoiceFieldMaskType::class, array(
5861
'choices' => array(
5962
'route' => 'route',
6063
'uri' => 'uri',
@@ -63,13 +66,13 @@ protected function configureFormFields(FormMapper $formMapper)
6366
'map' => array(
6467
'route' => array('link'),
6568
'uri' => array('link'),
66-
'content' => array('content', 'doctrine_phpcr_odm_tree'),
69+
'content' => array('content', TreeModelType::class),
6770
),
68-
'empty_value' => 'auto',
71+
'placeholder' => 'auto',
6972
'required' => false,
7073
))
71-
->add('link', 'text', array('required' => false, 'mapped' => false))
72-
->add('content', 'doctrine_phpcr_odm_tree',
74+
->add('link', TextType::class, array('required' => false, 'mapped' => false))
75+
->add('content', TreeModelType::class,
7376
array(
7477
'root_node' => $this->contentRoot,
7578
'choice_list' => array(),
@@ -159,15 +162,13 @@ public function buildBreadcrumbs($action, MenuItemInterface $menu = null)
159162
{
160163
$menuNodeNode = parent::buildBreadcrumbs($action, $menu);
161164

162-
if ($action != 'edit' || !$this->recursiveBreadcrumbs) {
165+
if ('edit' !== $action || !$this->recursiveBreadcrumbs) {
163166
return $menuNodeNode;
164167
}
165168

166169
$parentDoc = $this->getSubject()->getParentDocument();
167170
$pool = $this->getConfigurationPool();
168-
$parentAdmin = $pool->getAdminByClass(
169-
ClassUtils::getClass($parentDoc)
170-
);
171+
$parentAdmin = $pool->getAdminByClass(ClassUtils::getClass($parentDoc));
171172

172173
if (null === $parentAdmin) {
173174
return $menuNodeNode;

PublishWorkflow/CreateMenuItemFromNodeListener.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Cmf\Bundle\MenuBundle\PublishWorkflow;
1313

14-
use Symfony\Component\Security\Core\SecurityContextInterface;
14+
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
1515
use Symfony\Cmf\Bundle\MenuBundle\Event\CreateMenuItemFromNodeEvent;
1616
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishWorkflowChecker;
1717

@@ -36,10 +36,10 @@ class CreateMenuItemFromNodeListener
3636
private $publishWorkflowPermission;
3737

3838
/**
39-
* @param SecurityContextInterface $publishWorkflowChecker The publish workflow checker.
40-
* @param string $attribute The permission to check.
39+
* @param AuthorizationCheckerInterface $publishWorkflowChecker The publish workflow checker.
40+
* @param string $attribute The permission to check.
4141
*/
42-
public function __construct(SecurityContextInterface $publishWorkflowChecker, $attribute = PublishWorkflowChecker::VIEW_ATTRIBUTE)
42+
public function __construct(AuthorizationCheckerInterface $publishWorkflowChecker, $attribute = PublishWorkflowChecker::VIEW_ATTRIBUTE)
4343
{
4444
$this->publishWorkflowChecker = $publishWorkflowChecker;
4545
$this->publishWorkflowPermission = $attribute;

Tests/Resources/app/AppKernel.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public function configure()
2727
new \Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
2828
new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
2929
));
30+
31+
if (class_exists('Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle')) {
32+
$this->addBundles(array(
33+
new \Symfony\Cmf\Bundle\ResourceBundle\CmfResourceBundle(),
34+
new \Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle(),
35+
));
36+
}
3037
}
3138

3239
public function registerContainerConfiguration(LoaderInterface $loader)

Tests/Resources/app/config/config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
*/
1111

1212
$container->setParameter('cmf_testing.bundle_fqn', 'Symfony\Cmf\Bundle\MenuBundle');
13+
14+
$container->loadFromExtension('framework', array(
15+
'serializer' => true,
16+
));
17+
1318
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
1419
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
1520
$loader->import(CMF_TEST_CONFIG_DIR.'/sonata_admin.php');

Tests/Resources/app/config/routing.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
use Symfony\Component\Routing\RouteCollection;
1313

1414
$collection = new RouteCollection();
15-
$collection->addCollection(
16-
$loader->import(CMF_TEST_CONFIG_DIR.'/routing/sonata_routing.yml')
17-
);
18-
$collection->addCollection(
19-
$loader->import(__DIR__.'/routing/test.yml')
20-
);
15+
16+
$treeBrowserVersion = '1.x';
17+
if (class_exists('Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle')) {
18+
$treeBrowserVersion = '2.x';
19+
}
20+
21+
$collection->addCollection($loader->import(__DIR__.'/routing/sonata.yml'));
22+
$collection->addCollection($loader->import(__DIR__.'/routing/tree_browser_'.$treeBrowserVersion.'.yml'));
23+
$collection->addCollection($loader->import(__DIR__.'/routing/test.yml'));
2124

2225
return $collection;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
admin:
2+
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
3+
prefix: /admin
4+
5+
sonata_admin:
6+
resource: .
7+
type: sonata_admin
8+
prefix: /admin
9+
requirements:
10+
id: .+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmf_tree:
2+
resource: .
3+
type: 'cmf_tree'
4+
5+
fos_js_routing:
6+
resource: '@FOSJsRoutingBundle/Resources/config/routing/routing.xml'

0 commit comments

Comments
 (0)