diff --git a/.github/Bug_report.md b/.github/Bug_report.md
new file mode 100644
index 0000000..8b27ed7
--- /dev/null
+++ b/.github/Bug_report.md
@@ -0,0 +1,24 @@
+---
+name: Bug Report
+about: Report errors and problems
+
+---
+
+
+
+**Description**
+
+
+**How to reproduce**
+
+
+**Possible Solution**
+
+
+**Additional context**
+
diff --git a/.github/Documentation_issue.md b/.github/Documentation_issue.md
new file mode 100644
index 0000000..196478c
--- /dev/null
+++ b/.github/Documentation_issue.md
@@ -0,0 +1,10 @@
+---
+name: Documentation Issue
+about: Anything related to Symfony CMF Documentation
+
+---
+
+Symfony CMF Documentation has its own dedicated repository. Please open your
+documentation-related issue at https://github.com/symfony-cmf/symfony-cmf-docs/issues
+
+Thanks!
diff --git a/.github/Feature_request.md b/.github/Feature_request.md
new file mode 100644
index 0000000..db3e02c
--- /dev/null
+++ b/.github/Feature_request.md
@@ -0,0 +1,12 @@
+---
+name: Feature Request
+about: RFC and ideas for new features and improvements
+
+---
+
+**Description**
+
+
+**Example**
+
diff --git a/.github/Security_issue.md b/.github/Security_issue.md
new file mode 100644
index 0000000..34be6e0
--- /dev/null
+++ b/.github/Security_issue.md
@@ -0,0 +1,9 @@
+---
+name: Security Issue
+about: Report security-related errors
+
+---
+
+If you have found a security issue in Symfony, please send the details to
+[David](mailto:david@liip.ch) or [Maximilian](mailto:maximilian.berghoff@gmx.de) and don't disclose it publicly until we can provide a
+fix for it.
diff --git a/.github/Support_question.md b/.github/Support_question.md
new file mode 100644
index 0000000..c128b56
--- /dev/null
+++ b/.github/Support_question.md
@@ -0,0 +1,15 @@
+---
+name: Support Question
+about: Questions about using Symfony CMF and its components
+
+---
+
+**Description**
+
+
+**How to reproduce (optional)**
+
+
+**Possible Solution**
+
+
diff --git a/.gitignore b/.gitignore
index cc7c2c8..9d499c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ tests/Fixtures/App/var/logs
!tests/Fixtures/App/var/.gitempty
composer.lock
vendor
+build/
+.php_cs.cache
diff --git a/.php_cs.dist b/.php_cs.dist
new file mode 100644
index 0000000..5759af5
--- /dev/null
+++ b/.php_cs.dist
@@ -0,0 +1,64 @@
+ true,
+ '@Symfony:risky' => true,
+ 'array_syntax' => [
+ 'syntax' => 'short',
+ ],
+ 'combine_consecutive_issets' => true,
+ 'combine_consecutive_unsets' => true,
+ 'header_comment' => [
+ 'header' => $header,
+ ],
+ 'no_extra_blank_lines' => true,
+ 'no_php4_constructor' => true,
+ 'no_useless_else' => true,
+ 'no_useless_return' => true,
+ 'ordered_class_elements' => true,
+ 'ordered_imports' => true,
+ 'phpdoc_order' => true,
+ '@PHP56Migration' => true,
+ '@PHP56Migration:risky' => true,
+ '@PHPUnit57Migration:risky' => true,
+ '@PHP70Migration' => true,
+ '@PHP70Migration:risky' => true,
+ '@PHPUnit60Migration:risky' => true,
+ '@PHP71Migration' => true,
+ '@PHP71Migration:risky' => true,
+ 'compact_nullable_typehint' => true,
+ 'void_return' => null,
+ 'strict_comparison' => true,
+ 'strict_param' => true,
+];
+
+
+$finder = PhpCsFixer\Finder::create()
+ ->in(__DIR__)
+ ->exclude('Tests/Fixtures')
+ ->exclude('tests/Fixtures')
+ ->exclude('Resources/skeleton')
+ ->exclude('Resources/public/vendor')
+;
+
+return PhpCsFixer\Config::create()
+ ->setFinder($finder)
+ ->setRiskyAllowed(true)
+ ->setRules($rules)
+ ->setUsingCache(true)
+;
diff --git a/.styleci.yml b/.styleci.yml
index 2bdb04b..c721eb6 100644
--- a/.styleci.yml
+++ b/.styleci.yml
@@ -7,7 +7,7 @@
############################################################################
# This file is part of the Symfony CMF package. #
# #
-# (c) 2011-2017 Symfony CMF #
+# (c) Symfony CMF #
# #
# For the full copyright and license information, please view the LICENSE #
# file that was distributed with this source code. #
diff --git a/.travis.yml b/.travis.yml
index 9bd7838..77a1266 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@
############################################################################
# This file is part of the Symfony CMF package. #
# #
-# (c) 2011-2017 Symfony CMF #
+# (c) Symfony CMF #
# #
# For the full copyright and license information, please view the LICENSE #
# file that was distributed with this source code. #
@@ -17,7 +17,8 @@ language: php
php:
- 7.1
-
+ - 7.2
+ - 7.3
sudo: false
cache:
@@ -26,40 +27,50 @@ cache:
- $HOME/.composer/cache/files
env:
- matrix: SYMFONY_VERSION=4.0.*
+ matrix: SYMFONY_VERSION=4.2.*
global:
- - SYMFONY_DEPRECATIONS_HELPER=0
+ - SYMFONY_DEPRECATIONS_HELPER="/.*each.*/"
- SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
- - KERNEL_CLASS=Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Fixtures\App\Kernel
- - SYMFONY_PHPUNIT_VERSION=5.7
- - TEST_INSTALLATION=false
+ - SYMFONY_PHPUNIT_VERSION=7
+ - PHPUNIT_VERSION=7
+ - TARGET=test
matrix:
include:
+ - env: TARGET=lint
+ - php: 7.3
+ env: STABILITY="dev" SYMFONY_VERSION=4.3.*
+ - php: 7.3
+ env: SYMFONY_VERSION=4.2.*
- php: 7.1
- env: STABILITY=dev SYMFONY_VERSION=4.0.*
- - php: 7.1
- env: STABILITY=dev COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
- - php: 7.1
- env: STABILITY=dev SYMFONY_VERSION=3.3.*
- - php: 7.1
- env: STABILITY=dev SYMFONY_VERSION=3.4.*
- - env: TEST_INSTALLATION=true
+ env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER="/.*each.*/"
+
+ - php: 7.2
+ env: SYMFONY_VERSION=4.1.*
+ - env: TARGET=test_installation
fast_finish: true
allow_failures:
- - env: TEST_INSTALLATION=true
+ - php: 7.3
+ env: STABILITY="dev" SYMFONY_VERSION=4.3.*
+ - env: TARGET=test_installation
before_install:
- phpenv config-rm xdebug.ini || true
- composer self-update
+ - composer validate --no-check-all --ansi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; composer config prefer-stable true; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer require symfony/symfony:${SYMFONY_VERSION} --no-update; fi
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
-install: travis_wait composer update --prefer-dist $COMPOSER_FLAGS
+install:
+ - phpenv config-add travis.php.ini
+ - php -ini | grep memory_limit
+ - if [ -x .travis/install_${TARGET}.sh ]; then .travis/install_${TARGET}.sh; fi;
+
+script: make $TARGET
-script:
- - if [ "${TEST_INSTALLATION}" == true ]; then make test_installation; else make test; fi
+after_success:
+ - if [ -x .travis/after_success_${TARGET}.sh ]; then .travis/after_success_${TARGET}.sh; fi;
notifications:
irc: "irc.freenode.org#symfony-cmf"
diff --git a/.travis/after_success_test.sh b/.travis/after_success_test.sh
new file mode 100755
index 0000000..9837420
--- /dev/null
+++ b/.travis/after_success_test.sh
@@ -0,0 +1,5 @@
+
+#!/usr/bin/env sh
+set -ev
+
+coveralls -v
diff --git a/.travis/install_lint.sh b/.travis/install_lint.sh
new file mode 100755
index 0000000..864c751
--- /dev/null
+++ b/.travis/install_lint.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+set -ev
+
+mkdir --parents "${HOME}/bin"
+
+wget "http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar" --output-document="${HOME}/bin/php-cs-fixer"
+chmod u+x "${HOME}/bin/php-cs-fixer"
+
+composer global require sllh/composer-lint:@stable --prefer-dist --no-interaction
+
+gem install yaml-lint
diff --git a/.travis/install_test.sh b/.travis/install_test.sh
new file mode 100755
index 0000000..a033500
--- /dev/null
+++ b/.travis/install_test.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env sh
+set -ev
+
+mkdir --parents "${HOME}/bin"
+
+wget "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" --output-document="${HOME}/bin/phpunit"
+chmod u+x "${HOME}/bin/phpunit"
+
+# Coveralls client install
+wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar --output-document="${HOME}/bin/coveralls"
+chmod u+x "${HOME}/bin/coveralls"
+
+# To be removed when these issues are resolved:
+# https://github.com/composer/composer/issues/5355
+if [ "${COMPOSER_FLAGS}" = '--prefer-lowest' ]; then
+ composer update --prefer-dist --no-interaction --prefer-stable --quiet
+fi
+
+composer update --prefer-dist --no-interaction --prefer-stable ${COMPOSER_FLAGS}
diff --git a/Makefile b/Makefile
index 1b1c030..1f9990a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@
############################################################################
# This file is part of the Symfony CMF package. #
# #
-# (c) 2011-2017 Symfony CMF #
+# (c) Symfony CMF #
# #
# For the full copyright and license information, please view the LICENSE #
# file that was distributed with this source code. #
@@ -20,16 +20,63 @@ ifdef BRANCH
VERSION=dev-${BRANCH}
endif
PACKAGE=symfony-cmf/sonata-phpcr-admin-integration-bundle
-export KERNEL_CLASS=Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Fixtures\App\Kernel
+HAS_XDEBUG=$(shell php --modules|grep --quiet xdebug;echo $$?)
+
list:
@echo 'test: will run all tests'
@echo 'unit_tests: will run unit tests only'
@echo 'functional_tests_phpcr: will run functional tests with PHPCR'
- @echo 'test_installation: will run installation test'
-include ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk
-include ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk
-include ${TESTING_SCRIPTS_DIR}/make/test_installation.mk
+ @echo 'test_installation: will run installation test'TEST_DEPENDENCIES := ""
+EXTRA_INCLUDES:=$(wildcard ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk)
+ifneq ($(strip $(EXTRA_INCLUDES)),)
+ contents := $(shell echo including extra rules $(EXTRA_INCLUDES))
+ include $(EXTRA_INCLUDES)
+ TEST_DEPENDENCIES := $(TEST_DEPENDENCIES)" unit_tests"
+ endif
+EXTRA_INCLUDES:=$(wildcard ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk)
+ifneq ($(strip $(EXTRA_INCLUDES)),)
+ contents := $(shell echo including extra rules $(EXTRA_INCLUDES))
+ include $(EXTRA_INCLUDES)
+ TEST_DEPENDENCIES := $(TEST_DEPENDENCIES)" functional_tests_phpcr"
+ endif
+EXTRA_INCLUDES:=$(wildcard ${TESTING_SCRIPTS_DIR}/make/test_installation.mk)
+ifneq ($(strip $(EXTRA_INCLUDES)),)
+ contents := $(shell echo including extra rules $(EXTRA_INCLUDES))
+ include $(EXTRA_INCLUDES)
+ endif
.PHONY: test
-test: unit_tests functional_tests_phpcr
+test: build/xdebug-filter.php$
+ifneq ($(strip $(wildcard ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk)),)
+ @make unit_tests
+endif
+ifneq ($(strip $(wildcard ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk)),)
+ @make functional_tests_phpcr
+endif
+
+lint-php:
+ php-cs-fixer fix --ansi --verbose --diff --dry-run
+.PHONY: lint-php
+
+lint: lint-composer lint-php
+.PHONY: lint
+
+lint-composer:
+ composer validate
+.PHONY: lint-composer
+
+cs-fix: cs-fix-php
+.PHONY: cs-fix
+
+cs-fix-php:
+ php-cs-fixer fix --verbose
+.PHONY: cs-fix-php
+
+build:
+ mkdir $@
+
+build/xdebug-filter.php: phpunit.xml.dist build
+ifeq ($(HAS_XDEBUG), 0)
+ phpunit --dump-xdebug-filter $@
+endif
diff --git a/README.md b/README.md
index 974b1a7..787e726 100644
--- a/README.md
+++ b/README.md
@@ -8,35 +8,37 @@
[](https://packagist.org/packages/symfony-cmf/sonata-phpcr-admin-integration-bundle)
[](https://packagist.org/packages/symfony-cmf/sonata-phpcr-admin-integration-bundle)
-Branch | Travis | Coveralls |
------- | ------ | --------- |
-master | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] |
+Branch | Travis | Coveralls | Scrutinizer |
+------ | ------ | --------- | ----------- |
+1.0 | [![Build Status][travis_stable_badge]][travis_stable_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] | [![Scrutinizer Status][scrutinizer_stable_badge]][scrutinizer_stable_link] |
+dev-master | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] | [![Scrutinizer Status][scrutinizer_unstable_badge]][scrutinizer_unstable_link] |
-This package is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/) and licensed
+
+This package is part of the [Symfony Content Management Framework (CMF)](https://cmf.symfony.com/) and licensed
under the [MIT License](LICENSE).
## Requirements
-* PHP 7.1
-* Symfony 2.8 / 3.3 / 3.4 / 4.0
+* PHP 7.1 / 7.2 / 7.3
+* Symfony 3.4 / 4.1 / 4.2
* See also the `require` section of [composer.json](composer.json)
## Documentation
For the install guide and reference, see:
-* [symfony-cmf/sonata-phpcr-admin-integration-bundle Documentation](http://symfony.com/doc/master/cmf/bundles/sonata-phpcr-admin-integration-bundle/index.html)
+* [symfony-cmf/sonata-phpcr-admin-integration-bundle Documentation](https://symfony.com/doc/master/cmf/bundles/sonata-phpcr-admin-integration-bundle/index.html)
See also:
-* [All Symfony CMF documentation](http://symfony.com/doc/master/cmf/index.html) - complete Symfony CMF reference
-* [Symfony CMF Website](http://cmf.symfony.com/) - introduction, live demo, support and community links
+* [All Symfony CMF documentation](https://symfony.com/doc/master/cmf/index.html) - complete Symfony CMF reference
+* [Symfony CMF Website](https://cmf.symfony.com/) - introduction, live demo, support and community links
## Support
-For general support and questions, please use [StackOverflow](http://stackoverflow.com/questions/tagged/symfony-cmf).
+For general support and questions, please use [StackOverflow](https://stackoverflow.com/questions/tagged/symfony-cmf).
## Contributing
@@ -45,7 +47,7 @@ Pull requests are welcome. Please see our
guide.
Unit and/or functional tests exist for this package. See the
-[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html)
+[Testing documentation](https://symfony.com/doc/master/cmf/components/testing.html)
for a guide to running the tests.
Thanks to
@@ -55,16 +57,17 @@ Thanks to
This package is available under the [MIT license](src/Resources/meta/LICENSE).
-[travis_legacy_badge]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle.svg?branch=master
-[travis_legacy_link]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle
-[travis_stable_badge]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle.svg?branch=master
+[travis_stable_badge]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle.svg?branch=1.0
[travis_stable_link]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle
-[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle.svg?branch=master
+[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle.svg?branch=dev-master
[travis_unstable_link]: https://travis-ci.org/symfony-cmf/sonata-phpcr-admin-integration-bundle
-[coveralls_legacy_badge]: https://coveralls.io/repos/github/symfony-cmf/sonata-phpcr-admin-integration-bundle/badge.svg?branch=master
-[coveralls_legacy_link]: https://coveralls.io/github/symfony-cmf/sonata-phpcr-admin-integration-bundle?branch=master
-[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/sonata-phpcr-admin-integration-bundle/badge.svg?branch=master
-[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/sonata-phpcr-admin-integration-bundle?branch=master
-[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/sonata-phpcr-admin-integration-bundle/badge.svg?branch=master
-[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/sonata-phpcr-admin-integration-bundle?branch=master
+[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/sonata-phpcr-admin-integration-bundle/badge.svg?branch=1.0
+[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/sonata-phpcr-admin-integration-bundle?branch=1.0
+[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/sonata-phpcr-admin-integration-bundle/badge.svg?branch=dev-master
+[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/sonata-phpcr-admin-integration-bundle?branch=dev-master
+
+[scrutinizer_stable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/sonata-phpcr-admin-integration-bundle/badges/quality-score.png?b=1.0
+[scrutinizer_stable_link]: https://scrutinizer-ci.com/g/symfony-cmf/sonata-phpcr-admin-integration-bundle/?branch=1.0
+[scrutinizer_unstable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/sonata-phpcr-admin-integration-bundle/badges/quality-score.png?b=dev-master
+[scrutinizer_unstable_link]: https://scrutinizer-ci.com/g/symfony-cmf/sonata-phpcr-admin-integration-bundle/?branch=dev-master
diff --git a/composer.json b/composer.json
index a8ffc21..2a25664 100644
--- a/composer.json
+++ b/composer.json
@@ -17,13 +17,13 @@
],
"require": {
"php": "^7.1",
- "symfony/framework-bundle": "^2.8 || ^3.3 || ^4.0",
- "sonata-project/doctrine-phpcr-admin-bundle": "^2.1",
+ "symfony/framework-bundle": "^3.4 || ^4.1",
+ "sonata-project/doctrine-phpcr-admin-bundle": "^2.2",
"sonata-project/admin-bundle": "^3.6.0",
"symfony-cmf/tree-browser-bundle": "^2.0"
},
"require-dev": {
- "symfony-cmf/testing": "^2.1",
+ "symfony-cmf/testing": "^2.1.11",
"symfony-cmf/core-bundle": "^2.1",
"symfony-cmf/routing-bundle": "^2.1",
"symfony-cmf/seo-bundle": "^2.1",
@@ -31,24 +31,22 @@
"symfony-cmf/block-bundle": "^2.1",
"symfony-cmf/content-bundle": "^2.1",
"doctrine/orm": "^2.4",
- "doctrine/phpcr-odm": "^1.4|^2.0",
+ "doctrine/phpcr-odm": "^1.4 || ^2.0",
"doctrine/doctrine-bundle": "^1.3",
- "symfony/phpunit-bridge": "^3.3 || ^4.0",
- "matthiasnoback/symfony-dependency-injection-test": "^1.1",
- "matthiasnoback/symfony-config-test": "^2.1",
+ "symfony/phpunit-bridge": "^4.2.2",
"burgov/key-value-form-bundle": "^1.0",
- "friendsofsymfony/ckeditor-bundle": "^1.0",
- "sebastian/environment": "^1.3.4",
- "sebastian/exporter": "^2.0.0",
- "symfony/asset": "^2.8 || ^3.3 || ^4.0",
- "symfony/browser-kit": "^2.8 || ^3.3 || ^4.0",
- "symfony/css-selector": "^2.8 || ^3.3 || ^4.0"
+ "friendsofsymfony/ckeditor-bundle": "^1.0 || ^2.0",
+ "symfony/asset": "^3.4 || ^4.1",
+ "symfony/browser-kit": "^3.4 || ^4.1",
+ "symfony/css-selector": "^3.4 || ^4.1",
+ "matthiasnoback/symfony-dependency-injection-test": "^3.1",
+ "matthiasnoback/symfony-config-test": "^4.0.1"
},
"suggest": {
"symfony-cmf/routing-bundle": "To make use of the alternate locale provider.",
"doctrine/phpcr-bundle": "To persist the metadata in PHPCR ODM documents",
"doctrine/doctrine-bundle": "To persist the metadata in ORM entities",
- "doctrine/orm": "To persist the metadata in ORM entities, ~2.4",
+ "doctrine/orm": "To persist the metadata in ORM entities, ^2.4",
"friendsofsymfony/ckeditor-bundl": "To have CkEditor support on textareas."
},
"autoload": {
@@ -65,7 +63,5 @@
"branch-alias": {
"dev-master": "2.0-dev"
}
- },
- "minimum-stability": "dev",
- "prefer-stable": true
+ }
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 3a2dc07..8865efc 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,32 +1,36 @@
+
+
+ colors="true"
+ bootstrap="vendor/symfony-cmf/testing/bootstrap/bootstrap.php"
+>
+
+
-
-
+
+
./tests/Unit
-
+
- ./tests/WebTest
+ ./tests/Functional
+ ./tests/Functional/Doctrine/Orm
-
+
+
-
-
- .
-
- src/Resources/
- tests/
- vendor/
-
-
-
+
+
+ src/
+
+ Resources/
+
+
+
-
-
-
+
+
+
diff --git a/src/Admin/AbstractAdmin.php b/src/Admin/AbstractAdmin.php
index 25c23ce..9c51d2e 100644
--- a/src/Admin/AbstractAdmin.php
+++ b/src/Admin/AbstractAdmin.php
@@ -1,9 +1,11 @@
menuPath = $menuPath;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMenuPath()
+ {
+ return $this->menuPath;
+ }
+
/**
* {@inheritdoc}
*/
@@ -66,29 +93,4 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper)
->add('name', 'doctrine_phpcr_nodename')
;
}
-
- /**
- * PHPCR to the root of all menu nodes for the selection of the target.
- *
- * @var string
- */
- private $menuPath;
-
- /**
- * Set the menu root for selection of the target of this block.
- *
- * @param string $menuPath
- */
- public function setMenuPath($menuPath)
- {
- $this->menuPath = $menuPath;
- }
-
- /**
- * @return string
- */
- public function getMenuPath()
- {
- return $this->menuPath;
- }
}
diff --git a/src/Admin/Block/ReferenceBlockAdmin.php b/src/Admin/Block/ReferenceBlockAdmin.php
index 0b83ad0..436383d 100644
--- a/src/Admin/Block/ReferenceBlockAdmin.php
+++ b/src/Admin/Block/ReferenceBlockAdmin.php
@@ -1,9 +1,11 @@
getTitle()
+ ? $object->getTitle()
+ : parent::toString($object)
+ ;
+ }
+
/**
* {@inheritdoc}
*/
@@ -61,12 +71,4 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper)
->add('name', 'doctrine_phpcr_nodename')
;
}
-
- public function toString($object)
- {
- return $object instanceof SimpleBlock && $object->getTitle()
- ? $object->getTitle()
- : parent::toString($object)
- ;
- }
}
diff --git a/src/Admin/Block/SlideshowBlockAdmin.php b/src/Admin/Block/SlideshowBlockAdmin.php
index 720c748..2a611a2 100644
--- a/src/Admin/Block/SlideshowBlockAdmin.php
+++ b/src/Admin/Block/SlideshowBlockAdmin.php
@@ -1,9 +1,11 @@
embeddedAdminCode = $adminCode;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function prePersist($slideshow)
+ {
+ foreach ($slideshow->getChildren() as $child) {
+ $child->setName($this->generateName());
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function preUpdate($slideshow)
+ {
+ foreach ($slideshow->getChildren() as $child) {
+ if (!$this->modelManager->getNormalizedIdentifier($child)) {
+ $child->setName($this->generateName());
+ }
+ }
+ }
+
+ public function toString($object)
+ {
+ return $object instanceof SlideshowBlock && $object->getTitle()
+ ? $object->getTitle()
+ : parent::toString($object)
+ ;
+ }
+
/**
* {@inheritdoc}
*/
@@ -80,28 +112,6 @@ protected function configureFormFields(FormMapper $formMapper)
;
}
- /**
- * {@inheritdoc}
- */
- public function prePersist($slideshow)
- {
- foreach ($slideshow->getChildren() as $child) {
- $child->setName($this->generateName());
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function preUpdate($slideshow)
- {
- foreach ($slideshow->getChildren() as $child) {
- if (!$this->modelManager->getNormalizedIdentifier($child)) {
- $child->setName($this->generateName());
- }
- }
- }
-
/**
* Generate a most likely unique name.
*
@@ -111,14 +121,6 @@ public function preUpdate($slideshow)
*/
private function generateName()
{
- return 'child_'.time().'_'.rand();
- }
-
- public function toString($object)
- {
- return $object instanceof SlideshowBlock && $object->getTitle()
- ? $object->getTitle()
- : parent::toString($object)
- ;
+ return 'child_'.time().'_'.random_int(0, getrandmax());
}
}
diff --git a/src/Admin/Block/StringBlockAdmin.php b/src/Admin/Block/StringBlockAdmin.php
index 94d91da..7fc288d 100644
--- a/src/Admin/Block/StringBlockAdmin.php
+++ b/src/Admin/Block/StringBlockAdmin.php
@@ -1,9 +1,11 @@
ckEditorConfig = $config;
}
+ public function toString($object)
+ {
+ return $object instanceof StaticContentBase && $object->getTitle()
+ ? $object->getTitle()
+ : $this->trans('link_add', [], 'SonataAdminBundle')
+ ;
+ }
+
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
@@ -97,12 +107,4 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper)
->add('name', 'doctrine_phpcr_nodename')
;
}
-
- public function toString($object)
- {
- return $object instanceof StaticContentBase && $object->getTitle()
- ? $object->getTitle()
- : $this->trans('link_add', [], 'SonataAdminBundle')
- ;
- }
}
diff --git a/src/Admin/Core/Extension/ChildExtension.php b/src/Admin/Core/Extension/ChildExtension.php
index 029bf66..585b37b 100644
--- a/src/Admin/Core/Extension/ChildExtension.php
+++ b/src/Admin/Core/Extension/ChildExtension.php
@@ -1,9 +1,11 @@
contentRoot = $contentRoot;
+ }
+
+ public function setMenuRoot($menuRoot)
+ {
+ $this->menuRoot = $menuRoot;
+ }
+
+ public function setContentTreeBlock($contentTreeBlock)
+ {
+ $this->contentTreeBlock = $contentTreeBlock;
+ }
+
+ public function toString($object)
+ {
+ if ($object instanceof MenuNodeBase && $object->getLabel()) {
+ return $object->getLabel();
+ }
+
+ return $this->trans('link_add', [], 'SonataAdminBundle');
+ }
+
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
@@ -71,33 +102,4 @@ protected function configureShowFields(ShowMapper $showMapper)
->add('content', null, ['associated_property' => 'title'])
;
}
-
- public function getExportFormats()
- {
- return [];
- }
-
- public function setContentRoot($contentRoot)
- {
- $this->contentRoot = $contentRoot;
- }
-
- public function setMenuRoot($menuRoot)
- {
- $this->menuRoot = $menuRoot;
- }
-
- public function setContentTreeBlock($contentTreeBlock)
- {
- $this->contentTreeBlock = $contentTreeBlock;
- }
-
- public function toString($object)
- {
- if ($object instanceof MenuNodeBase && $object->getLabel()) {
- return $object->getLabel();
- }
-
- return $this->trans('link_add', [], 'SonataAdminBundle');
- }
}
diff --git a/src/Admin/Menu/Extension/MenuNodeReferrersExtension.php b/src/Admin/Menu/Extension/MenuNodeReferrersExtension.php
index a6a4b02..ac718ec 100644
--- a/src/Admin/Menu/Extension/MenuNodeReferrersExtension.php
+++ b/src/Admin/Menu/Extension/MenuNodeReferrersExtension.php
@@ -1,9 +1,11 @@
setParentDocument($this->getModelManager()->find(null, $this->menuRoot));
+
+ return $new;
+ }
+
/**
* {@inheritdoc}
*/
@@ -44,13 +55,4 @@ protected function configureFormFields(FormMapper $formMapper)
;
}
}
-
- public function getNewInstance()
- {
- /** @var $new Menu */
- $new = parent::getNewInstance();
- $new->setParentDocument($this->getModelManager()->find(null, $this->menuRoot));
-
- return $new;
- }
}
diff --git a/src/Admin/Menu/MenuNodeAdmin.php b/src/Admin/Menu/MenuNodeAdmin.php
index 17ad92f..2073a2d 100644
--- a/src/Admin/Menu/MenuNodeAdmin.php
+++ b/src/Admin/Menu/MenuNodeAdmin.php
@@ -1,9 +1,11 @@
add('uri', 'text')
- ->add('route', 'text')
- ;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function configureFormFields(FormMapper $formMapper)
- {
- $formMapper
- ->tab('form.tab_general')
- ->with('form.group_location', ['class' => 'col-sm-3'])
- ->add(
- 'parentDocument',
- TreeSelectType::class,
- ['root_node' => $this->menuRoot, 'widget' => 'browser']
- )
- ->end()
- ->end()
- ;
-
- $this->addTransformerToField($formMapper->getFormBuilder(), 'parentDocument');
-
- parent::configureFormFields($formMapper);
-
- if (null === $this->getParentFieldDescription()) {
- // Add the choice for the node links "target"
- $formMapper
- ->tab('form.tab_general')
- ->with('form.group_target', ['class' => 'col-sm-6'])
- ->add('linkType', ChoiceFieldMaskType::class, [
- 'choices' => [
- 'route' => 'route',
- 'uri' => 'uri',
- 'content' => 'content',
- ],
- 'map' => [
- 'route' => ['link'],
- 'uri' => ['link'],
- 'content' => ['content', TreeSelectType::class],
- ],
- 'placeholder' => 'auto',
- 'required' => false,
- ])
- ->add('link', TextType::class, ['required' => false, 'mapped' => false])
- ->add(
- 'content',
- TreeSelectType::class,
- ['root_node' => $this->contentRoot, 'widget' => 'browser', 'required' => false]
- )
- ->end()
- ->end()
- ;
-
- $this->addTransformerToField($formMapper->getFormBuilder(), 'content');
- }
- }
-
/**
* {@inheritdoc}
*/
@@ -205,4 +143,68 @@ public function setRecursiveBreadcrumbs($recursiveBreadcrumbs)
{
$this->recursiveBreadcrumbs = (bool) $recursiveBreadcrumbs;
}
+
+ protected function configureListFields(ListMapper $listMapper)
+ {
+ parent::configureListFields($listMapper);
+
+ $listMapper
+ ->add('uri', 'text')
+ ->add('route', 'text')
+ ;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function configureFormFields(FormMapper $formMapper)
+ {
+ $formMapper
+ ->tab('form.tab_general')
+ ->with('form.group_location', ['class' => 'col-sm-3'])
+ ->add(
+ 'parentDocument',
+ TreeSelectType::class,
+ ['root_node' => $this->menuRoot, 'widget' => 'browser']
+ )
+ ->end()
+ ->end()
+ ;
+
+ $this->addTransformerToField($formMapper->getFormBuilder(), 'parentDocument');
+
+ parent::configureFormFields($formMapper);
+
+ if (null === $this->getParentFieldDescription()) {
+ // Add the choice for the node links "target"
+ $formMapper
+ ->tab('form.tab_general')
+ ->with('form.group_target', ['class' => 'col-sm-6'])
+ ->add('linkType', ChoiceFieldMaskType::class, [
+ 'choices' => [
+ 'route' => 'route',
+ 'uri' => 'uri',
+ 'content' => 'content',
+ ],
+ 'map' => [
+ 'route' => ['link'],
+ 'uri' => ['link'],
+ 'content' => ['content', TreeSelectType::class],
+ ],
+ 'placeholder' => 'auto',
+ 'required' => false,
+ ])
+ ->add('link', TextType::class, ['required' => false, 'mapped' => false])
+ ->add(
+ 'content',
+ TreeSelectType::class,
+ ['root_node' => $this->contentRoot, 'widget' => 'browser', 'required' => false]
+ )
+ ->end()
+ ->end()
+ ;
+
+ $this->addTransformerToField($formMapper->getFormBuilder(), 'content');
+ }
+ }
}
diff --git a/src/Admin/Routing/Extension/FrontendLinkExtension.php b/src/Admin/Routing/Extension/FrontendLinkExtension.php
index e1048d9..a2c39ac 100644
--- a/src/Admin/Routing/Extension/FrontendLinkExtension.php
+++ b/src/Admin/Routing/Extension/FrontendLinkExtension.php
@@ -1,9 +1,11 @@
getId())) {
+ if ($subject instanceof PrefixInterface && !\is_string($subject->getId())) {
// we have an unpersisted dynamic route
return;
}
diff --git a/src/Admin/Routing/Extension/RouteReferrersExtension.php b/src/Admin/Routing/Extension/RouteReferrersExtension.php
index bb02256..bd9142c 100644
--- a/src/Admin/Routing/Extension/RouteReferrersExtension.php
+++ b/src/Admin/Routing/Extension/RouteReferrersExtension.php
@@ -1,9 +1,11 @@
getId()
+ ? $object->getId()
+ : $this->trans('link_add', [], 'SonataAdminBundle')
+ ;
+ }
+
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->addIdentifier('path', 'text');
@@ -58,17 +73,4 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('name', 'doctrine_phpcr_nodename');
}
-
- public function getExportFormats()
- {
- return [];
- }
-
- public function toString($object)
- {
- return $object instanceof Route && $object->getId()
- ? $object->getId()
- : $this->trans('link_add', [], 'SonataAdminBundle')
- ;
- }
}
diff --git a/src/Admin/Routing/RouteAdmin.php b/src/Admin/Routing/RouteAdmin.php
index 9228440..3de1e0d 100644
--- a/src/Admin/Routing/RouteAdmin.php
+++ b/src/Admin/Routing/RouteAdmin.php
@@ -1,9 +1,11 @@
contentRoot = $contentRoot;
+ }
+
+ public function getExportFormats()
+ {
+ return [];
+ }
+
+ public function prePersist($object)
+ {
+ $defaults = array_filter($object->getDefaults());
+ $object->setDefaults($defaults);
+ }
+
+ public function preUpdate($object)
+ {
+ $defaults = array_filter($object->getDefaults());
+ $object->setDefaults($defaults);
+ }
+
+ public function toString($object)
+ {
+ return $object instanceof Route && $object->getId()
+ ? $object->getId()
+ : $this->trans('link_add', [], 'SonataAdminBundle')
+ ;
+ }
+
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->addIdentifier('path', 'text');
@@ -103,16 +135,6 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper)
$datagridMapper->add('name', 'doctrine_phpcr_nodename');
}
- public function setContentRoot($contentRoot)
- {
- $this->contentRoot = $contentRoot;
- }
-
- public function getExportFormats()
- {
- return [];
- }
-
/**
* Provide default route defaults and extract defaults from $dynamicDefaults.
*
@@ -184,24 +206,4 @@ protected function configureFieldsForOptions(array $dynamicOptions)
return $options;
}
-
- public function prePersist($object)
- {
- $defaults = array_filter($object->getDefaults());
- $object->setDefaults($defaults);
- }
-
- public function preUpdate($object)
- {
- $defaults = array_filter($object->getDefaults());
- $object->setDefaults($defaults);
- }
-
- public function toString($object)
- {
- return $object instanceof Route && $object->getId()
- ? $object->getId()
- : $this->trans('link_add', [], 'SonataAdminBundle')
- ;
- }
}
diff --git a/src/Admin/Seo/Extension/SeoContentAdminExtension.php b/src/Admin/Seo/Extension/SeoContentAdminExtension.php
index 91978a8..e0884be 100644
--- a/src/Admin/Seo/Extension/SeoContentAdminExtension.php
+++ b/src/Admin/Seo/Extension/SeoContentAdminExtension.php
@@ -1,9 +1,11 @@
factories);
}
- private function loadBundles(array $config, XmlFileLoader $loader, ContainerBuilder $container)
- {
- foreach ($this->factories as $name => $factory) {
- if ($this->isConfigEnabled($container, $config[$name])) {
- $factory->create($config[$name], $container, $loader);
- }
- }
- }
-
/**
* Registers an admin factory.
*
@@ -113,6 +106,15 @@ public function getXsdValidationBasePath()
return __DIR__.'/../Resources/config/schema';
}
+ private function loadBundles(array $config, XmlFileLoader $loader, ContainerBuilder $container)
+ {
+ foreach ($this->factories as $name => $factory) {
+ if ($this->isConfigEnabled($container, $config[$name])) {
+ $factory->create($config[$name], $container, $loader);
+ }
+ }
+ }
+
private function addDefaultFactories(ContainerBuilder $container)
{
$bundles = [
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 8acf9d9..78d9d9f 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -1,9 +1,11 @@
getParameterBag()->resolveValue($enabled);
- $bundleExists = array_key_exists($requiredBundle, $container->getParameter('kernel.bundles'));
+ $bundleExists = \array_key_exists($requiredBundle, $container->getParameter('kernel.bundles'));
if ('auto' === $enabled) {
$enabled = $bundleExists;
diff --git a/src/DependencyInjection/Factory/MenuAdminFactory.php b/src/DependencyInjection/Factory/MenuAdminFactory.php
index c5ac6cd..23ada43 100644
--- a/src/DependencyInjection/Factory/MenuAdminFactory.php
+++ b/src/DependencyInjection/Factory/MenuAdminFactory.php
@@ -1,9 +1,11 @@
set(self::$linkKeyMapping[$linkKey], $url);
}
}
@@ -107,7 +109,7 @@ public function supports(PuliResource $resource)
private function getAdminByClass($class)
{
- if (array_key_exists($class, $this->adminMap)) {
+ if (\array_key_exists($class, $this->adminMap)) {
return $this->adminMap[$class];
}
diff --git a/src/Resources/meta/LICENSE b/src/Resources/meta/LICENSE
index e75f5fc..73af90c 100644
--- a/src/Resources/meta/LICENSE
+++ b/src/Resources/meta/LICENSE
@@ -1,8 +1,8 @@
-Symfony Cmf Sonata Phpcr Admin Integration Bundle
+Symfony CMF Sonata Phpcr Admin Integration Bundle
The MIT License
- Copyright (c) 2011-2017 Symfony CMF
+ Copyright (c) Symfony CMF
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/tests/Unit/Admin/Core/Extension/ChildExtensionTest.php b/tests/Unit/Admin/Core/Extension/ChildExtensionTest.php
index fc1e599..3976862 100644
--- a/tests/Unit/Admin/Core/Extension/ChildExtensionTest.php
+++ b/tests/Unit/Admin/Core/Extension/ChildExtensionTest.php
@@ -1,9 +1,11 @@
expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
+
$this->container->setParameter(
'kernel.bundles',
[
@@ -63,4 +54,14 @@ public function testEnhancerExists()
['alias' => 'sonata_phpcr_admin']
);
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getContainerExtensions()
+ {
+ return [
+ new CmfSonataPhpcrAdminIntegrationExtension(),
+ ];
+ }
}
diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php
index 0857d4e..e0acebc 100644
--- a/tests/Unit/DependencyInjection/ConfigurationTest.php
+++ b/tests/Unit/DependencyInjection/ConfigurationTest.php
@@ -1,9 +1,11 @@
new Factory\SeoAdminFactory(),
- 'core' => new Factory\CoreAdminFactory(),
- ]);
- }
-
public function testDefaultsForAllConfigFormats()
{
$expectedConfiguration = [
@@ -77,4 +66,17 @@ public function testDefaultsForAllConfigFormats()
$this->assertProcessedConfigurationEquals($expectedConfiguration, $sources);
}
+
+ protected function getContainerExtension()
+ {
+ return new CmfSonataPhpcrAdminIntegrationExtension();
+ }
+
+ protected function getConfiguration()
+ {
+ return new Configuration([
+ 'seo' => new Factory\SeoAdminFactory(),
+ 'core' => new Factory\CoreAdminFactory(),
+ ]);
+ }
}
diff --git a/tests/Unit/DependencyInjection/Factory/AbstractFactoryTest.php b/tests/Unit/DependencyInjection/Factory/AbstractFactoryTest.php
index b340d96..85ff7d7 100644
--- a/tests/Unit/DependencyInjection/Factory/AbstractFactoryTest.php
+++ b/tests/Unit/DependencyInjection/Factory/AbstractFactoryTest.php
@@ -1,9 +1,11 @@
* @author Maximilian Berghoff
*/
-class ContentAdminFactoryTest extends \PHPUnit_Framework_TestCase
+class ContentAdminFactoryTest extends TestCase
{
private $factory;
@@ -37,12 +40,11 @@ protected function setUp()
$this->fileLoader = $this->createMock(XmlFileLoader::class);
}
- /**
- * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
- * @expectedExceptionMessage config_name setting has to be defined when FOSCKEditorBundle integration is enabled
- */
public function testInvalidCKEditorEnabledWithoutConfigName()
{
+ $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
+ $this->expectExceptionMessage('config_name setting has to be defined when FOSCKEditorBundle integration is enabled');
+
$config = $this->process($this->buildConfig(), [[
'bundles' => [
'content' => true,
diff --git a/tests/Unit/DependencyInjection/Factory/CoreAdminFactoryTest.php b/tests/Unit/DependencyInjection/Factory/CoreAdminFactoryTest.php
index 6c39c37..bf00ca2 100644
--- a/tests/Unit/DependencyInjection/Factory/CoreAdminFactoryTest.php
+++ b/tests/Unit/DependencyInjection/Factory/CoreAdminFactoryTest.php
@@ -1,9 +1,11 @@
db('PHPCR')->loadFixtures([
+ 'Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Fixtures\App\DataFixtures\Phpcr\LoadBlockData',
+ ]);
+ $this->client = $this->createClient();
+ }
+
/**
* Admin listing test case.
*/
@@ -49,17 +62,6 @@ abstract public function testBlockDelete();
*/
abstract public function testBlockShow();
- /**
- * {@inheritdoc}
- */
- public function setUp()
- {
- $this->db('PHPCR')->loadFixtures([
- 'Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Fixtures\App\DataFixtures\Phpcr\LoadBlockData',
- ]);
- $this->client = $this->createClient();
- }
-
/**
* Make defaults listing assertions.
*
diff --git a/tests/WebTest/Admin/Block/ActionBlockAdminTest.php b/tests/WebTest/Admin/Block/ActionBlockAdminTest.php
index dcc4bd8..d3ab0f1 100644
--- a/tests/WebTest/Admin/Block/ActionBlockAdminTest.php
+++ b/tests/WebTest/Admin/Block/ActionBlockAdminTest.php
@@ -1,9 +1,11 @@