These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * ImportCommandController.php |
||
4 | */ |
||
5 | namespace HDNET\Importr\Command; |
||
6 | |||
7 | use HDNET\Importr\Service\Manager; |
||
8 | use TYPO3\CMS\Core\Messaging\FlashMessage; |
||
9 | use TYPO3\CMS\Core\Messaging\FlashMessageService; |
||
10 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
||
11 | use TYPO3\CMS\Extbase\Mvc\Controller\CommandController; |
||
12 | |||
13 | /** |
||
14 | * ImportCommandController |
||
15 | * |
||
16 | * For initializing the Manager |
||
17 | */ |
||
18 | class ImportCommandController extends CommandController |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * @var \TYPO3\CMS\Extbase\Mvc\Cli\CommandManager |
||
23 | * @inject |
||
24 | */ |
||
25 | protected $commandManager; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $commandsByExtensionsAndControllers = []; |
||
31 | |||
32 | /** |
||
33 | * initializes the import service manager |
||
34 | * |
||
35 | * @param string $mail Set an email address for error reporting |
||
36 | * |
||
37 | * @return boolean |
||
38 | */ |
||
39 | public function initializeServiceManagerCommand($mail = null) |
||
0 ignored issues
–
show
|
|||
40 | { |
||
41 | $message = GeneralUtility::makeInstance( |
||
42 | FlashMessage::class, |
||
43 | '', |
||
44 | 'Initializing ServiceManager', |
||
45 | FlashMessage::INFO, |
||
46 | true |
||
47 | ); |
||
48 | $this->addFlashMessage($message); |
||
49 | |||
50 | $manager = $this->objectManager->get(Manager::class); |
||
51 | try { |
||
52 | // let the manager run the imports now |
||
53 | $manager->runImports(); |
||
54 | } catch (\Exception $e) { |
||
55 | $message = GeneralUtility::makeInstance( |
||
56 | FlashMessage::class, |
||
57 | '', |
||
58 | 'An Error occured: ' . $e->getCode() . ': ' . $e->getMessage(), |
||
59 | FlashMessage::ERROR |
||
60 | ); |
||
61 | $this->addFlashMessage($message); |
||
62 | |||
63 | // @TODO: Send email when the manager crashes. |
||
64 | return false; |
||
65 | } |
||
66 | return true; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param FlashMessage $flashMessage |
||
71 | */ |
||
72 | protected function addFlashMessage(FlashMessage $flashMessage) |
||
73 | { |
||
74 | $flashMessageService = $this->objectManager->get( |
||
75 | FlashMessageService::class |
||
76 | ); |
||
77 | $messageQueue = $flashMessageService->getMessageQueueByIdentifier(); |
||
78 | $messageQueue->addMessage($flashMessage); |
||
79 | } |
||
80 | } |
||
81 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.