From 4bd50d014813b7f7215c6ff321bd531bd97d6eb9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Feb 2022 15:31:24 +0100 Subject: [PATCH] fix code style for AccompanyingPeriodWorkEvaluation --- .../ChillDocStoreExtension.php | 42 +++++++++---------- .../Normalizer/StoredObjectDenormalizer.php | 12 +++--- ...anyingPeriodWorkEvaluationDenormalizer.php | 5 +-- .../migrations/Version20220224145951.php | 12 +++--- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php b/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php index 01ce4d9f7..957624702 100644 --- a/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php +++ b/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php @@ -50,6 +50,27 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf $this->prependApis($container); } + protected function prependApis(ContainerBuilder $container) + { + $container->prependExtensionConfig('chill_main', [ + 'apis' => [ + [ + 'class' => \Chill\DocStoreBundle\Entity\StoredObject::class, + 'name' => 'stored_object', + 'base_path' => '/api/1.0/docstore/stored-object', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_POST => true, + ], + ], + ], + ], + ], + ]); + } + protected function prependAuthorization(ContainerBuilder $container) { $container->prependExtensionConfig('security', [ @@ -86,25 +107,4 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf ]; $container->prependExtensionConfig('twig', $twigConfig); } - - protected function prependApis(ContainerBuilder $container) - { - $container->prependExtensionConfig('chill_main', [ - 'apis' => [ - [ - 'class' => \Chill\DocStoreBundle\Entity\StoredObject::class, - 'name' => 'stored_object', - 'base_path' => '/api/1.0/docstore/stored-object', - 'base_role' => 'ROLE_USER', - 'actions' => [ - '_entity' => [ - 'methods' => [ - Request::METHOD_POST => true, - ], - ], - ], - ], - ] - ]); - } } diff --git a/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php b/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php index 5bc5515b5..762aed7fb 100644 --- a/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php +++ b/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php @@ -15,9 +15,11 @@ use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Repository\StoredObjectRepository; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use function array_key_exists; +use function is_array; -class StoredObjectDenormalizer implements DenormalizerInterface { - +class StoredObjectDenormalizer implements DenormalizerInterface +{ private StoredObjectRepository $storedObjectRepository; public function __construct(StoredObjectRepository $storedObjectRepository) @@ -44,8 +46,6 @@ class StoredObjectDenormalizer implements DenormalizerInterface { return false; } - return $type === StoredObject::class; - + return StoredObject::class === $type; } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php index 9190243de..12bd254c5 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php @@ -33,7 +33,6 @@ use function is_array; class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenormalizerInterface, DenormalizerAwareInterface { use DenormalizerAwareTrait; - use ObjectToPopulateTrait; private EntityManagerInterface $em; @@ -56,7 +55,7 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm )); //if (in_array('accompanying_period_work:edit', $context['groups'] ?? [], true)) { - $this->handleEvaluationCollection($data, $evaluation, $format, $context); + $this->handleEvaluationCollection($data, $evaluation, $format, $context); //} return $evaluation; @@ -102,7 +101,7 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm } // handle the documents kept foreach ($kept as $k) { - dump($k);// Cannot iterate over $kept which is a PersistentCollection + dump($k); // Cannot iterate over $kept which is a PersistentCollection $evaluation->removeDocument($k); dump($evaluation); $document = $this->denormalizer->denormalize( diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220224145951.php b/src/Bundle/ChillPersonBundle/migrations/Version20220224145951.php index 13fb91d4f..e71174eea 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220224145951.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220224145951.php @@ -15,10 +15,15 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Add title to AccompanyingPeriodWorkEvaluationDocument + * Add title to AccompanyingPeriodWorkEvaluationDocument. */ final class Version20220224145951 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP title'); + } + public function getDescription(): string { return 'Add title to AccompanyingPeriodWorkEvaluationDocument'; @@ -28,9 +33,4 @@ final class Version20220224145951 extends AbstractMigration { $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD title TEXT DEFAULT NULL'); } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP title'); - } }