@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | ), |
| 145 | 145 | Events::PACKAGE_PRE_OPTIONS); |
| 146 | 146 | } |
| 147 | - $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PRE_UPDATE]), Events::PACKAGE_PRE_UPDATE); |
|
| 147 | + $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PRE_UPDATE]), Events::PACKAGE_PRE_UPDATE); |
|
| 148 | 148 | $this->packageObjectManager->flush(); |
| 149 | - $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_POST_UPDATE]), Events::PACKAGE_POST_UPDATE); |
|
| 150 | - $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
| 149 | + $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_POST_UPDATE]), Events::PACKAGE_POST_UPDATE); |
|
| 150 | + $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
| 151 | 151 | $this->packageObjectManager->flush(); |
| 152 | 152 | |
| 153 | 153 | $this->logger->info(sprintf('Package %s was updated', $existingPackage->getGuid())); |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | ); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_PRE_CREATE]), Events::PACKAGE_PRE_CREATE); |
|
| 179 | + $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_PRE_CREATE]), Events::PACKAGE_PRE_CREATE); |
|
| 180 | 180 | $this->packageRepository->add($package); |
| 181 | - $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_POST_CREATE]), Events::PACKAGE_POST_CREATE); |
|
| 182 | - $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
| 181 | + $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_POST_CREATE]), Events::PACKAGE_POST_CREATE); |
|
| 182 | + $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
| 183 | 183 | |
| 184 | 184 | if (!empty($options)) { |
| 185 | 185 | $this->eventDispatcher->dispatch( |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | use FOS\RestBundle\Controller\Annotations\Route; |
| 43 | 43 | |
| 44 | 44 | class ContentPushController extends AbstractController { |
| 45 | - private EventDispatcherInterface $eventDispatcher; |
|
| 46 | - private FormFactoryInterface $formFactory; |
|
| 47 | - private MessageBusInterface $messageBus;//swp_multi_tenancy.tenant_context |
|
| 48 | - private DataTransformerInterface $dataTransformer; // swp_bridge.transformer.json_to_package |
|
| 49 | - private MediaManagerInterface $mediaManager; // swp_content_bundle.manager.media |
|
| 50 | - private EntityManagerInterface $entityManager; // swp.object_manager.media |
|
| 51 | - private PackageRepository $packageRepository;//swp.repository.package |
|
| 52 | - private ArticleRepositoryInterface $articleRepository;//swp.repository.article |
|
| 53 | - private FileProviderInterface $fileProvider; |
|
| 45 | + private EventDispatcherInterface $eventDispatcher; |
|
| 46 | + private FormFactoryInterface $formFactory; |
|
| 47 | + private MessageBusInterface $messageBus;//swp_multi_tenancy.tenant_context |
|
| 48 | + private DataTransformerInterface $dataTransformer; // swp_bridge.transformer.json_to_package |
|
| 49 | + private MediaManagerInterface $mediaManager; // swp_content_bundle.manager.media |
|
| 50 | + private EntityManagerInterface $entityManager; // swp.object_manager.media |
|
| 51 | + private PackageRepository $packageRepository;//swp.repository.package |
|
| 52 | + private ArticleRepositoryInterface $articleRepository;//swp.repository.article |
|
| 53 | + private FileProviderInterface $fileProvider; |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @param EventDispatcherInterface $eventDispatcher |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | * @param ArticleRepositoryInterface $articleRepository |
| 64 | 64 | * @param FileProviderInterface $fileProvider |
| 65 | 65 | */ |
| 66 | - public function __construct( |
|
| 67 | - EventDispatcherInterface $eventDispatcher, |
|
| 68 | - FormFactoryInterface $formFactory, |
|
| 69 | - MessageBusInterface $messageBus, |
|
| 70 | - DataTransformerInterface $dataTransformer, |
|
| 71 | - MediaManagerInterface $mediaManager, |
|
| 72 | - EntityManagerInterface $entityManager, |
|
| 73 | - PackageRepository $packageRepository, |
|
| 74 | - ArticleRepositoryInterface $articleRepository, |
|
| 75 | - FileProviderInterface $fileProvider |
|
| 76 | - ) { |
|
| 66 | + public function __construct( |
|
| 67 | + EventDispatcherInterface $eventDispatcher, |
|
| 68 | + FormFactoryInterface $formFactory, |
|
| 69 | + MessageBusInterface $messageBus, |
|
| 70 | + DataTransformerInterface $dataTransformer, |
|
| 71 | + MediaManagerInterface $mediaManager, |
|
| 72 | + EntityManagerInterface $entityManager, |
|
| 73 | + PackageRepository $packageRepository, |
|
| 74 | + ArticleRepositoryInterface $articleRepository, |
|
| 75 | + FileProviderInterface $fileProvider |
|
| 76 | + ) { |
|
| 77 | 77 | $this->eventDispatcher = $eventDispatcher; |
| 78 | 78 | $this->formFactory = $formFactory; |
| 79 | 79 | $this->messageBus = $messageBus; |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | $this->packageRepository = $packageRepository; |
| 84 | 84 | $this->articleRepository = $articleRepository; |
| 85 | 85 | $this->fileProvider = $fileProvider; |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @Route("/api/{version}/content/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_push") |
|
| 91 | - */ |
|
| 92 | - public function pushContentAction(Request $request, TenantContextInterface $tenantContext): SingleResourceResponseInterface { |
|
| 89 | + /** |
|
| 90 | + * @Route("/api/{version}/content/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_push") |
|
| 91 | + */ |
|
| 92 | + public function pushContentAction(Request $request, TenantContextInterface $tenantContext): SingleResourceResponseInterface { |
|
| 93 | 93 | $package = $this->dataTransformer->transform($request->getContent()); |
| 94 | 94 | $this->eventDispatcher->dispatch(new GenericEvent($package), Events::SWP_VALIDATION); |
| 95 | 95 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201)); |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -139,25 +139,25 @@ discard block |
||
| 139 | 139 | ); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * @Route("/api/{version}/assets/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_assets_push") |
|
| 144 | - */ |
|
| 145 | - public function pushAssetsAction(Request $request): SingleResourceResponseInterface { |
|
| 142 | + /** |
|
| 143 | + * @Route("/api/{version}/assets/push", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_assets_push") |
|
| 144 | + */ |
|
| 145 | + public function pushAssetsAction(Request $request): SingleResourceResponseInterface { |
|
| 146 | 146 | $form = $this->formFactory->createNamed('', MediaFileType::class); |
| 147 | 147 | $form->handleRequest($request); |
| 148 | 148 | |
| 149 | 149 | if ($form->isSubmitted() && $form->isValid()) { |
| 150 | - $mediaManager = $this->mediaManager; |
|
| 151 | - $uploadedFile = $form->getData()['media']; |
|
| 152 | - $mediaId = $request->request->get('mediaId'); |
|
| 150 | + $mediaManager = $this->mediaManager; |
|
| 151 | + $uploadedFile = $form->getData()['media']; |
|
| 152 | + $mediaId = $request->request->get('mediaId'); |
|
| 153 | 153 | |
| 154 | - if ($uploadedFile->isValid()) { |
|
| 154 | + if ($uploadedFile->isValid()) { |
|
| 155 | 155 | $fileProvider = $this->fileProvider; |
| 156 | 156 | $file = $fileProvider->getFile(ArticleMedia::handleMediaId($mediaId), $uploadedFile->guessExtension()); |
| 157 | 157 | |
| 158 | 158 | if (null === $file) { |
| 159 | - $file = $mediaManager->handleUploadedFile($uploadedFile, $mediaId); |
|
| 160 | - $this->entityManager->flush(); |
|
| 159 | + $file = $mediaManager->handleUploadedFile($uploadedFile, $mediaId); |
|
| 160 | + $this->entityManager->flush(); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | return new SingleResourceResponse( |
@@ -170,23 +170,23 @@ discard block |
||
| 170 | 170 | ], |
| 171 | 171 | new ResponseContext(201) |
| 172 | 172 | ); |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - throw new \Exception('Uploaded file is not valid:' . $uploadedFile->getErrorMessage()); |
|
| 175 | + throw new \Exception('Uploaded file is not valid:' . $uploadedFile->getErrorMessage()); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return new SingleResourceResponse($form); |
| 179 | - } |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * @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") |
|
| 183 | - */ |
|
| 184 | - public function getAssetsAction(string $mediaId, string $extension): SingleResourceResponseInterface { |
|
| 181 | + /** |
|
| 182 | + * @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") |
|
| 183 | + */ |
|
| 184 | + public function getAssetsAction(string $mediaId, string $extension): SingleResourceResponseInterface { |
|
| 185 | 185 | $fileProvider = $this->fileProvider; |
| 186 | 186 | $file = $fileProvider->getFile(ArticleMedia::handleMediaId($mediaId), $extension); |
| 187 | 187 | |
| 188 | 188 | if (null === $file) { |
| 189 | - throw new NotFoundHttpException('Media don\'t exist in storage'); |
|
| 189 | + throw new NotFoundHttpException('Media don\'t exist in storage'); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $mediaManager = $this->mediaManager; |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | 'mime_type' => MimeTypeHelper::getByExtension($file->getFileExtension()), |
| 199 | 199 | 'filemeta' => [], |
| 200 | 200 | ]); |
| 201 | - } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - protected function getPackageRepository() { |
|
| 203 | + protected function getPackageRepository() { |
|
| 204 | 204 | return $this->packageRepository; |
| 205 | - } |
|
| 205 | + } |
|
| 206 | 206 | } |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | class ContentPushController extends AbstractController { |
| 45 | 45 | private EventDispatcherInterface $eventDispatcher; |
| 46 | 46 | private FormFactoryInterface $formFactory; |
| 47 | - private MessageBusInterface $messageBus;//swp_multi_tenancy.tenant_context |
|
| 47 | + private MessageBusInterface $messageBus; //swp_multi_tenancy.tenant_context |
|
| 48 | 48 | private DataTransformerInterface $dataTransformer; // swp_bridge.transformer.json_to_package |
| 49 | 49 | private MediaManagerInterface $mediaManager; // swp_content_bundle.manager.media |
| 50 | 50 | private EntityManagerInterface $entityManager; // swp.object_manager.media |
| 51 | - private PackageRepository $packageRepository;//swp.repository.package |
|
| 52 | - private ArticleRepositoryInterface $articleRepository;//swp.repository.article |
|
| 51 | + private PackageRepository $packageRepository; //swp.repository.package |
|
| 52 | + private ArticleRepositoryInterface $articleRepository; //swp.repository.article |
|
| 53 | 53 | private FileProviderInterface $fileProvider; |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | ); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - throw new \Exception('Uploaded file is not valid:' . $uploadedFile->getErrorMessage()); |
|
| 175 | + throw new \Exception('Uploaded file is not valid:'.$uploadedFile->getErrorMessage()); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return new SingleResourceResponse($form); |