From 454a551d0396e6bd1b0ff481f006dd728cc6bd28 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Fri, 5 Mar 2021 11:10:29 -0300 Subject: [PATCH] Use camel case for arguments and variables at `CRUDController::historyCompareRevisionsAction()` --- src/Controller/CRUDController.php | 24 +++++++++---------- .../views/CRUD/base_history.html.twig | 2 +- src/Route/PathInfoBuilder.php | 2 +- .../Type/Operator/StringOperatorTypeTest.php | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Controller/CRUDController.php b/src/Controller/CRUDController.php index fb5e04b8e97..3031c8351c1 100644 --- a/src/Controller/CRUDController.php +++ b/src/Controller/CRUDController.php @@ -842,15 +842,15 @@ public function historyViewRevisionAction($id = null, $revision = null) // NEXT_ * Compare history revisions of object. * * @param int|string|null $id - * @param int|string|null $base_revision - * @param int|string|null $compare_revision + * @param int|string|null $baseRevision + * @param int|string|null $compareRevision * * @throws AccessDeniedException If access is not granted * @throws NotFoundHttpException If the object or revision does not exist or the audit reader is not available * * @return Response */ - public function historyCompareRevisionsAction($id = null, $base_revision = null, $compare_revision = null) // NEXT_MAJOR: Remove the unused $id parameter + public function historyCompareRevisionsAction($id = null, $baseRevision = null, $compareRevision = null) // NEXT_MAJOR: Remove the unused $id parameter { $this->admin->checkAccess('historyCompareRevisions'); @@ -874,28 +874,28 @@ public function historyCompareRevisionsAction($id = null, $base_revision = null, $reader = $manager->getReader($this->admin->getClass()); // retrieve the base revision - $base_object = $reader->find($this->admin->getClass(), $id, $base_revision); - if (!$base_object) { + $baseObject = $reader->find($this->admin->getClass(), $id, $baseRevision); + if (!$baseObject) { throw $this->createNotFoundException(sprintf( 'unable to find the targeted object `%s` from the revision `%s` with classname : `%s`', $id, - $base_revision, + $baseRevision, $this->admin->getClass() )); } // retrieve the compare revision - $compare_object = $reader->find($this->admin->getClass(), $id, $compare_revision); - if (!$compare_object) { + $compareObject = $reader->find($this->admin->getClass(), $id, $compareRevision); + if (!$compareObject) { throw $this->createNotFoundException(sprintf( 'unable to find the targeted object `%s` from the revision `%s` with classname : `%s`', $id, - $compare_revision, + $compareRevision, $this->admin->getClass() )); } - $this->admin->setSubject($base_object); + $this->admin->setSubject($baseObject); // NEXT_MAJOR: Remove this line and use commented line below it instead $template = $this->admin->getTemplate('show_compare'); @@ -903,8 +903,8 @@ public function historyCompareRevisionsAction($id = null, $base_revision = null, return $this->renderWithExtraParams($template, [ 'action' => 'show', - 'object' => $base_object, - 'object_compare' => $compare_object, + 'object' => $baseObject, + 'object_compare' => $compareObject, 'elements' => $this->admin->getShow(), ], null); } diff --git a/src/Resources/views/CRUD/base_history.html.twig b/src/Resources/views/CRUD/base_history.html.twig index a83f67f32a9..0cbac4b3652 100644 --- a/src/Resources/views/CRUD/base_history.html.twig +++ b/src/Resources/views/CRUD/base_history.html.twig @@ -42,7 +42,7 @@ file that was distributed with this source code. {% if (currentRevision == false or revision.rev == currentRevision.rev) %} / {% else %} - {{ 'label_compare_revision'|trans({}, 'SonataAdminBundle') }} + {{ 'label_compare_revision'|trans({}, 'SonataAdminBundle') }} {% endif %} diff --git a/src/Route/PathInfoBuilder.php b/src/Route/PathInfoBuilder.php index 18dd09343ab..c7f12249b93 100644 --- a/src/Route/PathInfoBuilder.php +++ b/src/Route/PathInfoBuilder.php @@ -47,7 +47,7 @@ public function build(AdminInterface $admin, RouteCollection $collection) if ($this->manager->hasReader($admin->getClass())) { $collection->add('history', sprintf('%s/history', $admin->getRouterIdParameter())); $collection->add('history_view_revision', sprintf('%s/history/{revision}/view', $admin->getRouterIdParameter())); - $collection->add('history_compare_revisions', sprintf('%s/history/{base_revision}/{compare_revision}/compare', $admin->getRouterIdParameter())); + $collection->add('history_compare_revisions', sprintf('%s/history/{baseRevision}/{compareRevision}/compare', $admin->getRouterIdParameter())); } if ($admin->isAclEnabled()) { diff --git a/tests/Form/Type/Operator/StringOperatorTypeTest.php b/tests/Form/Type/Operator/StringOperatorTypeTest.php index 726989cf618..a09bb5aea5b 100644 --- a/tests/Form/Type/Operator/StringOperatorTypeTest.php +++ b/tests/Form/Type/Operator/StringOperatorTypeTest.php @@ -23,7 +23,7 @@ public function testConfigureOptions(): void { $formType = new StringOperatorType(); $optionsResolver = new OptionsResolver(); - $expected_choices = [ + $expectedChoices = [ 'label_type_contains' => StringOperatorType::TYPE_CONTAINS, 'label_type_not_contains' => StringOperatorType::TYPE_NOT_CONTAINS, 'label_type_equals' => StringOperatorType::TYPE_EQUAL, @@ -33,7 +33,7 @@ public function testConfigureOptions(): void ]; $formType->configureOptions($optionsResolver); $options = $optionsResolver->resolve([]); - $this->assertSame($expected_choices, $options['choices']); + $this->assertSame($expectedChoices, $options['choices']); $this->assertSame('SonataAdminBundle', $options['choice_translation_domain']); } }