fromArray() public static method

Initiliaze from array
public static fromArray ( array $array ) : Model
$array array Data
return Model
Esempio n. 1
0
 /**
  * Test
  *
  * @return void
  */
 public function testDelete()
 {
     $array = array('name' => 'Test Identifier', 'identifier' => 'test-delete-identifier', 'description' => 'Description', 'content' => 'Content');
     $model = $this->object->fromArray($array);
     $model->save();
     $this->assertTrue($model->delete());
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 /**
  * Get scripts
  *
  * @param boolean $forceReload to initiliaze scripts
  *
  * @return array
  */
 public function getScripts($forceReload = false)
 {
     if ($forceReload or $this->getData('scripts') === null) {
         $rows = $this->fetchAll($this->select(function (Select $select) {
             $select->order('name ASC');
         }));
         $scripts = array();
         foreach ($rows as $row) {
             $scripts[] = Model::fromArray((array) $row);
         }
         $this->setData('scripts', $scripts);
     }
     return $this->getData('scripts');
 }
Esempio n. 4
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();
 }
Esempio n. 5
0
 /**
  * Test
  *
  * @return void
  */
 public function testDownloadActionWithoutId()
 {
     $scriptModel = ScriptModel::fromArray(array('name' => 'ScriptName', 'identifier' => 'ScriptIdentifier', 'content' => 'Content'));
     $scriptModel->save();
     $this->dispatch('/admin/development/script/download');
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcDevelopment');
     $this->assertControllerName('ScriptController');
     $this->assertControllerClass('ScriptController');
     $this->assertMatchedRouteName('development/script/download');
     $scriptModel->delete();
 }