/**
  * Generates the content of an Action template
  * For some Actions default templates are provided, other Action templates will just be created emtpy
  *
  * @param string $templateRootFolder
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject_Action $action
  * @return string The generated Template code (might be empty)
  */
 public function generateDomainTemplate($templateRootFolder, Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject, Tx_ExtensionBuilder_Domain_Model_DomainObject_Action $action)
 {
     return $this->renderTemplate($templateRootFolder . $action->getName() . '.htmlt', array('domainObject' => $domainObject, 'action' => $action, 'extension' => $this->extension));
 }
예제 #2
0
 /**
  * Adding a new action
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject_Action $action The new action to add
  *
  * @return void
  */
 public function addAction(Tx_ExtensionBuilder_Domain_Model_DomainObject_Action $action)
 {
     $action->setDomainObject($this);
     if (!in_array($action, $this->actions)) {
         $this->actions[] = $action;
     }
 }
예제 #3
0
 /**
  *
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject_Action $action
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject
  *
  * @return Tx_ExtensionBuilder_Domain_Model_Class_Method
  */
 protected function buildActionMethod(Tx_ExtensionBuilder_Domain_Model_DomainObject_Action $action, Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject)
 {
     $actionName = $action->getName();
     $actionMethodName = $actionName . 'Action';
     $actionMethod = new Tx_ExtensionBuilder_Domain_Model_Class_Method($actionMethodName);
     $actionMethod->setDescription('action ' . $action->getName());
     $actionMethod->setBody($this->codeGenerator->getDefaultMethodBody($domainObject, NULL, 'Controller', '', $actionMethodName));
     $actionMethod->addModifier('public');
     if (in_array($actionName, array('show', 'edit', 'create', 'new', 'update', 'delete'))) {
         // these actions need a parameter
         if (in_array($actionName, array('create', 'new'))) {
             $parameterName = 'new' . $domainObject->getName();
         } else {
             $parameterName = t3lib_div::lcfirst($domainObject->getName());
         }
         $parameter = new Tx_ExtensionBuilder_Domain_Model_Class_MethodParameter($parameterName);
         $parameter->setTypeHint($domainObject->getClassName());
         $parameter->setVarType($domainObject->getClassName());
         $parameter->setPosition(0);
         if ($actionName == 'new') {
             $parameter->setOptional(TRUE);
             $actionMethod->setTag('dontvalidate', '$' . $parameterName);
         }
         $actionMethod->setParameter($parameter);
     }
     $actionMethod->setTag('return', 'void');
     return $actionMethod;
 }