public function create($resourceName, $module = null) { parent::create($resourceName . 's', true, $module); $this->_resourceName = $resourceName; $this->_moduleName = $module; $modelProvider = new Zend_Tool_Project_Provider_Model(); $modelProvider->setRegistry($this->_registry); $modelProvider->create($this->_resourceName, $this->_moduleName); $dbTableProvider = new Zend_Tool_Project_Provider_DbTable(); $dbTableProvider->setRegistry($this->_registry); $dbTableProvider->create($this->_resourceName, $this->_resourceName . 's', $this->_moduleName); $formProvider = new Zend_Tool_Project_Provider_Form(); $formProvider->setRegistry($this->_registry); $formProvider->create($this->_resourceName, $this->_moduleName); $response = $this->_registry->getResponse(); try { $controllerResource = self::createResource($this->_loadedProfile, $resourceName, $module); //index created on superclass::create $this->_createAction('new'); $this->_createAction('edit'); $this->_createAction('destroy'); /* $testControllerResource = Zend_Tool_Project_Provider_Test::createApplicationResource( $this->_loadedProfile, $name, 'update', $module); $response->appendContent('Creating a controller test file at ' . $testControllerResource->getContext()->getPath()); $testControllerResource->create();*/ } catch (Exception $e) { $response->setException($e); return; } }
/** * Implements the create action for the action-spec provider * * @param string $name * @param string $controllerName * @param string $module * @return void */ public function create($name, $controllerName, $module = null) { $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION); if (!is_dir('spec')) { throw new ProviderException('Please run zf generate phpspec, to create the environment'); } $response = $this->_registry->getResponse(); $request = $this->_registry->getRequest(); $originalName = $name; $name = LCFirst::apply($name); $camelCaseToDashFilter = new CamelCaseToDash(); $name = strtolower($camelCaseToDashFilter->filter($name)); // alert the user about inline converted names $tense = $request->isPretend() ? 'would be' : 'is'; if ($name !== $originalName) { $response->appendContent('Note: The canonical action name that ' . $tense . ' used with other providers is "' . $name . '";' . ' not "' . $originalName . '" as supplied', array('color' => array('yellow'))); } try { $controllerResource = ControllerProvider::createResource($this->_loadedProfile, $controllerName, $module); $actionResource = self::createResource($this->_loadedProfile, $name, $controllerName, $module); } catch (Exception $e) { $response->setException($e); return; } // action spec $controllerPath = str_replace(basename($controllerResource->getContext()->getPath()), '', $controllerResource->getContext()->getPath()); $basePath = realpath($controllerPath . '/../..'); $controllerSpecPath = realpath($basePath . '/spec/controllers') . '/' . $controllerName . 'ControllerSpec.php'; $specContent = $this->_getSpecContent($name, $controllerName); if ($request->isPretend()) { $response->appendContent('Would create an action named ' . $name . ' inside controller at ' . $controllerResource->getContext()->getPath()); $response->appendContent('Would create an action spec at ' . $controllerSpecPath); } else { $response->appendContent('Creating an action named ' . $name . ' inside controller at ' . $controllerResource->getContext()->getPath()); $actionResource->create(); $response->appendContent('Creating an action spec at ' . $controllerSpecPath); $content = file_get_contents($controllerSpecPath); file_put_contents($controllerSpecPath, str_replace("\n}", $specContent, $content)); } }
/** * * @group ZF-8305 */ public function testHasResourceWithNonexistentModuleDiesFatalError() { $this->assertFalse(Zend_Tool_Project_Provider_Controller::hasResource(new Zend_Tool_Project_Profile(), 'NewController', 'NonexistentModule')); }
/** * Creates the controller views and actions * * @param Registry $registry * @param Profile $profile * @param string $entity * @param string $commaSeparatedFields * @param string $module */ protected static function _createControllerViewsAndActions(Registry $registry, Profile $profile, $entity, $commaSeparatedFields, $module) { $pluralize = new Pluralize(); $entityPlural = $pluralize->filter($entity); $controllerResource = ControllerProvider::createResource($profile, $entityPlural, $module); $controllerPath = $controllerResource->getContext()->getPath(); self::_addAliasesForTheController($entity, $controllerPath); foreach (self::$_scaffoldActions as $action) { if ($action !== 'add' && $action !== 'update' && $action !== 'delete') { ViewContent::create($registry, $profile, $action, $entity, $commaSeparatedFields, $module); } ActionMethod::create($action, $entity, $controllerPath); } }