@@ -19,36 +19,36 @@ |
||
19 | 19 | */ |
20 | 20 | class ExistsViewHelper extends AbstractViewHelper |
21 | 21 | { |
22 | - /** |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function initializeArguments() |
|
26 | - { |
|
27 | - $this->registerArgument('file', 'mixed', '', true); |
|
28 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function initializeArguments() |
|
26 | + { |
|
27 | + $this->registerArgument('file', 'mixed', '', true); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Returns a property value of a file given by the context. |
|
32 | - * |
|
33 | - * @return bool |
|
34 | - */ |
|
35 | - public function render() |
|
36 | - { |
|
37 | - /** @var File|Content|int $file $file */ |
|
38 | - $file = $this->arguments['file']; |
|
30 | + /** |
|
31 | + * Returns a property value of a file given by the context. |
|
32 | + * |
|
33 | + * @return bool |
|
34 | + */ |
|
35 | + public function render() |
|
36 | + { |
|
37 | + /** @var File|Content|int $file $file */ |
|
38 | + $file = $this->arguments['file']; |
|
39 | 39 | |
40 | - if (!$file instanceof File) { |
|
41 | - $file = $this->getFileConverter()->convert($file); |
|
42 | - } |
|
40 | + if (!$file instanceof File) { |
|
41 | + $file = $this->getFileConverter()->convert($file); |
|
42 | + } |
|
43 | 43 | |
44 | - return $file->exists(); |
|
45 | - } |
|
44 | + return $file->exists(); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return ContentToFileConverter|object |
|
49 | - */ |
|
50 | - protected function getFileConverter() |
|
51 | - { |
|
52 | - return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
53 | - } |
|
47 | + /** |
|
48 | + * @return ContentToFileConverter|object |
|
49 | + */ |
|
50 | + protected function getFileConverter() |
|
51 | + { |
|
52 | + return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
53 | + } |
|
54 | 54 | } |
@@ -19,37 +19,37 @@ |
||
19 | 19 | */ |
20 | 20 | class UriViewHelper extends AbstractViewHelper |
21 | 21 | { |
22 | - /** |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function initializeArguments() |
|
26 | - { |
|
27 | - $this->registerArgument('file', 'mixed', '', true); |
|
28 | - $this->registerArgument('relative', 'bool', '', false, false); |
|
29 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function initializeArguments() |
|
26 | + { |
|
27 | + $this->registerArgument('file', 'mixed', '', true); |
|
28 | + $this->registerArgument('relative', 'bool', '', false, false); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Returns a property value of a file given by the context. |
|
33 | - * |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function render() |
|
37 | - { |
|
38 | - /** @var File|Content|int $file $file */ |
|
39 | - $file = $this->arguments['file']; |
|
40 | - $relative = $this->arguments['relative']; |
|
31 | + /** |
|
32 | + * Returns a property value of a file given by the context. |
|
33 | + * |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function render() |
|
37 | + { |
|
38 | + /** @var File|Content|int $file $file */ |
|
39 | + $file = $this->arguments['file']; |
|
40 | + $relative = $this->arguments['relative']; |
|
41 | 41 | |
42 | - if (!$file instanceof File) { |
|
43 | - $file = $this->getFileConverter()->convert($file); |
|
44 | - } |
|
45 | - return $file->getPublicUrl($relative); |
|
46 | - } |
|
42 | + if (!$file instanceof File) { |
|
43 | + $file = $this->getFileConverter()->convert($file); |
|
44 | + } |
|
45 | + return $file->getPublicUrl($relative); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return ContentToFileConverter|object |
|
50 | - */ |
|
51 | - protected function getFileConverter() |
|
52 | - { |
|
53 | - return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return ContentToFileConverter|object |
|
50 | + */ |
|
51 | + protected function getFileConverter() |
|
52 | + { |
|
53 | + return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
54 | + } |
|
55 | 55 | } |
@@ -17,25 +17,25 @@ |
||
17 | 17 | */ |
18 | 18 | class PropertyViewHelper extends AbstractViewHelper |
19 | 19 | { |
20 | - /** |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function initializeArguments() |
|
24 | - { |
|
25 | - $this->registerArgument('name', 'string', '', true); |
|
26 | - } |
|
20 | + /** |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function initializeArguments() |
|
24 | + { |
|
25 | + $this->registerArgument('name', 'string', '', true); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Returns a property value of a file given by the context. |
|
30 | - * |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function render() |
|
34 | - { |
|
35 | - $name = $this->arguments['name']; |
|
28 | + /** |
|
29 | + * Returns a property value of a file given by the context. |
|
30 | + * |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function render() |
|
34 | + { |
|
35 | + $name = $this->arguments['name']; |
|
36 | 36 | |
37 | - /** @var File $file */ |
|
38 | - $file = $this->templateVariableContainer->get('file'); |
|
39 | - return $file->getProperty($name); |
|
40 | - } |
|
37 | + /** @var File $file */ |
|
38 | + $file = $this->templateVariableContainer->get('file'); |
|
39 | + return $file->getProperty($name); |
|
40 | + } |
|
41 | 41 | } |
@@ -22,68 +22,68 @@ |
||
22 | 22 | */ |
23 | 23 | class ThumbnailViewHelper extends AbstractViewHelper |
24 | 24 | { |
25 | - /** |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function initializeArguments() |
|
29 | - { |
|
30 | - $this->registerArgument('file', 'mixed', 'The source file', false, null); |
|
31 | - $this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []); |
|
32 | - $this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, ''); |
|
33 | - $this->registerArgument('preset', 'string', 'Image dimension preset', false, ''); |
|
34 | - $this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image'); |
|
35 | - $this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, ''); |
|
36 | - } |
|
25 | + /** |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function initializeArguments() |
|
29 | + { |
|
30 | + $this->registerArgument('file', 'mixed', 'The source file', false, null); |
|
31 | + $this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []); |
|
32 | + $this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, ''); |
|
33 | + $this->registerArgument('preset', 'string', 'Image dimension preset', false, ''); |
|
34 | + $this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image'); |
|
35 | + $this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, ''); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Returns a configurable thumbnail of an asset |
|
40 | - * |
|
41 | - * @throws \Exception |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function render() |
|
45 | - { |
|
46 | - $file = $this->arguments['file']; |
|
47 | - $preset = $this->arguments['preset']; |
|
48 | - $configuration = $this->arguments['configuration']; |
|
49 | - if (!is_array($configuration)) { |
|
50 | - $configuration = array(); |
|
51 | - } |
|
52 | - $configurationWrap = $this->arguments['configurationWrap']; |
|
53 | - $attributes = $this->arguments['attributes']; |
|
54 | - $output = $this->arguments['output']; |
|
38 | + /** |
|
39 | + * Returns a configurable thumbnail of an asset |
|
40 | + * |
|
41 | + * @throws \Exception |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function render() |
|
45 | + { |
|
46 | + $file = $this->arguments['file']; |
|
47 | + $preset = $this->arguments['preset']; |
|
48 | + $configuration = $this->arguments['configuration']; |
|
49 | + if (!is_array($configuration)) { |
|
50 | + $configuration = array(); |
|
51 | + } |
|
52 | + $configurationWrap = $this->arguments['configurationWrap']; |
|
53 | + $attributes = $this->arguments['attributes']; |
|
54 | + $output = $this->arguments['output']; |
|
55 | 55 | |
56 | - if ($file instanceof Content) { |
|
57 | - $file = $this->getFileConverter()->convert($file); |
|
58 | - } elseif (!($file instanceof File)) { |
|
59 | - $file = $this->getResourceFactory()->getFileObject((int)$file); |
|
60 | - } |
|
61 | - if ($preset) { |
|
62 | - $imageDimension = ImagePresetUtility::getInstance()->preset($preset); |
|
63 | - $configuration['width'] = $imageDimension->getWidth(); |
|
64 | - $configuration['height'] = $imageDimension->getHeight(); |
|
65 | - } |
|
66 | - /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */ |
|
67 | - $thumbnailService = GeneralUtility::makeInstance(ThumbnailService::class, $file); |
|
68 | - $thumbnail = $thumbnailService->setConfiguration($configuration) |
|
69 | - ->setConfigurationWrap($configurationWrap) |
|
70 | - ->setAttributes($attributes) |
|
71 | - ->setOutputType($output) |
|
72 | - ->create(); |
|
56 | + if ($file instanceof Content) { |
|
57 | + $file = $this->getFileConverter()->convert($file); |
|
58 | + } elseif (!($file instanceof File)) { |
|
59 | + $file = $this->getResourceFactory()->getFileObject((int)$file); |
|
60 | + } |
|
61 | + if ($preset) { |
|
62 | + $imageDimension = ImagePresetUtility::getInstance()->preset($preset); |
|
63 | + $configuration['width'] = $imageDimension->getWidth(); |
|
64 | + $configuration['height'] = $imageDimension->getHeight(); |
|
65 | + } |
|
66 | + /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */ |
|
67 | + $thumbnailService = GeneralUtility::makeInstance(ThumbnailService::class, $file); |
|
68 | + $thumbnail = $thumbnailService->setConfiguration($configuration) |
|
69 | + ->setConfigurationWrap($configurationWrap) |
|
70 | + ->setAttributes($attributes) |
|
71 | + ->setOutputType($output) |
|
72 | + ->create(); |
|
73 | 73 | |
74 | - return $thumbnail; |
|
75 | - } |
|
74 | + return $thumbnail; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return ContentToFileConverter|object |
|
79 | - */ |
|
80 | - protected function getFileConverter() |
|
81 | - { |
|
82 | - return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return ContentToFileConverter|object |
|
79 | + */ |
|
80 | + protected function getFileConverter() |
|
81 | + { |
|
82 | + return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
83 | + } |
|
84 | 84 | |
85 | - protected function getResourceFactory(): ResourceFactory |
|
86 | - { |
|
87 | - return GeneralUtility::makeInstance(ResourceFactory::class); |
|
88 | - } |
|
85 | + protected function getResourceFactory(): ResourceFactory |
|
86 | + { |
|
87 | + return GeneralUtility::makeInstance(ResourceFactory::class); |
|
88 | + } |
|
89 | 89 | } |
@@ -18,37 +18,37 @@ |
||
18 | 18 | */ |
19 | 19 | class FormResultCompiler extends \TYPO3\CMS\Backend\Form\FormResultCompiler |
20 | 20 | { |
21 | - /** |
|
22 | - * JavaScript bottom code |
|
23 | - * |
|
24 | - * @param string $formname The identification of the form on the page. |
|
25 | - * @return string A section with JavaScript - if $update is false, embedded in <script></script> |
|
26 | - */ |
|
27 | - protected function JSbottom() |
|
28 | - { |
|
29 | - $out = parent::JSbottom(); |
|
21 | + /** |
|
22 | + * JavaScript bottom code |
|
23 | + * |
|
24 | + * @param string $formname The identification of the form on the page. |
|
25 | + * @return string A section with JavaScript - if $update is false, embedded in <script></script> |
|
26 | + */ |
|
27 | + protected function JSbottom() |
|
28 | + { |
|
29 | + $out = parent::JSbottom(); |
|
30 | 30 | |
31 | - $tsConfig = $this->getBackendUser()->getTSConfig(); |
|
32 | - $enableMediaFilePicker = (bool)$tsConfig['options.vidi.enableMediaFilePicker']; |
|
33 | - if ($enableMediaFilePicker) { |
|
34 | - $pageRenderer = $this->getPageRenderer(); |
|
35 | - $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
|
31 | + $tsConfig = $this->getBackendUser()->getTSConfig(); |
|
32 | + $enableMediaFilePicker = (bool)$tsConfig['options.vidi.enableMediaFilePicker']; |
|
33 | + if ($enableMediaFilePicker) { |
|
34 | + $pageRenderer = $this->getPageRenderer(); |
|
35 | + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
|
36 | 36 | MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\'; |
37 | 37 | MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\'; |
38 | 38 | MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '; |
39 | 39 | }'); |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | - return $out; |
|
43 | - } |
|
42 | + return $out; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Returns an instance of the current Backend User. |
|
47 | - * |
|
48 | - * @return BackendUserAuthentication |
|
49 | - */ |
|
50 | - protected function getBackendUser() |
|
51 | - { |
|
52 | - return $GLOBALS['BE_USER']; |
|
53 | - } |
|
45 | + /** |
|
46 | + * Returns an instance of the current Backend User. |
|
47 | + * |
|
48 | + * @return BackendUserAuthentication |
|
49 | + */ |
|
50 | + protected function getBackendUser() |
|
51 | + { |
|
52 | + return $GLOBALS['BE_USER']; |
|
53 | + } |
|
54 | 54 | } |
@@ -33,9 +33,9 @@ |
||
33 | 33 | if ($enableMediaFilePicker) { |
34 | 34 | $pageRenderer = $this->getPageRenderer(); |
35 | 35 | $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
36 | - MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\'; |
|
37 | - MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\'; |
|
38 | - MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '; |
|
36 | + MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()).'\'; |
|
37 | + MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix().'\'; |
|
38 | + MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')).'; |
|
39 | 39 | }'); |
40 | 40 | } |
41 | 41 |
@@ -18,27 +18,27 @@ |
||
18 | 18 | |
19 | 19 | class FileCacheWarmUpCommand extends Command |
20 | 20 | { |
21 | - protected SymfonyStyle $io; |
|
22 | - |
|
23 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
24 | - { |
|
25 | - $this->io = new SymfonyStyle($input, $output); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Warm up the cache. Update some caching columns such as "number_of_references" to speed up the search. |
|
30 | - */ |
|
31 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
32 | - { |
|
33 | - $numberOfEntries = $this->getCacheService()->warmUp(); |
|
34 | - $message = sprintf('Done! Processed %s entries', $numberOfEntries); |
|
35 | - $this->io->info($message); |
|
36 | - |
|
37 | - return 0; |
|
38 | - } |
|
39 | - |
|
40 | - protected function getCacheService(): CacheService |
|
41 | - { |
|
42 | - return GeneralUtility::makeInstance(CacheService::class); |
|
43 | - } |
|
21 | + protected SymfonyStyle $io; |
|
22 | + |
|
23 | + protected function initialize(InputInterface $input, OutputInterface $output) |
|
24 | + { |
|
25 | + $this->io = new SymfonyStyle($input, $output); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Warm up the cache. Update some caching columns such as "number_of_references" to speed up the search. |
|
30 | + */ |
|
31 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
32 | + { |
|
33 | + $numberOfEntries = $this->getCacheService()->warmUp(); |
|
34 | + $message = sprintf('Done! Processed %s entries', $numberOfEntries); |
|
35 | + $this->io->info($message); |
|
36 | + |
|
37 | + return 0; |
|
38 | + } |
|
39 | + |
|
40 | + protected function getCacheService(): CacheService |
|
41 | + { |
|
42 | + return GeneralUtility::makeInstance(CacheService::class); |
|
43 | + } |
|
44 | 44 | } |
@@ -21,110 +21,110 @@ |
||
21 | 21 | |
22 | 22 | class ThumbnailCommand extends Command |
23 | 23 | { |
24 | - protected SymfonyStyle $io; |
|
25 | - |
|
26 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
27 | - { |
|
28 | - $this->io = new SymfonyStyle($input, $output); |
|
29 | - } |
|
30 | - |
|
31 | - protected function configure() |
|
32 | - { |
|
33 | - $this |
|
34 | - ->addOption( |
|
35 | - 'limit', |
|
36 | - '', |
|
37 | - InputOption::VALUE_REQUIRED, |
|
38 | - 'where to stop in the batch processing.', |
|
39 | - 0 |
|
40 | - ) |
|
41 | - ->addOption( |
|
42 | - 'offset', |
|
43 | - '', |
|
44 | - InputOption::VALUE_REQUIRED, |
|
45 | - 'where to start in the batch processing.', |
|
46 | - 0 |
|
47 | - ) |
|
48 | - ->addOption( |
|
49 | - 'configuration', |
|
50 | - '', |
|
51 | - InputOption::VALUE_REQUIRED, |
|
52 | - 'override the default thumbnail configuration.', |
|
53 | - [] |
|
54 | - ); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module. |
|
59 | - */ |
|
60 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
61 | - { |
|
62 | - $limit = $input->getOption('limit'); |
|
63 | - $offset = $input->getOption('offset'); |
|
64 | - $configuration = $input->getOption('configuration'); |
|
65 | - $verbose = $input->getOption('verbose'); |
|
66 | - |
|
67 | - foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
68 | - $this->io->info(sprintf('Processing files from storage %s (%s)', $storage->getName(), $storage->getUid())); |
|
69 | - |
|
70 | - if ($storage->isOnline()) { |
|
71 | - // For the CLI cause. |
|
72 | - $storage->setEvaluatePermissions(false); |
|
73 | - |
|
74 | - $thumbnailGenerator = $this->getThumbnailGenerator(); |
|
75 | - $thumbnailGenerator |
|
76 | - ->setStorage($storage) |
|
77 | - ->setConfiguration($configuration) |
|
78 | - ->generate($limit, $offset); |
|
79 | - |
|
80 | - if ($verbose) { |
|
81 | - $resultSet = $thumbnailGenerator->getResultSet(); |
|
82 | - foreach ($resultSet as $result) { |
|
83 | - $message = sprintf( |
|
84 | - '* File "%s": %s %s', |
|
85 | - $result['fileUid'], |
|
86 | - $result['fileIdentifier'], |
|
87 | - empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
88 | - ); |
|
89 | - $this->io->info($message); |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - $message = sprintf( |
|
94 | - 'Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.', |
|
95 | - $thumbnailGenerator->getNumberOfProcessedFiles(), |
|
96 | - $thumbnailGenerator->getNumberOfTraversedFiles(), |
|
97 | - $thumbnailGenerator->getTotalNumberOfFiles() |
|
98 | - ); |
|
99 | - $this->io->info($message); |
|
100 | - |
|
101 | - // Add warning message if missing files were found along the way. |
|
102 | - if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) { |
|
103 | - $message = sprintf( |
|
104 | - 'ATTENTION! %s missing file(s) detected.', |
|
105 | - $thumbnailGenerator->getNumberOfMissingFiles() |
|
106 | - ); |
|
107 | - $this->io->warning($message); |
|
108 | - } |
|
109 | - } else { |
|
110 | - $this->io->info('Storage is offline!'); |
|
111 | - } |
|
112 | - } |
|
113 | - return 0; |
|
114 | - } |
|
115 | - |
|
116 | - protected function getDataService(): DataService |
|
117 | - { |
|
118 | - return GeneralUtility::makeInstance(DataService::class); |
|
119 | - } |
|
120 | - |
|
121 | - protected function getThumbnailGenerator(): ThumbnailGenerator |
|
122 | - { |
|
123 | - return GeneralUtility::makeInstance(ThumbnailGenerator::class); |
|
124 | - } |
|
125 | - |
|
126 | - protected function getStorageRepository(): StorageRepository |
|
127 | - { |
|
128 | - return GeneralUtility::makeInstance(StorageRepository::class); |
|
129 | - } |
|
24 | + protected SymfonyStyle $io; |
|
25 | + |
|
26 | + protected function initialize(InputInterface $input, OutputInterface $output) |
|
27 | + { |
|
28 | + $this->io = new SymfonyStyle($input, $output); |
|
29 | + } |
|
30 | + |
|
31 | + protected function configure() |
|
32 | + { |
|
33 | + $this |
|
34 | + ->addOption( |
|
35 | + 'limit', |
|
36 | + '', |
|
37 | + InputOption::VALUE_REQUIRED, |
|
38 | + 'where to stop in the batch processing.', |
|
39 | + 0 |
|
40 | + ) |
|
41 | + ->addOption( |
|
42 | + 'offset', |
|
43 | + '', |
|
44 | + InputOption::VALUE_REQUIRED, |
|
45 | + 'where to start in the batch processing.', |
|
46 | + 0 |
|
47 | + ) |
|
48 | + ->addOption( |
|
49 | + 'configuration', |
|
50 | + '', |
|
51 | + InputOption::VALUE_REQUIRED, |
|
52 | + 'override the default thumbnail configuration.', |
|
53 | + [] |
|
54 | + ); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module. |
|
59 | + */ |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
61 | + { |
|
62 | + $limit = $input->getOption('limit'); |
|
63 | + $offset = $input->getOption('offset'); |
|
64 | + $configuration = $input->getOption('configuration'); |
|
65 | + $verbose = $input->getOption('verbose'); |
|
66 | + |
|
67 | + foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
68 | + $this->io->info(sprintf('Processing files from storage %s (%s)', $storage->getName(), $storage->getUid())); |
|
69 | + |
|
70 | + if ($storage->isOnline()) { |
|
71 | + // For the CLI cause. |
|
72 | + $storage->setEvaluatePermissions(false); |
|
73 | + |
|
74 | + $thumbnailGenerator = $this->getThumbnailGenerator(); |
|
75 | + $thumbnailGenerator |
|
76 | + ->setStorage($storage) |
|
77 | + ->setConfiguration($configuration) |
|
78 | + ->generate($limit, $offset); |
|
79 | + |
|
80 | + if ($verbose) { |
|
81 | + $resultSet = $thumbnailGenerator->getResultSet(); |
|
82 | + foreach ($resultSet as $result) { |
|
83 | + $message = sprintf( |
|
84 | + '* File "%s": %s %s', |
|
85 | + $result['fileUid'], |
|
86 | + $result['fileIdentifier'], |
|
87 | + empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
88 | + ); |
|
89 | + $this->io->info($message); |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + $message = sprintf( |
|
94 | + 'Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.', |
|
95 | + $thumbnailGenerator->getNumberOfProcessedFiles(), |
|
96 | + $thumbnailGenerator->getNumberOfTraversedFiles(), |
|
97 | + $thumbnailGenerator->getTotalNumberOfFiles() |
|
98 | + ); |
|
99 | + $this->io->info($message); |
|
100 | + |
|
101 | + // Add warning message if missing files were found along the way. |
|
102 | + if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) { |
|
103 | + $message = sprintf( |
|
104 | + 'ATTENTION! %s missing file(s) detected.', |
|
105 | + $thumbnailGenerator->getNumberOfMissingFiles() |
|
106 | + ); |
|
107 | + $this->io->warning($message); |
|
108 | + } |
|
109 | + } else { |
|
110 | + $this->io->info('Storage is offline!'); |
|
111 | + } |
|
112 | + } |
|
113 | + return 0; |
|
114 | + } |
|
115 | + |
|
116 | + protected function getDataService(): DataService |
|
117 | + { |
|
118 | + return GeneralUtility::makeInstance(DataService::class); |
|
119 | + } |
|
120 | + |
|
121 | + protected function getThumbnailGenerator(): ThumbnailGenerator |
|
122 | + { |
|
123 | + return GeneralUtility::makeInstance(ThumbnailGenerator::class); |
|
124 | + } |
|
125 | + |
|
126 | + protected function getStorageRepository(): StorageRepository |
|
127 | + { |
|
128 | + return GeneralUtility::makeInstance(StorageRepository::class); |
|
129 | + } |
|
130 | 130 | } |
@@ -84,7 +84,7 @@ |
||
84 | 84 | '* File "%s": %s %s', |
85 | 85 | $result['fileUid'], |
86 | 86 | $result['fileIdentifier'], |
87 | - empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
87 | + empty($result['thumbnailUri']) ? '' : ' -> '.$result['thumbnailUri'] |
|
88 | 88 | ); |
89 | 89 | $this->io->info($message); |
90 | 90 | } |
@@ -25,69 +25,69 @@ |
||
25 | 25 | |
26 | 26 | class FileCacheFlushProcessedFilesCommand extends Command |
27 | 27 | { |
28 | - protected SymfonyStyle $io; |
|
29 | - |
|
30 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
31 | - { |
|
32 | - $this->io = new SymfonyStyle($input, $output); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * Flush all processed files to be used for debugging mainly. |
|
37 | - */ |
|
38 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
39 | - { |
|
40 | - foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
41 | - // This only works for local driver |
|
42 | - if ($storage->getDriverType() === 'Local' && $storage->isOnline()) { |
|
43 | - $processedDirectoryPath = Environment::getPublicPath() . $this->getProcessingFolderPath($storage); |
|
44 | - $this->io->info(sprintf('Removing files from %s for storage "%s" (%s)', $processedDirectoryPath, $storage->getName(), $storage->getUid())); |
|
45 | - |
|
46 | - $this->clearProcessedFiles($storage->getUid()); |
|
47 | - |
|
48 | - GeneralUtility::rmdir($processedDirectoryPath, true); |
|
49 | - GeneralUtility::mkdir($processedDirectoryPath); // recreate the directory. |
|
50 | - |
|
51 | - $message = sprintf('Done! Removed all processed files from storage %s.', $storage->getUid()); |
|
52 | - $this->io->info($message); |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - return 0; |
|
57 | - } |
|
58 | - |
|
59 | - public function clearProcessedFiles(int $storageUid): int |
|
60 | - { |
|
61 | - $repository = GeneralUtility::makeInstance(ProcessedFileRepository::class); |
|
62 | - return $repository->removeAll($storageUid); |
|
63 | - } |
|
64 | - |
|
65 | - protected function getProcessingFolderPath(ResourceStorage $storage): string |
|
66 | - { |
|
67 | - $storageConfiguration = $storage->getConfiguration(); |
|
68 | - $storageBasePath = rtrim($storageConfiguration['basePath'], '/'); |
|
69 | - return '/' . $storageBasePath . $storage->getProcessingFolder()->getIdentifier(); |
|
70 | - } |
|
71 | - |
|
72 | - protected function getCacheService(): CacheService |
|
73 | - { |
|
74 | - return GeneralUtility::makeInstance(CacheService::class); |
|
75 | - } |
|
76 | - |
|
77 | - protected function getStorageRepository(): StorageRepository |
|
78 | - { |
|
79 | - return GeneralUtility::makeInstance(StorageRepository::class); |
|
80 | - } |
|
81 | - |
|
82 | - protected function getDataService(): DataService |
|
83 | - { |
|
84 | - return GeneralUtility::makeInstance(DataService::class); |
|
85 | - } |
|
86 | - |
|
87 | - protected function getConnection(string $tableName): Connection |
|
88 | - { |
|
89 | - /** @var ConnectionPool $connectionPool */ |
|
90 | - $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
91 | - return $connectionPool->getConnectionForTable($tableName); |
|
92 | - } |
|
28 | + protected SymfonyStyle $io; |
|
29 | + |
|
30 | + protected function initialize(InputInterface $input, OutputInterface $output) |
|
31 | + { |
|
32 | + $this->io = new SymfonyStyle($input, $output); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * Flush all processed files to be used for debugging mainly. |
|
37 | + */ |
|
38 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
39 | + { |
|
40 | + foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
41 | + // This only works for local driver |
|
42 | + if ($storage->getDriverType() === 'Local' && $storage->isOnline()) { |
|
43 | + $processedDirectoryPath = Environment::getPublicPath() . $this->getProcessingFolderPath($storage); |
|
44 | + $this->io->info(sprintf('Removing files from %s for storage "%s" (%s)', $processedDirectoryPath, $storage->getName(), $storage->getUid())); |
|
45 | + |
|
46 | + $this->clearProcessedFiles($storage->getUid()); |
|
47 | + |
|
48 | + GeneralUtility::rmdir($processedDirectoryPath, true); |
|
49 | + GeneralUtility::mkdir($processedDirectoryPath); // recreate the directory. |
|
50 | + |
|
51 | + $message = sprintf('Done! Removed all processed files from storage %s.', $storage->getUid()); |
|
52 | + $this->io->info($message); |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + return 0; |
|
57 | + } |
|
58 | + |
|
59 | + public function clearProcessedFiles(int $storageUid): int |
|
60 | + { |
|
61 | + $repository = GeneralUtility::makeInstance(ProcessedFileRepository::class); |
|
62 | + return $repository->removeAll($storageUid); |
|
63 | + } |
|
64 | + |
|
65 | + protected function getProcessingFolderPath(ResourceStorage $storage): string |
|
66 | + { |
|
67 | + $storageConfiguration = $storage->getConfiguration(); |
|
68 | + $storageBasePath = rtrim($storageConfiguration['basePath'], '/'); |
|
69 | + return '/' . $storageBasePath . $storage->getProcessingFolder()->getIdentifier(); |
|
70 | + } |
|
71 | + |
|
72 | + protected function getCacheService(): CacheService |
|
73 | + { |
|
74 | + return GeneralUtility::makeInstance(CacheService::class); |
|
75 | + } |
|
76 | + |
|
77 | + protected function getStorageRepository(): StorageRepository |
|
78 | + { |
|
79 | + return GeneralUtility::makeInstance(StorageRepository::class); |
|
80 | + } |
|
81 | + |
|
82 | + protected function getDataService(): DataService |
|
83 | + { |
|
84 | + return GeneralUtility::makeInstance(DataService::class); |
|
85 | + } |
|
86 | + |
|
87 | + protected function getConnection(string $tableName): Connection |
|
88 | + { |
|
89 | + /** @var ConnectionPool $connectionPool */ |
|
90 | + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
91 | + return $connectionPool->getConnectionForTable($tableName); |
|
92 | + } |
|
93 | 93 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | foreach ($this->getStorageRepository()->findAll() as $storage) { |
41 | 41 | // This only works for local driver |
42 | 42 | if ($storage->getDriverType() === 'Local' && $storage->isOnline()) { |
43 | - $processedDirectoryPath = Environment::getPublicPath() . $this->getProcessingFolderPath($storage); |
|
43 | + $processedDirectoryPath = Environment::getPublicPath().$this->getProcessingFolderPath($storage); |
|
44 | 44 | $this->io->info(sprintf('Removing files from %s for storage "%s" (%s)', $processedDirectoryPath, $storage->getName(), $storage->getUid())); |
45 | 45 | |
46 | 46 | $this->clearProcessedFiles($storage->getUid()); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $storageConfiguration = $storage->getConfiguration(); |
68 | 68 | $storageBasePath = rtrim($storageConfiguration['basePath'], '/'); |
69 | - return '/' . $storageBasePath . $storage->getProcessingFolder()->getIdentifier(); |
|
69 | + return '/'.$storageBasePath.$storage->getProcessingFolder()->getIdentifier(); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | protected function getCacheService(): CacheService |
@@ -19,36 +19,36 @@ |
||
19 | 19 | */ |
20 | 20 | class StorageValidator extends AbstractValidator |
21 | 21 | { |
22 | - /** |
|
23 | - * Check if $storageIdentifier is allowed. If it is not valid, throw an exception. |
|
24 | - * |
|
25 | - * @param int $combinedIdentifier |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function isValid($combinedIdentifier) |
|
29 | - { |
|
30 | - $allowedStorageIdentifiers = []; |
|
31 | - foreach ($this->getMediaModule()->getAllowedStorages() as $allowedStorage) { |
|
32 | - $allowedStorageIdentifiers[] = $allowedStorage->getUid(); |
|
33 | - } |
|
22 | + /** |
|
23 | + * Check if $storageIdentifier is allowed. If it is not valid, throw an exception. |
|
24 | + * |
|
25 | + * @param int $combinedIdentifier |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function isValid($combinedIdentifier) |
|
29 | + { |
|
30 | + $allowedStorageIdentifiers = []; |
|
31 | + foreach ($this->getMediaModule()->getAllowedStorages() as $allowedStorage) { |
|
32 | + $allowedStorageIdentifiers[] = $allowedStorage->getUid(); |
|
33 | + } |
|
34 | 34 | |
35 | - $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
36 | - if (!in_array($storage->getUid(), $allowedStorageIdentifiers)) { |
|
37 | - $message = sprintf('Storage identifier "%s" is not allowed or is currently off-line.', $combinedIdentifier); |
|
38 | - $this->addError($message, 1380813503); |
|
39 | - } |
|
40 | - } |
|
35 | + $storage = $this->getResourceFactory()->getStorageObjectFromCombinedIdentifier($combinedIdentifier); |
|
36 | + if (!in_array($storage->getUid(), $allowedStorageIdentifiers)) { |
|
37 | + $message = sprintf('Storage identifier "%s" is not allowed or is currently off-line.', $combinedIdentifier); |
|
38 | + $this->addError($message, 1380813503); |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return MediaModule|object |
|
44 | - */ |
|
45 | - protected function getMediaModule() |
|
46 | - { |
|
47 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
48 | - } |
|
42 | + /** |
|
43 | + * @return MediaModule|object |
|
44 | + */ |
|
45 | + protected function getMediaModule() |
|
46 | + { |
|
47 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
48 | + } |
|
49 | 49 | |
50 | - protected function getResourceFactory(): ResourceFactory |
|
51 | - { |
|
52 | - return GeneralUtility::makeInstance(ResourceFactory::class); |
|
53 | - } |
|
50 | + protected function getResourceFactory(): ResourceFactory |
|
51 | + { |
|
52 | + return GeneralUtility::makeInstance(ResourceFactory::class); |
|
53 | + } |
|
54 | 54 | } |