@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | return $domainString; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return $domainString . '.' . $result->suffix()->toString(); |
|
| 89 | + return $domainString.'.'.$result->suffix()->toString(); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | protected function extractSubdomain(string $host = null): string |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | private function getPublicSuffixList(): string |
| 121 | 121 | { |
| 122 | - return $this->cacheProvider->get('suffix_list', function (ItemInterface $item) { |
|
| 123 | - $dir = __DIR__ . '/../'; |
|
| 122 | + return $this->cacheProvider->get('suffix_list', function(ItemInterface $item) { |
|
| 123 | + $dir = __DIR__.'/../'; |
|
| 124 | 124 | $filesystem = new Filesystem(); |
| 125 | - if (!$filesystem->exists($dir . $this->suffixListFilename)) { |
|
| 125 | + if (!$filesystem->exists($dir.$this->suffixListFilename)) { |
|
| 126 | 126 | throw new \LogicException( |
| 127 | 127 | 'Public suffix list file not found. Run swp:public-suffix-list:get command' |
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | - return file_get_contents($dir . $this->suffixListFilename); |
|
| 130 | + return file_get_contents($dir.$this->suffixListFilename); |
|
| 131 | 131 | }); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | class ContentPushController extends AbstractController { |
| 43 | 43 | private EventDispatcherInterface $eventDispatcher; |
| 44 | 44 | private FormFactoryInterface $formFactory; |
| 45 | - private MessageBusInterface $messageBus;//swp_multi_tenancy.tenant_context |
|
| 45 | + private MessageBusInterface $messageBus; //swp_multi_tenancy.tenant_context |
|
| 46 | 46 | private DataTransformerInterface $dataTransformer; // swp_bridge.transformer.json_to_package |
| 47 | 47 | private MediaManagerInterface $mediaManager; // swp_content_bundle.manager.media |
| 48 | 48 | private EntityManagerInterface $entityManager; // swp.object_manager.media |
| 49 | - private PackageRepository $packageRepository;//swp.repository.package |
|
| 49 | + private PackageRepository $packageRepository; //swp.repository.package |
|
| 50 | 50 | private FileProviderInterface $fileProvider; |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | ); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - throw new \Exception('Uploaded file is not valid:' . $uploadedFile->getErrorMessage()); |
|
| 125 | + throw new \Exception('Uploaded file is not valid:'.$uploadedFile->getErrorMessage()); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | return new SingleResourceResponse($form); |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | use FOS\RestBundle\Controller\Annotations\Route; |
| 42 | 42 | |
| 43 | 43 | class ContentPushController extends AbstractController { |
| 44 | - private EventDispatcherInterface $eventDispatcher; |
|
| 45 | - private FormFactoryInterface $formFactory; |
|
| 46 | - private MessageBusInterface $messageBus;//swp_multi_tenancy.tenant_context |
|
| 47 | - private DataTransformerInterface $dataTransformer; // swp_bridge.transformer.json_to_package |
|
| 48 | - private MediaManagerInterface $mediaManager; // swp_content_bundle.manager.media |
|
| 49 | - private EntityManagerInterface $entityManager; // swp.object_manager.media |
|
| 50 | - private PackageRepository $packageRepository;//swp.repository.package |
|
| 51 | - private FileProviderInterface $fileProvider; |
|
| 44 | + private EventDispatcherInterface $eventDispatcher; |
|
| 45 | + private FormFactoryInterface $formFactory; |
|
| 46 | + private MessageBusInterface $messageBus;//swp_multi_tenancy.tenant_context |
|
| 47 | + private DataTransformerInterface $dataTransformer; // swp_bridge.transformer.json_to_package |
|
| 48 | + private MediaManagerInterface $mediaManager; // swp_content_bundle.manager.media |
|
| 49 | + private EntityManagerInterface $entityManager; // swp.object_manager.media |
|
| 50 | + private PackageRepository $packageRepository;//swp.repository.package |
|
| 51 | + private FileProviderInterface $fileProvider; |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @param EventDispatcherInterface $eventDispatcher |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | * @param PackageRepository $packageRepository |
| 61 | 61 | * @param FileProviderInterface $fileProvider |
| 62 | 62 | */ |
| 63 | - public function __construct(EventDispatcherInterface $eventDispatcher, FormFactoryInterface $formFactory, |
|
| 64 | - MessageBusInterface $messageBus, |
|
| 65 | - DataTransformerInterface $dataTransformer, MediaManagerInterface $mediaManager, |
|
| 66 | - EntityManagerInterface $entityManager, PackageRepository $packageRepository, |
|
| 67 | - FileProviderInterface $fileProvider) { |
|
| 63 | + public function __construct(EventDispatcherInterface $eventDispatcher, FormFactoryInterface $formFactory, |
|
| 64 | + MessageBusInterface $messageBus, |
|
| 65 | + DataTransformerInterface $dataTransformer, MediaManagerInterface $mediaManager, |
|
| 66 | + EntityManagerInterface $entityManager, PackageRepository $packageRepository, |
|
| 67 | + FileProviderInterface $fileProvider) { |
|
| 68 | 68 | $this->eventDispatcher = $eventDispatcher; |
| 69 | 69 | $this->formFactory = $formFactory; |
| 70 | 70 | $this->messageBus = $messageBus; |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | $this->entityManager = $entityManager; |
| 74 | 74 | $this->packageRepository = $packageRepository; |
| 75 | 75 | $this->fileProvider = $fileProvider; |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @Route("/api/{version}/content/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_push") |
|
| 81 | - */ |
|
| 82 | - public function pushContentAction(Request $request, TenantContextInterface $tenantContext): SingleResourceResponseInterface { |
|
| 79 | + /** |
|
| 80 | + * @Route("/api/{version}/content/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_push") |
|
| 81 | + */ |
|
| 82 | + public function pushContentAction(Request $request, TenantContextInterface $tenantContext): SingleResourceResponseInterface { |
|
| 83 | 83 | $package = $this->dataTransformer->transform($request->getContent()); |
| 84 | 84 | $this->eventDispatcher->dispatch(new GenericEvent($package), Events::SWP_VALIDATION); |
| 85 | 85 | |
@@ -88,27 +88,27 @@ discard block |
||
| 88 | 88 | $this->messageBus->dispatch(new ContentPushMessage($currentTenant->getId(), $request->getContent())); |
| 89 | 89 | |
| 90 | 90 | return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201)); |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @Route("/api/{version}/assets/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_assets_push") |
|
| 95 | - */ |
|
| 96 | - public function pushAssetsAction(Request $request): SingleResourceResponseInterface { |
|
| 93 | + /** |
|
| 94 | + * @Route("/api/{version}/assets/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_assets_push") |
|
| 95 | + */ |
|
| 96 | + public function pushAssetsAction(Request $request): SingleResourceResponseInterface { |
|
| 97 | 97 | $form = $this->formFactory->createNamed('', MediaFileType::class); |
| 98 | 98 | $form->handleRequest($request); |
| 99 | 99 | |
| 100 | 100 | if ($form->isSubmitted() && $form->isValid()) { |
| 101 | - $mediaManager = $this->mediaManager; |
|
| 102 | - $uploadedFile = $form->getData()['media']; |
|
| 103 | - $mediaId = $request->request->get('mediaId'); |
|
| 101 | + $mediaManager = $this->mediaManager; |
|
| 102 | + $uploadedFile = $form->getData()['media']; |
|
| 103 | + $mediaId = $request->request->get('mediaId'); |
|
| 104 | 104 | |
| 105 | - if ($uploadedFile->isValid()) { |
|
| 105 | + if ($uploadedFile->isValid()) { |
|
| 106 | 106 | $fileProvider = $this->fileProvider; |
| 107 | 107 | $file = $fileProvider->getFile(ArticleMedia::handleMediaId($mediaId), $uploadedFile->guessExtension()); |
| 108 | 108 | |
| 109 | 109 | if (null === $file) { |
| 110 | - $file = $mediaManager->handleUploadedFile($uploadedFile, $mediaId); |
|
| 111 | - $this->entityManager->flush(); |
|
| 110 | + $file = $mediaManager->handleUploadedFile($uploadedFile, $mediaId); |
|
| 111 | + $this->entityManager->flush(); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | return new SingleResourceResponse( |
@@ -121,23 +121,23 @@ discard block |
||
| 121 | 121 | ], |
| 122 | 122 | new ResponseContext(201) |
| 123 | 123 | ); |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - throw new \Exception('Uploaded file is not valid:' . $uploadedFile->getErrorMessage()); |
|
| 126 | + throw new \Exception('Uploaded file is not valid:' . $uploadedFile->getErrorMessage()); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return new SingleResourceResponse($form); |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * @Route("/api/{version}/assets/{action}/{mediaId}.{extension}", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, requirements={"mediaId"=".+", "action"="get|push"}, name="swp_api_assets_get") |
|
| 134 | - */ |
|
| 135 | - public function getAssetsAction(string $mediaId, string $extension): SingleResourceResponseInterface { |
|
| 132 | + /** |
|
| 133 | + * @Route("/api/{version}/assets/{action}/{mediaId}.{extension}", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, requirements={"mediaId"=".+", "action"="get|push"}, name="swp_api_assets_get") |
|
| 134 | + */ |
|
| 135 | + public function getAssetsAction(string $mediaId, string $extension): SingleResourceResponseInterface { |
|
| 136 | 136 | $fileProvider = $this->fileProvider; |
| 137 | 137 | $file = $fileProvider->getFile(ArticleMedia::handleMediaId($mediaId), $extension); |
| 138 | 138 | |
| 139 | 139 | if (null === $file) { |
| 140 | - throw new NotFoundHttpException('Media don\'t exist in storage'); |
|
| 140 | + throw new NotFoundHttpException('Media don\'t exist in storage'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $mediaManager = $this->mediaManager; |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | 'mime_type' => MimeTypeHelper::getByExtension($file->getFileExtension()), |
| 150 | 150 | 'filemeta' => [], |
| 151 | 151 | ]); |
| 152 | - } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - protected function getPackageRepository() { |
|
| 154 | + protected function getPackageRepository() { |
|
| 155 | 155 | return $this->packageRepository; |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -41,11 +41,11 @@ |
||
| 41 | 41 | |
| 42 | 42 | protected function configureRoutes(RoutingConfigurator $routes): void |
| 43 | 43 | { |
| 44 | - $confDir = $this->getProjectDir() . '/config'; |
|
| 44 | + $confDir = $this->getProjectDir().'/config'; |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); |
|
| 48 | - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, 'glob'); |
|
| 49 | - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, 'glob'); |
|
| 47 | + $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); |
|
| 48 | + $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, 'glob'); |
|
| 49 | + $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, 'glob'); |
|
| 50 | 50 | } |
| 51 | 51 | } |
@@ -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 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | $mim = MimeTypeHelper::getByExtension($extension); |
| 50 | - $response->headers->set('Content-Type', $mim .'; charset=UTF-8'); |
|
| 50 | + $response->headers->set('Content-Type', $mim.'; charset=UTF-8'); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -50,38 +50,38 @@ |
||
| 50 | 50 | protected function execute(InputInterface $input, OutputInterface $output) |
| 51 | 51 | { |
| 52 | 52 | $dir = $this->container->getParameter('kernel.project_dir'); |
| 53 | - $path = $dir . '/' . $input->getArgument('path'); |
|
| 53 | + $path = $dir.'/'.$input->getArgument('path'); |
|
| 54 | 54 | |
| 55 | 55 | if (!file_exists($path)) { |
| 56 | - throw new \InvalidArgumentException('File ' . $path . ' doe not exist.'); |
|
| 56 | + throw new \InvalidArgumentException('File '.$path.' doe not exist.'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $output->writeln('<info>Checking file:</info> ' . $path); |
|
| 59 | + $output->writeln('<info>Checking file:</info> '.$path); |
|
| 60 | 60 | |
| 61 | 61 | $mimType = new FileBinaryMimeTypeGuesser(); |
| 62 | - $output->writeln('<info>FileBinaryMimeTypeGuesser:</info> ' . $mimType->guessMimeType($path)); |
|
| 62 | + $output->writeln('<info>FileBinaryMimeTypeGuesser:</info> '.$mimType->guessMimeType($path)); |
|
| 63 | 63 | |
| 64 | 64 | $mimType = new FileinfoMimeTypeGuesser(); |
| 65 | - $output->writeln('<info>FileinfoMimeTypeGuesser:</info> ' . $mimType->guessMimeType($path)); |
|
| 65 | + $output->writeln('<info>FileinfoMimeTypeGuesser:</info> '.$mimType->guessMimeType($path)); |
|
| 66 | 66 | |
| 67 | 67 | $mim = MimeTypes::getDefault()->guessMimeType($path); |
| 68 | - $output->writeln('<info>Default Symfony MimType:</info> ' . $mim); |
|
| 68 | + $output->writeln('<info>Default Symfony MimType:</info> '.$mim); |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | $mimByExtension = MimeTypes::getDefault()->getMimeTypes($ext = pathinfo($path, PATHINFO_EXTENSION)); |
| 72 | - $output->writeln('<info>MimType by extension:</info> ' . implode(',', $mimByExtension)); |
|
| 72 | + $output->writeln('<info>MimType by extension:</info> '.implode(',', $mimByExtension)); |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | $mimExtension = MimeTypes::getDefault()->getExtensions($mimByExtension[0]); |
| 76 | - $output->writeln('<info>Extension of mim types:</info> ' . $mimByExtension[0] . ' <info>is:</info> ' . implode(',', $mimExtension)); |
|
| 76 | + $output->writeln('<info>Extension of mim types:</info> '.$mimByExtension[0].' <info>is:</info> '.implode(',', $mimExtension)); |
|
| 77 | 77 | |
| 78 | 78 | $output->writeln('--------------- My ----------------'); |
| 79 | 79 | |
| 80 | - $output->writeln('<info>My MimTypes checker:</info> ' . \SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getByPath($path)); |
|
| 81 | - $output->writeln('<info>My Extensions by MimTypes checker:</info> ' . \SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('application/json')); |
|
| 82 | - $output->writeln('<info>My Extensions by MimTypes checker:</info> ' . \SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('application/javascript')); |
|
| 83 | - $output->writeln('<info>My Extensions by MimTypes checker:</info> ' . \SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('image/png')); |
|
| 84 | - $output->writeln('<info>My Extensions by MimTypes checker:</info> ' . \SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('image/jpeg')); |
|
| 80 | + $output->writeln('<info>My MimTypes checker:</info> '.\SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getByPath($path)); |
|
| 81 | + $output->writeln('<info>My Extensions by MimTypes checker:</info> '.\SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('application/json')); |
|
| 82 | + $output->writeln('<info>My Extensions by MimTypes checker:</info> '.\SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('application/javascript')); |
|
| 83 | + $output->writeln('<info>My Extensions by MimTypes checker:</info> '.\SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('image/png')); |
|
| 84 | + $output->writeln('<info>My Extensions by MimTypes checker:</info> '.\SWP\Bundle\CoreBundle\Util\MimeTypeHelper::getExtensionByMimeType('image/jpeg')); |
|
| 85 | 85 | |
| 86 | 86 | return 0; |
| 87 | 87 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param bool $all |
| 21 | 21 | * @return array|string |
| 22 | 22 | */ |
| 23 | - public static function getByPath(string $path, bool $all = false): array|string |
|
| 23 | + public static function getByPath(string $path, bool $all = false): array | string |
|
| 24 | 24 | { |
| 25 | 25 | $ext = pathinfo($path, PATHINFO_EXTENSION); |
| 26 | 26 | return self::getByExtension($ext, $all); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param bool $all |
| 32 | 32 | * @return array|string |
| 33 | 33 | */ |
| 34 | - public static function getByExtension(string $ext, bool $all = false): array|string |
|
| 34 | + public static function getByExtension(string $ext, bool $all = false): array | string |
|
| 35 | 35 | { |
| 36 | 36 | $mimeType = MimeTypes::getDefault(); |
| 37 | 37 | $types = $mimeType->getMimeTypes($ext); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param bool $all |
| 53 | 53 | * @return array|string |
| 54 | 54 | */ |
| 55 | - public static function getExtensionByMimeType(string $mime, bool $all = false): array|string |
|
| 55 | + public static function getExtensionByMimeType(string $mime, bool $all = false): array | string |
|
| 56 | 56 | { |
| 57 | 57 | $mimeType = MimeTypes::getDefault(); |
| 58 | 58 | $extensions = $mimeType->getExtensions($mime); |
@@ -43,53 +43,53 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | class RegistrationController extends AbstractController { |
| 45 | 45 | |
| 46 | - private SettingsManagerInterface $settingsManager; |
|
| 47 | - private ScopeContextInterface $scopeContext; |
|
| 48 | - private EmailVerifier $emailVerifier; |
|
| 49 | - private UserManagerInterface $userManager; |
|
| 50 | - private EntityManagerInterface $entityManager; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @param SettingsManagerInterface $settingsManager |
|
| 54 | - * @param ScopeContextInterface $scopeContext |
|
| 55 | - * @param EmailVerifier $emailVerifier |
|
| 56 | - * @param UserManagerInterface $userManager |
|
| 57 | - * @param EntityManagerInterface $entityManager |
|
| 58 | - */ |
|
| 59 | - public function __construct( |
|
| 60 | - SettingsManagerInterface $settingsManager, |
|
| 61 | - ScopeContextInterface $scopeContext, |
|
| 62 | - EmailVerifier $emailVerifier, |
|
| 63 | - UserManagerInterface $userManager, |
|
| 64 | - EntityManagerInterface $entityManager |
|
| 65 | - ) { |
|
| 46 | + private SettingsManagerInterface $settingsManager; |
|
| 47 | + private ScopeContextInterface $scopeContext; |
|
| 48 | + private EmailVerifier $emailVerifier; |
|
| 49 | + private UserManagerInterface $userManager; |
|
| 50 | + private EntityManagerInterface $entityManager; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @param SettingsManagerInterface $settingsManager |
|
| 54 | + * @param ScopeContextInterface $scopeContext |
|
| 55 | + * @param EmailVerifier $emailVerifier |
|
| 56 | + * @param UserManagerInterface $userManager |
|
| 57 | + * @param EntityManagerInterface $entityManager |
|
| 58 | + */ |
|
| 59 | + public function __construct( |
|
| 60 | + SettingsManagerInterface $settingsManager, |
|
| 61 | + ScopeContextInterface $scopeContext, |
|
| 62 | + EmailVerifier $emailVerifier, |
|
| 63 | + UserManagerInterface $userManager, |
|
| 64 | + EntityManagerInterface $entityManager |
|
| 65 | + ) { |
|
| 66 | 66 | $this->settingsManager = $settingsManager; |
| 67 | 67 | $this->scopeContext = $scopeContext; |
| 68 | 68 | $this->emailVerifier = $emailVerifier; |
| 69 | 69 | $this->userManager = $userManager; |
| 70 | 70 | $this->entityManager = $entityManager; |
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @FOSRoute( |
|
| 76 | - * "/api/{version}/users/register/", |
|
| 77 | - * methods={"POST"}, |
|
| 78 | - * options={"expose"=true}, |
|
| 79 | - * defaults={"version"="v2"}, |
|
| 80 | - * name="swp_api_core_register_user" |
|
| 81 | - * ) |
|
| 82 | - */ |
|
| 83 | - public function registerAction( |
|
| 84 | - Request $request, |
|
| 85 | - UserPasswordHasherInterface $userPasswordEncoder, |
|
| 86 | - UserManagerInterface $userManager, |
|
| 87 | - MailerInterface $mailer |
|
| 88 | - ) { |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @FOSRoute( |
|
| 76 | + * "/api/{version}/users/register/", |
|
| 77 | + * methods={"POST"}, |
|
| 78 | + * options={"expose"=true}, |
|
| 79 | + * defaults={"version"="v2"}, |
|
| 80 | + * name="swp_api_core_register_user" |
|
| 81 | + * ) |
|
| 82 | + */ |
|
| 83 | + public function registerAction( |
|
| 84 | + Request $request, |
|
| 85 | + UserPasswordHasherInterface $userPasswordEncoder, |
|
| 86 | + UserManagerInterface $userManager, |
|
| 87 | + MailerInterface $mailer |
|
| 88 | + ) { |
|
| 89 | 89 | try { |
| 90 | - $this->ensureThatRegistrationIsEnabled(); |
|
| 90 | + $this->ensureThatRegistrationIsEnabled(); |
|
| 91 | 91 | } catch (NotFoundHttpException $e) { |
| 92 | - return new SingleResourceResponse(null, new ResponseContext(404)); |
|
| 92 | + return new SingleResourceResponse(null, new ResponseContext(404)); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $user = $userManager->createUser(); |
@@ -98,69 +98,69 @@ discard block |
||
| 98 | 98 | $form->handleRequest($request); |
| 99 | 99 | |
| 100 | 100 | if ($form->isSubmitted() && $form->isValid()) { |
| 101 | - $user->addRole('ROLE_USER'); |
|
| 102 | - // encode the plain password |
|
| 103 | - $user->setPassword( |
|
| 104 | - $userPasswordEncoder->hashPassword( |
|
| 105 | - $user, |
|
| 106 | - $form->get('plainPassword')->getData() |
|
| 107 | - ) |
|
| 108 | - ); |
|
| 109 | - |
|
| 110 | - $entityManager = $this->entityManager; |
|
| 111 | - $entityManager->persist($user); |
|
| 112 | - $entityManager->flush(); |
|
| 113 | - |
|
| 114 | - $signatureComponents = $this->emailVerifier->getSignatureComponents('swp_user_verify_email', $user); |
|
| 115 | - $url = $signatureComponents->getSignedUrl(); |
|
| 116 | - |
|
| 117 | - $mailer->sendConfirmationEmail($user, $url); |
|
| 118 | - |
|
| 119 | - return new JsonResponse([ |
|
| 120 | - 'message' => sprintf( |
|
| 121 | - 'The user has been created successfully. |
|
| 101 | + $user->addRole('ROLE_USER'); |
|
| 102 | + // encode the plain password |
|
| 103 | + $user->setPassword( |
|
| 104 | + $userPasswordEncoder->hashPassword( |
|
| 105 | + $user, |
|
| 106 | + $form->get('plainPassword')->getData() |
|
| 107 | + ) |
|
| 108 | + ); |
|
| 109 | + |
|
| 110 | + $entityManager = $this->entityManager; |
|
| 111 | + $entityManager->persist($user); |
|
| 112 | + $entityManager->flush(); |
|
| 113 | + |
|
| 114 | + $signatureComponents = $this->emailVerifier->getSignatureComponents('swp_user_verify_email', $user); |
|
| 115 | + $url = $signatureComponents->getSignedUrl(); |
|
| 116 | + |
|
| 117 | + $mailer->sendConfirmationEmail($user, $url); |
|
| 118 | + |
|
| 119 | + return new JsonResponse([ |
|
| 120 | + 'message' => sprintf( |
|
| 121 | + 'The user has been created successfully. |
|
| 122 | 122 | An email has been sent to %s. It contains an activation link you must click to activate your account.', |
| 123 | - $user->getEmail() |
|
| 124 | - ), |
|
| 125 | - 'url' => $url, |
|
| 126 | - ]); |
|
| 123 | + $user->getEmail() |
|
| 124 | + ), |
|
| 125 | + 'url' => $url, |
|
| 126 | + ]); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @Route("/verify/email", name="swp_user_verify_email") |
|
| 134 | - */ |
|
| 135 | - public function verifyUserEmail( |
|
| 136 | - Request $request, |
|
| 137 | - GuardAuthenticatorHandler $guardHandler, |
|
| 138 | - LoginAuthenticator $authenticator |
|
| 139 | - ): Response { |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @Route("/verify/email", name="swp_user_verify_email") |
|
| 134 | + */ |
|
| 135 | + public function verifyUserEmail( |
|
| 136 | + Request $request, |
|
| 137 | + GuardAuthenticatorHandler $guardHandler, |
|
| 138 | + LoginAuthenticator $authenticator |
|
| 139 | + ): Response { |
|
| 140 | 140 | $id = (int)$request->get('id'); // retrieve the user id from the url |
| 141 | 141 | |
| 142 | 142 | if ($request->isXmlHttpRequest()) { |
| 143 | - return $this->verifyUserEmailFromPWA($id, $request); |
|
| 143 | + return $this->verifyUserEmailFromPWA($id, $request); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Verify the user id exists and is not null |
| 147 | 147 | if (null === $id) { |
| 148 | - return $this->redirectToRoute('homepage'); |
|
| 148 | + return $this->redirectToRoute('homepage'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $user = $this->userManager->find($id); |
| 152 | 152 | |
| 153 | 153 | // Ensure the user exists in persistence |
| 154 | 154 | if (null === $user) { |
| 155 | - return $this->redirectToRoute('homepage'); |
|
| 155 | + return $this->redirectToRoute('homepage'); |
|
| 156 | 156 | } |
| 157 | 157 | // validate email confirmation link, sets User::isVerified=true and persists |
| 158 | 158 | try { |
| 159 | - $this->emailVerifier->handleEmailConfirmation($request, $user); |
|
| 159 | + $this->emailVerifier->handleEmailConfirmation($request, $user); |
|
| 160 | 160 | } catch (VerifyEmailExceptionInterface $exception) { |
| 161 | - $this->addFlash('verify_email_error', $exception->getReason()); |
|
| 161 | + $this->addFlash('verify_email_error', $exception->getReason()); |
|
| 162 | 162 | |
| 163 | - return $this->redirectToRoute('homepage'); |
|
| 163 | + return $this->redirectToRoute('homepage'); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
@@ -174,63 +174,63 @@ discard block |
||
| 174 | 174 | $this->addFlash('success', 'The user has been created successfully.'); |
| 175 | 175 | |
| 176 | 176 | return $this->redirectToRoute('swp_user_registration_confirmed'); |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Tell the user his account is now confirmed. |
|
| 181 | - */ |
|
| 182 | - public function confirmedAction(Request $request) { |
|
| 179 | + /** |
|
| 180 | + * Tell the user his account is now confirmed. |
|
| 181 | + */ |
|
| 182 | + public function confirmedAction(Request $request) { |
|
| 183 | 183 | $user = $this->getUser(); |
| 184 | 184 | if (!is_object($user) || !$user instanceof UserInterface) { |
| 185 | - $this->createAccessDeniedException('This user does not have access to this section.'); |
|
| 185 | + $this->createAccessDeniedException('This user does not have access to this section.'); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | return $this->render('@SWPUser/Registration/confirmed.html.twig', [ |
| 189 | 189 | 'user' => $user, |
| 190 | 190 | ]); |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * @throws NotFoundHttpException |
|
| 195 | - */ |
|
| 196 | - private function ensureThatRegistrationIsEnabled() { |
|
| 193 | + /** |
|
| 194 | + * @throws NotFoundHttpException |
|
| 195 | + */ |
|
| 196 | + private function ensureThatRegistrationIsEnabled() { |
|
| 197 | 197 | $settingName = 'registration_enabled'; |
| 198 | 198 | $setting = $this->settingsManager->getOneSettingByName($settingName); |
| 199 | 199 | $registrationEnabled = $this->settingsManager |
| 200 | 200 | ->get($settingName, $setting['scope'], $this->scopeContext->getScopeOwner($setting['scope'])); |
| 201 | 201 | if (!$registrationEnabled) { |
| 202 | - throw new NotFoundHttpException('Registration is disabled.'); |
|
| 202 | + throw new NotFoundHttpException('Registration is disabled.'); |
|
| 203 | + } |
|
| 203 | 204 | } |
| 204 | - } |
|
| 205 | 205 | |
| 206 | - private function verifyUserEmailFromPWA(int $id, Request $request): JsonResponse { |
|
| 206 | + private function verifyUserEmailFromPWA(int $id, Request $request): JsonResponse { |
|
| 207 | 207 | // Verify the user id exists and is not null |
| 208 | 208 | if (null === $id) { |
| 209 | - return new JsonResponse( |
|
| 210 | - ['error' => 'User does not exist'] |
|
| 211 | - ); |
|
| 209 | + return new JsonResponse( |
|
| 210 | + ['error' => 'User does not exist'] |
|
| 211 | + ); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | $user = $this->userManager->find($id); |
| 215 | 215 | |
| 216 | 216 | // Ensure the user exists in persistence |
| 217 | 217 | if (null === $user) { |
| 218 | - return new JsonResponse( |
|
| 219 | - ['error' => 'User does not exist'] |
|
| 220 | - ); |
|
| 218 | + return new JsonResponse( |
|
| 219 | + ['error' => 'User does not exist'] |
|
| 220 | + ); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // validate email confirmation link, sets User::isVerified=true and persists |
| 224 | 224 | try { |
| 225 | - $this->emailVerifier->handleEmailConfirmation($request, $user); |
|
| 225 | + $this->emailVerifier->handleEmailConfirmation($request, $user); |
|
| 226 | 226 | } catch (VerifyEmailExceptionInterface $exception) { |
| 227 | - return new JsonResponse( |
|
| 228 | - ['error' => 'Registration confirmation invalid'] |
|
| 229 | - ); |
|
| 227 | + return new JsonResponse( |
|
| 228 | + ['error' => 'Registration confirmation invalid'] |
|
| 229 | + ); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | return new JsonResponse( |
| 233 | 233 | ['message' => 'The user has been created successfully.'] |
| 234 | 234 | ); |
| 235 | - } |
|
| 235 | + } |
|
| 236 | 236 | } |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | GuardAuthenticatorHandler $guardHandler, |
| 138 | 138 | LoginAuthenticator $authenticator |
| 139 | 139 | ): Response { |
| 140 | - $id = (int)$request->get('id'); // retrieve the user id from the url |
|
| 140 | + $id = (int) $request->get('id'); // retrieve the user id from the url |
|
| 141 | 141 | |
| 142 | 142 | if ($request->isXmlHttpRequest()) { |
| 143 | 143 | return $this->verifyUserEmailFromPWA($id, $request); |