@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | { |
334 | 334 | return $this->getExtraCollection() |
335 | 335 | ->map( |
336 | - function (ArticleExtraFieldInterface $field) { |
|
336 | + function(ArticleExtraFieldInterface $field) { |
|
337 | 337 | return $field->toApiFormat(); |
338 | 338 | } |
339 | 339 | )->toArray(); |
@@ -536,8 +536,8 @@ discard block |
||
536 | 536 | if (is_array($value)) { |
537 | 537 | $this->addEmbedExtra(ArticleExtraEmbedField::newFromValue($key, $value)); |
538 | 538 | } else { |
539 | - if(is_int($value)) { |
|
540 | - $value = (string)$value; |
|
539 | + if (is_int($value)) { |
|
540 | + $value = (string) $value; |
|
541 | 541 | } |
542 | 542 | $this->addTextExtra(ArticleExtraTextField::newFromValue($key, $value)); |
543 | 543 | } |
@@ -691,7 +691,7 @@ |
||
691 | 691 | */ |
692 | 692 | public function isCurrent(): bool |
693 | 693 | { |
694 | - return ($this->isCurrent?true:false); |
|
694 | + return ($this->isCurrent ?true:false); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -17,7 +17,7 @@ |
||
17 | 17 | { |
18 | 18 | // this up() migration is auto-generated, please modify it to your needs |
19 | 19 | $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
20 | - $this->addSql('ALTER TABLE swp_article ADD COLUMN IF NOT EXISTS feature_media INT DEFAULT NULL'); |
|
20 | + $this->addSql('ALTER TABLE swp_article ADD COLUMN IF NOT EXISTS feature_media INT DEFAULT NULL'); |
|
21 | 21 | $this->addSql('ALTER TABLE swp_article ADD CONSTRAINT FK_FB21E858A372AB05 FOREIGN KEY (feature_media) REFERENCES swp_article_media (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE'); |
22 | 22 | $this->addSql('CREATE INDEX IDX_FB21E858A372AB05 ON swp_article (feature_media)'); |
23 | 23 | } |
@@ -31,18 +31,18 @@ |
||
31 | 31 | |
32 | 32 | public function execute(InputInterface $input, OutputInterface $output) |
33 | 33 | { |
34 | - $output->writeln('<info>Fetching data from </info> ' . $this->suffixListEndpoint); |
|
34 | + $output->writeln('<info>Fetching data from </info> '.$this->suffixListEndpoint); |
|
35 | 35 | $filesystem = new Filesystem(); |
36 | - $dir = $this->container->getParameter('kernel.project_dir') . '/src/SWP/Component/MultiTenancy/'; |
|
37 | - if ($filesystem->exists($dir . $this->suffixListFilename)) { |
|
38 | - $filesystem->remove($dir . $this->suffixListFilename); |
|
36 | + $dir = $this->container->getParameter('kernel.project_dir').'/src/SWP/Component/MultiTenancy/'; |
|
37 | + if ($filesystem->exists($dir.$this->suffixListFilename)) { |
|
38 | + $filesystem->remove($dir.$this->suffixListFilename); |
|
39 | 39 | } |
40 | 40 | $filesystem->mkdir($dir); |
41 | - $filesystem->touch($dir . $this->suffixListFilename); |
|
41 | + $filesystem->touch($dir.$this->suffixListFilename); |
|
42 | 42 | $data = file_get_contents($this->suffixListEndpoint); |
43 | - $filesystem->dumpFile($dir . $this->suffixListFilename, $data); |
|
43 | + $filesystem->dumpFile($dir.$this->suffixListFilename, $data); |
|
44 | 44 | |
45 | - $output->writeln('<info>Data saved into:</info> ' . $dir . $this->suffixListFilename); |
|
45 | + $output->writeln('<info>Data saved into:</info> '.$dir.$this->suffixListFilename); |
|
46 | 46 | return 0; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | public function generateUrl(FileInterface $file, string $basePath): string |
27 | 27 | { |
28 | - $key = $basePath . '/' . $file->getAssetId() . '.' . $file->getFileExtension(); |
|
29 | - return 'https://storage.googleapis.com/' . $this->bucket->name() . '/' . $key; |
|
28 | + $key = $basePath.'/'.$file->getAssetId().'.'.$file->getFileExtension(); |
|
29 | + return 'https://storage.googleapis.com/'.$this->bucket->name().'/'.$key; |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public static function createGCSClient(ContainerInterface $container, string $keyFilePath): StorageClient |
17 | 17 | { |
18 | - $path = $container->getParameter('kernel.project_dir') . '/config/gcs/' . $keyFilePath; |
|
18 | + $path = $container->getParameter('kernel.project_dir').'/config/gcs/'.$keyFilePath; |
|
19 | 19 | return new StorageClient([ |
20 | 20 | 'keyFilePath' => $path, |
21 | 21 | ]); |
@@ -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 | } |