array( 'className' => 'App_Admin_Tool_Project_Provider_Module', 'title' => App_Admin_Tool_Project_Provider_Module::PROVIDER_TITLE, 'directoryName' => 'Module' ) ); protected $_workflowAreaForm = null; public function __construct($options) { $this->_pageHeaderTemplates[self::HEADER_VIEW] = '%itemName%'; return parent::__construct($options); } public function exec() { if (isset($this->_restParams[0]) && array_key_exists($this->_restParams[0], $this->_providerMap)) { if (class_exists($this->_providerMap[$this->_restParams[0]]['className'], false)) { $providerClassName = $this->_providerMap[$this->_restParams[0]]['className']; $this->_provider = new $providerClassName(); } } return parent::exec(); } protected function _doView() { $item = array( 'providers' => $this->_providerMap, 'tpl' => $this->getTemplate('view.tpl') ); $this->_addItem($item); if ($this->_provider instanceof App_Admin_Tool_Project_Provider_Abstract) { $this->_addForm(); } return $this; } protected function _addForm() { /** @var Qs_Form $form */ $form = $this->_getProviderForm(); $item = array( 'form' => $form->render(), 'tpl' => $this->getTemplate( $this->_providerMap[$this->_restParams[0]]['directoryName'] . DIRECTORY_SEPARATOR . 'form.tpl' ) ); $this->_addItem($item, 'WORKFLOW_ITEMS'); return $this; } protected function _getProviderForm() { if (empty($this->_workflowAreaForm)) { $this->_workflowAreaForm = $this->_provider->getWorkflowAreaForm($this->_getFormOptions()); } return $this->_workflowAreaForm; } protected function _doGenerate() { /** @var Qs_Form $form */ $form = $this->_getProviderForm(); if ($form->validate()) { $this->_initFromForm($form); $this->_generate(); $providerClassName = $this->_providerMap[$this->_restParams[0]]['className']; $this->_setBackMessage(sprintf( $this->_provider->getMessage($providerClassName::SUCCESS_GENERATION), $this->_provider->getModuleName() )); $this->_doBack(); } else { $this->_workflowAreaForm = $form; $this->_doView(); } return $this; } protected function _doGenerateAjax() { /** @var Qs_Form $form */ $form = $this->_getProviderForm(); $this->_displayJson($form->validateAjax()); } protected function _generate() { /** @var App_Admin_Tool_Obj $dataObj */ $dataObj = $this->_getDataObj(); $this->_provider->setModuleName($dataObj->getData('name')); $this->_provider->generate(); $dataObj->save(); } }