From c1b727b1c8396674a78515a3a135807d039a6ca4 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 7 May 2021 16:02:39 +0200 Subject: [PATCH] Add API endpoints for Address and AddressReference (again) --- .../ChillMainExtension.php | 59 ++++++++++++++++++- .../Entity/AddressReference.php | 3 +- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index a40221263..eaf7711d3 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -35,6 +35,7 @@ use Chill\MainBundle\Doctrine\DQL\OverlapsI; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Chill\MainBundle\Doctrine\DQL\Replace; +use Symfony\Component\HttpFoundation\Request; /** * Class ChillMainExtension @@ -133,7 +134,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, $loader->load('services/search.yaml'); $loader->load('services/serializer.yaml'); - $this->configureCruds($container, $config['cruds'], $config['apis'], $loader); + $this->configureCruds($container, $config['cruds'], $config['apis'], $loader); } /** @@ -212,6 +213,9 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, $container->prependExtensionConfig('monolog', array( 'channels' => array('chill') )); + + //add crud api + $this->prependCruds($container); } /** @@ -235,4 +239,57 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, // Note: the controller are loaded inside compiler pass } + + + /** + * @param ContainerBuilder $container + */ + protected function prependCruds(ContainerBuilder $container) + { + $container->prependExtensionConfig('chill_main', [ + 'apis' => [ + [ + 'class' => \Chill\MainBundle\Entity\Address::class, + 'name' => 'address', + 'base_path' => '/api/1.0/main/address', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true + ], + ], + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_POST => true, + Request::METHOD_HEAD => true + ] + ], + ] + ], + [ + 'class' => \Chill\MainBundle\Entity\AddressReference::class, + 'name' => 'address_reference', + 'base_path' => '/api/1.0/main/address-reference', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true + ], + ], + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true + ] + ], + ] + ] + ] + ]); + } } diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index 944cab81b..b1fca205d 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -2,12 +2,11 @@ namespace Chill\MainBundle\Entity; -use Chill\MainBundle\Entity\AddressReferenceRepository; use Doctrine\ORM\Mapping as ORM; use Chill\MainBundle\Doctrine\Model\Point; /** - * @ORM\Entity(repositoryClass=AddressReferenceRepository::class) + * @ORM\Entity() * @ORM\Table(name="chill_main_address_reference") * @ORM\HasLifecycleCallbacks() */