@@ -27,73 +27,73 @@ |
||
| 27 | 27 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
| 28 | 28 | |
| 29 | 29 | class WebhookController extends AbstractAPIController { |
| 30 | - private WebhookRepositoryInterface $webhookRepository; |
|
| 31 | - private FormFactoryInterface $formFactory; |
|
| 32 | - private FactoryInterface $webhookFactory; |
|
| 33 | - private EntityManagerInterface $entityManager; |
|
| 34 | - private EventDispatcherInterface $eventDispatcher; |
|
| 30 | + private WebhookRepositoryInterface $webhookRepository; |
|
| 31 | + private FormFactoryInterface $formFactory; |
|
| 32 | + private FactoryInterface $webhookFactory; |
|
| 33 | + private EntityManagerInterface $entityManager; |
|
| 34 | + private EventDispatcherInterface $eventDispatcher; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param WebhookRepositoryInterface $webhookRepository |
|
| 38 | - * @param FormFactoryInterface $formFactory |
|
| 39 | - * @param FactoryInterface $webhookFactory |
|
| 40 | - * @param EntityManagerInterface $entityManager |
|
| 41 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 42 | - */ |
|
| 43 | - public function __construct(WebhookRepositoryInterface $webhookRepository, FormFactoryInterface $formFactory, |
|
| 44 | - FactoryInterface $webhookFactory, EntityManagerInterface $entityManager, |
|
| 45 | - EventDispatcherInterface $eventDispatcher) { |
|
| 36 | + /** |
|
| 37 | + * @param WebhookRepositoryInterface $webhookRepository |
|
| 38 | + * @param FormFactoryInterface $formFactory |
|
| 39 | + * @param FactoryInterface $webhookFactory |
|
| 40 | + * @param EntityManagerInterface $entityManager |
|
| 41 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 42 | + */ |
|
| 43 | + public function __construct(WebhookRepositoryInterface $webhookRepository, FormFactoryInterface $formFactory, |
|
| 44 | + FactoryInterface $webhookFactory, EntityManagerInterface $entityManager, |
|
| 45 | + EventDispatcherInterface $eventDispatcher) { |
|
| 46 | 46 | $this->webhookRepository = $webhookRepository; |
| 47 | 47 | $this->formFactory = $formFactory; |
| 48 | 48 | $this->webhookFactory = $webhookFactory; |
| 49 | 49 | $this->entityManager = $entityManager; |
| 50 | 50 | $this->eventDispatcher = $eventDispatcher; |
| 51 | - } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_webhook") |
|
| 56 | - */ |
|
| 57 | - public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 54 | + /** |
|
| 55 | + * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_webhook") |
|
| 56 | + */ |
|
| 57 | + public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 58 | 58 | return $this->listWebhooks($this->eventDispatcher,$this->webhookRepository, $request); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @Route("/api/{version}/webhooks/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_webhook") |
|
| 63 | - */ |
|
| 64 | - public function getAction(int $id): SingleResourceResponseInterface { |
|
| 61 | + /** |
|
| 62 | + * @Route("/api/{version}/webhooks/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_webhook") |
|
| 63 | + */ |
|
| 64 | + public function getAction(int $id): SingleResourceResponseInterface { |
|
| 65 | 65 | return $this->getSingleWebhook($this->findOr404($id)); |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_webhook") |
|
| 70 | - */ |
|
| 71 | - public function createAction(Request $request): SingleResourceResponseInterface { |
|
| 68 | + /** |
|
| 69 | + * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_webhook") |
|
| 70 | + */ |
|
| 71 | + public function createAction(Request $request): SingleResourceResponseInterface { |
|
| 72 | 72 | $ruleRepository = $this->webhookRepository; |
| 73 | 73 | $ruleFactory = $this->webhookFactory; |
| 74 | 74 | $formFactory = $this->formFactory; |
| 75 | 75 | |
| 76 | 76 | return $this->createWebhook($ruleRepository, $ruleFactory, $request, $formFactory); |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_webhook", requirements={"id"="\d+"}) |
|
| 81 | - */ |
|
| 82 | - public function deleteAction(int $id): SingleResourceResponseInterface { |
|
| 79 | + /** |
|
| 80 | + * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_webhook", requirements={"id"="\d+"}) |
|
| 81 | + */ |
|
| 82 | + public function deleteAction(int $id): SingleResourceResponseInterface { |
|
| 83 | 83 | $webhookRepository = $this->webhookRepository; |
| 84 | 84 | |
| 85 | 85 | return $this->deleteWebhook($webhookRepository, $this->findOr404($id)); |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_webhook", requirements={"id"="\d+"}) |
|
| 90 | - */ |
|
| 91 | - public function updateAction(Request $request, int $id): SingleResourceResponseInterface { |
|
| 88 | + /** |
|
| 89 | + * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_webhook", requirements={"id"="\d+"}) |
|
| 90 | + */ |
|
| 91 | + public function updateAction(Request $request, int $id): SingleResourceResponseInterface { |
|
| 92 | 92 | $objectManager = $this->entityManager; |
| 93 | 93 | $formFactory = $this->formFactory; |
| 94 | 94 | |
| 95 | 95 | return $this->updateWebhook($objectManager, $request, $this->findOr404($id), $formFactory); |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | private function findOr404(int $id) |
| 99 | 99 | { |
@@ -35,39 +35,39 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | class PublishDestinationController extends Controller { |
| 37 | 37 | |
| 38 | - private FormFactoryInterface $formFactory; |
|
| 39 | - private EventDispatcherInterface $eventDispatcher; |
|
| 40 | - private CachedTenantContextInterface $cachedTenantContext; |
|
| 41 | - private RepositoryInterface $publishDestinationRepository; |
|
| 42 | - private EntityManagerInterface $entityManager; |
|
| 43 | - private FactoryInterface $publishDestinationFactory; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @param FormFactoryInterface $formFactory |
|
| 47 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 48 | - * @param CachedTenantContextInterface $cachedTenantContext |
|
| 49 | - * @param RepositoryInterface $publishDestinationRepository |
|
| 50 | - * @param EntityManagerInterface $entityManager |
|
| 51 | - * @param FactoryInterface $publishDestinationFactory |
|
| 52 | - */ |
|
| 53 | - public function __construct(FormFactoryInterface $formFactory, |
|
| 54 | - EventDispatcherInterface $eventDispatcher, |
|
| 55 | - CachedTenantContextInterface $cachedTenantContext, |
|
| 56 | - RepositoryInterface $publishDestinationRepository, |
|
| 57 | - EntityManagerInterface $entityManager, |
|
| 58 | - FactoryInterface $publishDestinationFactory) { |
|
| 38 | + private FormFactoryInterface $formFactory; |
|
| 39 | + private EventDispatcherInterface $eventDispatcher; |
|
| 40 | + private CachedTenantContextInterface $cachedTenantContext; |
|
| 41 | + private RepositoryInterface $publishDestinationRepository; |
|
| 42 | + private EntityManagerInterface $entityManager; |
|
| 43 | + private FactoryInterface $publishDestinationFactory; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param FormFactoryInterface $formFactory |
|
| 47 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 48 | + * @param CachedTenantContextInterface $cachedTenantContext |
|
| 49 | + * @param RepositoryInterface $publishDestinationRepository |
|
| 50 | + * @param EntityManagerInterface $entityManager |
|
| 51 | + * @param FactoryInterface $publishDestinationFactory |
|
| 52 | + */ |
|
| 53 | + public function __construct(FormFactoryInterface $formFactory, |
|
| 54 | + EventDispatcherInterface $eventDispatcher, |
|
| 55 | + CachedTenantContextInterface $cachedTenantContext, |
|
| 56 | + RepositoryInterface $publishDestinationRepository, |
|
| 57 | + EntityManagerInterface $entityManager, |
|
| 58 | + FactoryInterface $publishDestinationFactory) { |
|
| 59 | 59 | $this->formFactory = $formFactory; |
| 60 | 60 | $this->eventDispatcher = $eventDispatcher; |
| 61 | 61 | $this->cachedTenantContext = $cachedTenantContext; |
| 62 | 62 | $this->publishDestinationRepository = $publishDestinationRepository; |
| 63 | 63 | $this->entityManager = $entityManager; |
| 64 | 64 | $this->publishDestinationFactory = $publishDestinationFactory; |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @Route("/api/{version}/organization/destinations/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_publishing_destination_create") |
|
| 69 | - */ |
|
| 70 | - public function createAction(Request $request): SingleResourceResponse { |
|
| 67 | + /** |
|
| 68 | + * @Route("/api/{version}/organization/destinations/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_publishing_destination_create") |
|
| 69 | + */ |
|
| 70 | + public function createAction(Request $request): SingleResourceResponse { |
|
| 71 | 71 | $tenantContext = $this->cachedTenantContext; |
| 72 | 72 | |
| 73 | 73 | $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE); |
@@ -78,26 +78,26 @@ discard block |
||
| 78 | 78 | $form->handleRequest($request); |
| 79 | 79 | |
| 80 | 80 | if ($form->isSubmitted() && $form->isValid()) { |
| 81 | - $repository = $this->publishDestinationRepository; |
|
| 82 | - /** @var PublishDestinationInterface $publishDestination */ |
|
| 83 | - $publishDestination = $repository->findOneByTenant($destination->getTenant()); |
|
| 84 | - if (null !== $publishDestination) { |
|
| 81 | + $repository = $this->publishDestinationRepository; |
|
| 82 | + /** @var PublishDestinationInterface $publishDestination */ |
|
| 83 | + $publishDestination = $repository->findOneByTenant($destination->getTenant()); |
|
| 84 | + if (null !== $publishDestination) { |
|
| 85 | 85 | $repository->remove($publishDestination); |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - $currentOrganization->addPublishDestination($destination); |
|
| 89 | - $this->entityManager->flush(); |
|
| 88 | + $currentOrganization->addPublishDestination($destination); |
|
| 89 | + $this->entityManager->flush(); |
|
| 90 | 90 | |
| 91 | - return new SingleResourceResponse($destination, new ResponseContext(200)); |
|
| 91 | + return new SingleResourceResponse($destination, new ResponseContext(200)); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 95 | - } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * @Route("/api/{version}/organization/destinations/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_publishing_destination_update", requirements={"id"="\d+"}) |
|
| 99 | - */ |
|
| 100 | - public function updateAction(Request $request, $id): SingleResourceResponse { |
|
| 97 | + /** |
|
| 98 | + * @Route("/api/{version}/organization/destinations/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_publishing_destination_update", requirements={"id"="\d+"}) |
|
| 99 | + */ |
|
| 100 | + public function updateAction(Request $request, $id): SingleResourceResponse { |
|
| 101 | 101 | $objectManager = $this->entityManager; |
| 102 | 102 | $publishDestination = $this->findOr404($id); |
| 103 | 103 | |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $form->handleRequest($request); |
| 112 | 112 | if ($form->isSubmitted() && $form->isValid()) { |
| 113 | - $objectManager->flush(); |
|
| 114 | - $objectManager->refresh($publishDestination); |
|
| 113 | + $objectManager->flush(); |
|
| 114 | + $objectManager->refresh($publishDestination); |
|
| 115 | 115 | |
| 116 | - return new SingleResourceResponse($publishDestination); |
|
| 116 | + return new SingleResourceResponse($publishDestination); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 120 | - } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | private function findOr404(int $id) |
| 123 | 123 | { |
@@ -32,83 +32,83 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | class RuleController extends FOSRestController { |
| 34 | 34 | |
| 35 | - private FormFactoryInterface $formFactory; |
|
| 36 | - private EntityManagerInterface $entityManager; |
|
| 37 | - private RuleRepositoryInterface $ruleRepository; |
|
| 38 | - private FactoryInterface $ruleFactory; |
|
| 39 | - private EventDispatcherInterface $eventDispatcher; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param FormFactoryInterface $formFactory |
|
| 43 | - * @param EntityManagerInterface $entityManager |
|
| 44 | - * @param RuleRepositoryInterface $ruleRepository |
|
| 45 | - * @param FactoryInterface $ruleFactory |
|
| 46 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 47 | - */ |
|
| 48 | - public function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, |
|
| 49 | - RuleRepositoryInterface $ruleRepository, FactoryInterface $ruleFactory, |
|
| 50 | - EventDispatcherInterface $eventDispatcher) { |
|
| 35 | + private FormFactoryInterface $formFactory; |
|
| 36 | + private EntityManagerInterface $entityManager; |
|
| 37 | + private RuleRepositoryInterface $ruleRepository; |
|
| 38 | + private FactoryInterface $ruleFactory; |
|
| 39 | + private EventDispatcherInterface $eventDispatcher; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param FormFactoryInterface $formFactory |
|
| 43 | + * @param EntityManagerInterface $entityManager |
|
| 44 | + * @param RuleRepositoryInterface $ruleRepository |
|
| 45 | + * @param FactoryInterface $ruleFactory |
|
| 46 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 47 | + */ |
|
| 48 | + public function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, |
|
| 49 | + RuleRepositoryInterface $ruleRepository, FactoryInterface $ruleFactory, |
|
| 50 | + EventDispatcherInterface $eventDispatcher) { |
|
| 51 | 51 | $this->formFactory = $formFactory; |
| 52 | 52 | $this->entityManager = $entityManager; |
| 53 | 53 | $this->ruleRepository = $ruleRepository; |
| 54 | 54 | $this->ruleFactory = $ruleFactory; |
| 55 | 55 | $this->eventDispatcher = $eventDispatcher; |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_rule") |
|
| 61 | - */ |
|
| 62 | - public function listAction(Request $request) { |
|
| 59 | + /** |
|
| 60 | + * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_rule") |
|
| 61 | + */ |
|
| 62 | + public function listAction(Request $request) { |
|
| 63 | 63 | $rules = $this->ruleRepository |
| 64 | 64 | ->getPaginatedByCriteria($this->eventDispatcher, new Criteria(), $request->query->all('sorting'), new PaginationData($request)); |
| 65 | 65 | |
| 66 | 66 | if (0 === $rules->count()) { |
| 67 | - throw new NotFoundHttpException('No rules were found.'); |
|
| 67 | + throw new NotFoundHttpException('No rules were found.'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return new ResourcesListResponse($rules); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @Route("/api/{version}/rules/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_rule") |
|
| 75 | - */ |
|
| 76 | - public function getAction(int $id) { |
|
| 73 | + /** |
|
| 74 | + * @Route("/api/{version}/rules/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_rule") |
|
| 75 | + */ |
|
| 76 | + public function getAction(int $id) { |
|
| 77 | 77 | return new SingleResourceResponse($this->findOr404($id)); |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_rule") |
|
| 82 | - */ |
|
| 83 | - public function createAction(Request $request) { |
|
| 80 | + /** |
|
| 81 | + * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_rule") |
|
| 82 | + */ |
|
| 83 | + public function createAction(Request $request) { |
|
| 84 | 84 | $ruleRepository = $this->ruleRepository; |
| 85 | 85 | $rule = $this->ruleFactory->create(); |
| 86 | 86 | $form = $this->formFactory->createNamed('', RuleType::class, $rule); |
| 87 | 87 | $form->handleRequest($request); |
| 88 | 88 | |
| 89 | 89 | if ($form->isSubmitted() && $form->isValid()) { |
| 90 | - $ruleRepository->add($rule); |
|
| 90 | + $ruleRepository->add($rule); |
|
| 91 | 91 | |
| 92 | - return new SingleResourceResponse($rule, new ResponseContext(201)); |
|
| 92 | + return new SingleResourceResponse($rule, new ResponseContext(201)); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_rule", methods={"DELETE"}, requirements={"id"="\d+"}) |
|
| 100 | - */ |
|
| 101 | - public function deleteAction(int $id) { |
|
| 98 | + /** |
|
| 99 | + * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_rule", methods={"DELETE"}, requirements={"id"="\d+"}) |
|
| 100 | + */ |
|
| 101 | + public function deleteAction(int $id) { |
|
| 102 | 102 | $ruleRepository = $this->ruleRepository; |
| 103 | 103 | $ruleRepository->remove($this->findOr404($id)); |
| 104 | 104 | |
| 105 | 105 | return new SingleResourceResponse(null, new ResponseContext(204)); |
| 106 | - } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_rule", requirements={"id"="\d+"}) |
|
| 110 | - */ |
|
| 111 | - public function updateAction(Request $request, int $id) { |
|
| 108 | + /** |
|
| 109 | + * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_rule", requirements={"id"="\d+"}) |
|
| 110 | + */ |
|
| 111 | + public function updateAction(Request $request, int $id) { |
|
| 112 | 112 | $rule = $this->findOr404($id); |
| 113 | 113 | $objectManager = $this->entityManager; |
| 114 | 114 | |
@@ -118,21 +118,21 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $form->handleRequest($request); |
| 120 | 120 | if ($form->isSubmitted() && $form->isValid()) { |
| 121 | - $objectManager->flush(); |
|
| 122 | - $objectManager->refresh($rule); |
|
| 121 | + $objectManager->flush(); |
|
| 122 | + $objectManager->refresh($rule); |
|
| 123 | 123 | |
| 124 | - return new SingleResourceResponse($rule); |
|
| 124 | + return new SingleResourceResponse($rule); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 128 | - } |
|
| 129 | - |
|
| 130 | - private function findOr404(int $id) |
|
| 131 | - { |
|
| 132 | - $rule = $this->ruleRepository->findOneBy(['id' => $id]); |
|
| 133 | - if (null === ($rule)) { |
|
| 134 | - throw new NotFoundHttpException('Rule was not found.'); |
|
| 135 | - } |
|
| 136 | - return $rule; |
|
| 137 | - } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + private function findOr404(int $id) |
|
| 131 | + { |
|
| 132 | + $rule = $this->ruleRepository->findOneBy(['id' => $id]); |
|
| 133 | + if (null === ($rule)) { |
|
| 134 | + throw new NotFoundHttpException('Rule was not found.'); |
|
| 135 | + } |
|
| 136 | + return $rule; |
|
| 137 | + } |
|
| 138 | 138 | } |