diff --git a/.travis.yml b/.travis.yml index 2663179..f9d6ca0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,6 @@ sudo: false cache: directories: - - $HOME/.composer/cache - - bin - vendor matrix: @@ -13,12 +11,12 @@ matrix: - php: 7.1 env: - COMPOSER_FLAGS='--prefer-lowest' - - php: 7.1 + - php: 7.2 before_script: - phpenv config-rm xdebug.ini - - travis_wait 40 composer update $COMPOSER_FLAGS + - travis_wait 20 composer update $COMPOSER_FLAGS - composer validate script: - - bin/phpspec run -f pretty + - vendor/bin/phpspec run -f pretty diff --git a/CHANGELOG-2.0.md b/CHANGELOG-2.0.md index c2ab31d..00b1acb 100644 --- a/CHANGELOG-2.0.md +++ b/CHANGELOG-2.0.md @@ -1,8 +1,8 @@ # CHANGELOG for version 2.0 -## Symfony3 support +## Extended Symfony support -As of this version, both Symfony 2 and 3 are suported. +As of this version, Symfony in 2, 4 and 4 versions is suported. ## Dropped support for PHP below 7.1 diff --git a/Controller/ReorderController.php b/Controller/ReorderController.php index a74f068..e467f60 100644 --- a/Controller/ReorderController.php +++ b/Controller/ReorderController.php @@ -36,7 +36,6 @@ public function __construct(RouterInterface $router) public function moveUpAction(DataIndexerElement $element, $id, Request $request) { $this->getRepository($element)->moveUp($this->getEntity($element, $id)); - $this->flush($element); return $this->getRedirectResponse($element, $request); @@ -45,7 +44,6 @@ public function moveUpAction(DataIndexerElement $element, $id, Request $request) public function moveDownAction(DataIndexerElement $element, $id, Request $request) { $this->getRepository($element)->moveDown($this->getEntity($element, $id)); - $this->flush($element); return $this->getRedirectResponse($element, $request); @@ -61,8 +59,12 @@ private function getEntity(DataIndexerElement $element, $id) { $entity = $element->getDataIndexer()->getData($id); - if (!$entity) { - throw new NotFoundHttpException(); + if (null === $entity) { + throw new NotFoundHttpException(sprintf( + 'Entity for element "%s" with id "%s" was not found!', + $element->getId(), + $id + )); } return $entity; @@ -78,7 +80,7 @@ private function getRepository(Element $element): NestedTreeRepository private function assertCorrectRepositoryType(EntityRepository $repository): void { - if (!$repository instanceof NestedTreeRepository) { + if (false === $repository instanceof NestedTreeRepository) { throw new InvalidArgumentException( sprintf("Entity must have repository class 'NestedTreeRepository'") ); diff --git a/DependencyInjection/FSiAdminTreeExtension.php b/DependencyInjection/FSiAdminTreeExtension.php index 05a5f52..4fb35a1 100644 --- a/DependencyInjection/FSiAdminTreeExtension.php +++ b/DependencyInjection/FSiAdminTreeExtension.php @@ -11,10 +11,10 @@ namespace FSi\Bundle\AdminTreeBundle\DependencyInjection; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; class FSiAdminTreeExtension extends Extension { diff --git a/composer.json b/composer.json index 23b76c6..99a0f41 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "fsi/admin-tree-bundle", "type": "symfony-bundle", - "description": "Provides integration for fsi/admin bundle with gedmo/doctrine-extensions tree.", + "description": "Provides integration for fsi/admin-bundle with gedmo/doctrine-extensions tree.", "keywords": ["admin", "symfony", "bundle", "tree", "fsi", "gedmo", "doctrine-extensions"], "license": "MIT", "authors": [ @@ -11,30 +11,40 @@ } ], "require": { + "doctrine/orm": "^2.5.2", + "fsi/admin-bundle" : "~2.0|~3.0", + "gedmo/doctrine-extensions": "~2.4", "php": ">=7.1", - "symfony/framework-bundle" : "^2.3|^3.0|^4.0", - "fsi/admin-bundle" : "^2.0|^3.0@dev", - "gedmo/doctrine-extensions": "^2.4" + "symfony/config" : "~2.4|~3.0|~4.0", + "symfony/dependency-injection" : "^2.6.2|~3.0|~4.0", + "symfony/framework-bundle" : "~2.4|~3.0|~4.0", + "symfony/http-foundation" : "~2.4|~3.0|~4.0", + "symfony/http-kernel" : "~2.4|~3.0|~4.0", + "symfony/routing" : "~2.3|~3.0|~4.0" }, "require-dev": { - "phpspec/phpspec": "^4.0", - "phpspec/prophecy": "^1.7.2", - "fsi/datagrid": "^2.0@dev", - "fsi/datagrid-bundle": "^2.0@dev", - "fsi/datasource": "^2.0@dev", - "fsi/datasource-bundle": "^2.0@dev" + "phpspec/phpspec": "~3.4|~4.3", + "phpspec/prophecy": "^1.7.6", + "sebastian/comparator": "~3.0", + "sebastian/exporter": "~3.0" }, "config": { - "bin-dir": "bin" + "bin-dir": "vendor/bin" }, "autoload": { "psr-4": { "FSi\\Bundle\\AdminTreeBundle\\": "" } }, + "autoload-dev": { + "psr-4": { + "spec\\FSi\\Bundle\\AdminTreeBundle\\": "" + } + }, "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.0-dev", + "1.0": "1.0-dev" } } } diff --git a/spec/FSi/Bundle/AdminTreeBundle/Controller/ReorderControllerSpec.php b/spec/FSi/Bundle/AdminTreeBundle/Controller/ReorderControllerSpec.php index 06632d2..eb3fd3f 100644 --- a/spec/FSi/Bundle/AdminTreeBundle/Controller/ReorderControllerSpec.php +++ b/spec/FSi/Bundle/AdminTreeBundle/Controller/ReorderControllerSpec.php @@ -25,12 +25,12 @@ use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Router; +use Symfony\Component\Routing\RouterInterface; class ReorderControllerSpec extends ObjectBehavior { function let( - Router $router, + RouterInterface $router, CRUDElement $element, DoctrineDataIndexer $indexer, ObjectManager $om, @@ -59,7 +59,7 @@ function it_moves_up_item_when_move_up_action_called( NestedTreeRepository $repository, stdClass $category, ObjectManager $om, - Router $router, + RouterInterface $router, DoctrineDataIndexer $indexer, Request $request ) { @@ -84,7 +84,7 @@ function it_moves_down_item_when_move_down_action_called( NestedTreeRepository $repository, stdClass $category, ObjectManager $om, - Router $router, + RouterInterface $router, DoctrineDataIndexer $indexer, Request $request ) { @@ -111,11 +111,8 @@ function it_throws_runtime_exception_when_specified_entity_doesnt_exist( ) { $indexer->getData(666)->willThrow(RuntimeException::class); - $this->shouldThrow(RuntimeException::class) - ->duringMoveUpAction($element, 666, $request); - - $this->shouldThrow(RuntimeException::class) - ->duringMoveDownAction($element, 666, $request); + $this->shouldThrow(RuntimeException::class)->duringMoveUpAction($element, 666, $request); + $this->shouldThrow(RuntimeException::class)->duringMoveDownAction($element, 666, $request); } function it_throws_exception_when_entity_doesnt_have_correct_repository( @@ -128,11 +125,8 @@ function it_throws_exception_when_entity_doesnt_have_correct_repository( $indexer->getData(666)->willReturn($category); $element->getRepository()->willReturn($repository); - $this->shouldThrow(InvalidArgumentException::class) - ->duringMoveUpAction($element, 666, $request); - - $this->shouldThrow(InvalidArgumentException::class) - ->duringMoveDownAction($element, 666, $request); + $this->shouldThrow(InvalidArgumentException::class)->duringMoveUpAction($element, 666, $request); + $this->shouldThrow(InvalidArgumentException::class)->duringMoveDownAction($element, 666, $request); } function it_redirects_to_redirect_uri_parameter_after_operation(