src/Plugins/PluginExecutor.php
/**
     * Executes the plugin with the passed configuration.
     *
     * @param \TechDivision\Import\Configuration\PluginConfigurationInterface $plugin The message with the plugin information
     *
     * @return void
     */
Executes the plugin with the passed configuration.
@param \TechDivision\Import\Configuration\PluginConfigurationInterface $plugin The message with the plugin information

@return void
Executes the plugin with the passed configuration . @param \ TechDivision \ Import \ Configuration \ PluginConfigurationInterface $plugin The message with the plugin information @return void
public function execute(PluginConfigurationInterface $plugin)
    {
        $pluginInstance = $this->getPluginFactory()->createPlugin($plugin);
         load the plug-in and operation name to prepare the events
        $pluginName = $plugin->getName();
        $operationName = $plugin->getOperationConfiguration()->getName();
        try {
             invoke the event that has to be fired before the plugin will be executed
            $this->getEmitter()->emit(EventNames::PLUGIN_PROCESS_START, $pluginInstance);
            $this->getEmitter()->emit(sprintf('%s.%s', $pluginName, EventNames::PLUGIN_PROCESS_START), $pluginInstance);
            $this->getEmitter()->emit(sprintf('%s.%s.%s', $operationName, $pluginName, EventNames::PLUGIN_PROCESS_START), $pluginInstance);
             initialize the counter
            $counter = 1;
             process the plugin
            $pluginInstance->process();
             query whether or not, we've to export artefacts
            if ($pluginInstance instanceof ExportablePluginInterface) {
                try {
                     invoke the event that has to be fired before the subject's export method will be invoked
                    $this->getEmitter()->emit(EventNames::PLUGIN_EXPORT_START, $pluginInstance);
                    $this->getEmitter()->emit(sprintf('%s.%s', $pluginName, EventNames::PLUGIN_EXPORT_START), $pluginInstance);
                    $this->getEmitter()->emit(sprintf('%s.%s.%s', $operationName, $pluginName, EventNames::PLUGIN_EXPORT_START), $pluginInstance);
                     export the plugin's artefacts if available
                    $pluginInstance->export(date('Ymd-His'), str_pad($counter++, 2, 0, STR_PAD_LEFT));
                     invoke the event that has to be fired after the subject's export method has been invoked
                    $this->getEmitter()->emit(EventNames::PLUGIN_EXPORT_SUCCESS, $pluginInstance);
                    $this->getEmitter()->emit(sprintf('%s.%s', $pluginName, EventNames::PLUGIN_EXPORT_SUCCESS), $pluginInstance);
                    $this->getEmitter()->emit(sprintf('%s.%s.%s', $operationName, $pluginName, EventNames::PLUGIN_EXPORT_SUCCESS), $pluginInstance);
                } catch (\Exception $e) {
                     invoke the event that has to be fired when the subject's export method throws an exception
                    $this->getEmitter()->emit(EventNames::PLUGIN_EXPORT_FAILURE, $pluginInstance);
                    $this->getEmitter()->emit(sprintf('%s.%s', $pluginName, EventNames::PLUGIN_EXPORT_FAILURE), $pluginInstance);
                    $this->getEmitter()->emit(sprintf('%s.%s.%s', $operationName, $pluginName, EventNames::PLUGIN_EXPORT_FAILURE), $pluginInstance);
                     re-throw the exception
                    throw $e;
                }
            }
             invoke the event that has to be fired after the plugin has been executed
            $this->getEmitter()->emit(EventNames::PLUGIN_PROCESS_SUCCESS, $pluginInstance);
            $this->getEmitter()->emit(sprintf('%s.%s', $pluginName, EventNames::PLUGIN_PROCESS_SUCCESS), $pluginInstance);
            $this->getEmitter()->emit(sprintf('%s.%s.%s', $operationName, $pluginName, EventNames::PLUGIN_PROCESS_SUCCESS), $pluginInstance);
        } catch (\Exception $e) {
             invoke the event that has to be fired when the plugin throws an exception
            $this->getEmitter()->emit(EventNames::PLUGIN_PROCESS_FAILURE, $pluginInstance);
            $this->getEmitter()->emit(sprintf('%s.%s', $pluginName, EventNames::PLUGIN_PROCESS_FAILURE), $pluginInstance);
            $this->getEmitter()->emit(sprintf('%s.%s.%s', $operationName, $pluginName, EventNames::PLUGIN_PROCESS_FAILURE), $pluginInstance);
             re-throw the exception
            throw $e;
        }
    }
