77
88namespace Elements \Bundle \ProcessManagerBundle \Executor ;
99
10+ use Elements \Bundle \ProcessManagerBundle \Model \Configuration ;
1011use Elements \Bundle \ProcessManagerBundle \Model \MonitoringItem ;
1112use Elements \Bundle \ProcessManagerBundle \Service \CommandsValidator ;
13+ use Exception ;
1214use Pimcore \Tool \Console ;
1315
1416class PimcoreCommand extends AbstractExecutor
@@ -22,6 +24,7 @@ class PimcoreCommand extends AbstractExecutor
2224 * @param null | MonitoringItem $monitoringItem
2325 *
2426 * @return mixed
27+ * @throws Exception
2528 */
2629 public function getCommand ($ callbackSettings = [], $ monitoringItem = null )
2730 {
@@ -37,7 +40,7 @@ public function getCommand($callbackSettings = [], $monitoringItem = null)
3740 $ commands = \Pimcore::getKernel ()->getContainer ()->get (CommandsValidator::class)->getValidCommands ();
3841
3942 if (!array_key_exists ($ this ->getValues ()['command ' ], $ commands )) {
40- throw new \ Exception ('Invalid command - not in valid commands ' );
43+ throw new Exception ('Invalid command - not in valid commands ' );
4144 }
4245 /**
4346 * @var \Pimcore\Console\AbstractCommand $commandObject
@@ -55,4 +58,21 @@ public function getCommand($callbackSettings = [], $monitoringItem = null)
5558
5659 return $ command ;
5760 }
61+
62+ public function validateConfiguration (Configuration $ configuration ): void
63+ {
64+
65+ if ($ configuration ->getExecutorSettings ()){
66+ $ settings = $ configuration ->getExecutorSettingsAsArray ();
67+ $ values = $ settings ['values ' ];
68+ if (!$ values ['command ' ]){
69+ throw new Exception ('Please provide a command. ' );
70+ }
71+ $ commandValidator = \Pimcore::getKernel ()->getContainer ()->get (CommandsValidator::class);
72+ $ commands = \Pimcore::getKernel ()->getContainer ()->get (CommandsValidator::class)->getValidCommands ();
73+ $ commandValidator ->validateCommandConfiguration ($ commands [$ values ['command ' ]], $ configuration );
74+
75+
76+ }
77+ }
5878}
0 commit comments