save() 공개 메소드

Save script model
public save ( ) : integer
리턴 integer
예제 #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->script = ScriptModel::fromArray(array('name' => 'Script name', 'identifier' => 'script-identifier', 'description' => 'Script description', 'content' => 'script Content'));
     $this->script->save();
     $serviceManager = Registry::get('Application')->getServiceManager();
     $this->object = new Script($serviceManager);
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', DocumentModel::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
 }
예제 #2
0
 protected function createContent()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewContentIdentifier', 'description' => 'Description', 'content' => 'Content of the webpage <br/>This is my view'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout', 'identifier' => 'LayoutContentIdentifier', 'description' => 'Description', 'content' => '<?php echo $this->content; '));
     $this->layout->save();
     $this->script = ScriptModel::fromArray(array('name' => 'Script', 'identifier' => 'ScriptContentIdentifier', 'description' => 'Description', 'content' => ''));
     $this->script->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->documentType->setDependencies(array($this->documentType->getId()));
     $this->documentType->addView($this->view->getId());
     $this->documentType->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $this->datatype->save();
     $this->tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $this->documentType->getId()));
     $this->tabModel->save();
     $this->property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'azd', 'description' => 'test', 'tab_id' => $this->tabModel->getId(), 'datatype_id' => $this->datatype->getId(), 'is_required' => true));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => '', 'status' => DocumentModel::STATUS_ENABLE, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $this->document->save();
     $this->property->setDocumentId($this->document->getId());
     $this->property->setValue('string');
     $this->property->saveValue();
 }
예제 #3
0
 /**
  * Create script
  *
  * @return \Zend\Script\Model\ScriptModel
  */
 public function createAction()
 {
     $scriptForm = new ScriptForm();
     $scriptForm->setAttribute('action', $this->url()->fromRoute('development/script/create'));
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost()->toArray();
         $scriptForm->setData($data);
         if (!$scriptForm->isValid()) {
             $this->flashMessenger()->addErrorMessage('Can not save script');
             $this->useFlashMessenger();
         } else {
             $scriptModel = new Script\Model();
             $scriptModel->setName($scriptForm->getValue('name'));
             $scriptModel->setIdentifier($scriptForm->getValue('identifier'));
             $scriptModel->setDescription($scriptForm->getValue('description'));
             $scriptModel->setContent($scriptForm->getValue('content'));
             $scriptModel->save();
             $this->flashMessenger()->addSuccessMessage('This script has been created');
             return $this->redirect()->toRoute('development/script/edit', array('id' => $scriptModel->getId()));
         }
     }
     return array('form' => $scriptForm);
 }