public function execute ( PluginConfigurationInterface $ plugin ) { $ pluginInstance = $ this -> getPluginFactory ( ) -> createPlugin ( $ plugin ) ; $ pluginName = $ plugin -> getName ( ) ; $ operationName = $ plugin -> getOperationConfiguration ( ) -> getName ( ) ; try { $ this -> getEmitter ( ) -> emit ( EventNames :: PLUGIN_PROCESS_START , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s' , $ pluginName , EventNames :: PLUGIN_PROCESS_START ) , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s.%s' , $ operationName , $ pluginName , EventNames :: PLUGIN_PROCESS_START ) , $ pluginInstance ) ; $ counter = 1 ; $ pluginInstance -> process ( ) ; if ( $ pluginInstance instanceof ExportablePluginInterface ) { try { $ this -> getEmitter ( ) -> emit ( EventNames :: PLUGIN_EXPORT_START , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s' , $ pluginName , EventNames :: PLUGIN_EXPORT_START ) , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s.%s' , $ operationName , $ pluginName , EventNames :: PLUGIN_EXPORT_START ) , $ pluginInstance ) ; $ pluginInstance -> export ( date ( 'Ymd-His' ) , str_pad ( $ counter ++ , 2 , 0 , STR_PAD_LEFT ) ) ; $ this -> getEmitter ( ) -> emit ( EventNames :: PLUGIN_EXPORT_SUCCESS , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s' , $ pluginName , EventNames :: PLUGIN_EXPORT_SUCCESS ) , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s.%s' , $ operationName , $ pluginName , EventNames :: PLUGIN_EXPORT_SUCCESS ) , $ pluginInstance ) ; } catch ( \ Exception $ e ) { $ this -> getEmitter ( ) -> emit ( EventNames :: PLUGIN_EXPORT_FAILURE , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s' , $ pluginName , EventNames :: PLUGIN_EXPORT_FAILURE ) , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s.%s' , $ operationName , $ pluginName , EventNames :: PLUGIN_EXPORT_FAILURE ) , $ pluginInstance ) ; throw $ e ; } } $ this -> getEmitter ( ) -> emit ( EventNames :: PLUGIN_PROCESS_SUCCESS , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s' , $ pluginName , EventNames :: PLUGIN_PROCESS_SUCCESS ) , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s.%s' , $ operationName , $ pluginName , EventNames :: PLUGIN_PROCESS_SUCCESS ) , $ pluginInstance ) ; } catch ( \ Exception $ e ) { $ this -> getEmitter ( ) -> emit ( EventNames :: PLUGIN_PROCESS_FAILURE , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s' , $ pluginName , EventNames :: PLUGIN_PROCESS_FAILURE ) , $ pluginInstance ) ; $ this -> getEmitter ( ) -> emit ( sprintf ( '%s.%s.%s' , $ operationName , $ pluginName , EventNames :: PLUGIN_PROCESS_FAILURE ) , $ pluginInstance ) ; throw $ e ; } }
Executes the plugin with the passed configuration.
Executes the plugin with the passed configuration .
// initialize the plugin // // load the plug-in and operation name to prepare the events // invoke the event that has to be fired before the plugin will be executed // initialize the counter // process the plugin // query whether or not, we've to export artefacts // invoke the event that has to be fired before the subject's export method will be invoked // export the plugin's artefacts if available // invoke the event that has to be fired after the subject's export method has been invoked // invoke the event that has to be fired when the subject's export method throws an exception // re-throw the exception // invoke the event that has to be fired after the plugin has been executed // invoke the event that has to be fired when the plugin throws an exception // re-throw the exception