Пример #1
0
 public function testApply()
 {
     $config = ["level1" => ["level2" => ["level3" => "123"], "level2-1" => ["level3-1" => "321"]]];
     $object = new Container($config);
     $this->assertEquals("123", $object->level1["level2"]->level3);
     $reverse = function ($v) {
         return strrev($v);
     };
     $object->apply(["level1" => ["level2" => ["level3" => $reverse], "level2-1" => ["level3-1" => $reverse]]]);
     $compare = ["level1" => ["level2" => ["level3" => "321"], "level2-1" => ["level3-1" => "123"]]];
     $this->assertEquals($compare, $object->toArray());
     $object->apply(function () {
         return null;
     });
     $this->assertEquals(["level1" => null], $object->toArray());
 }
Пример #2
0
 /**
  * @return array
  */
 public function toArray()
 {
     $tmp = new Container(null, []);
     foreach ($this->changesTracker as $itemKey => $opType) {
         if ($opType == ITEM_OPERATION_ADD || $opType == ITEM_OPERATION_NEW_VALUE) {
             $tmp->set($this->get($itemKey));
         }
     }
     return $tmp->toArray();
 }
Пример #3
0
 /**
  * Returns an array representation of the page
  *
  * @return array  associative array containing all page properties
  */
 public function toArray()
 {
     return array_merge($this->getCustomProperties(), array('label' => $this->getlabel(), 'fragment' => $this->getFragment(), 'id' => $this->getId(), 'class' => $this->getClass(), 'title' => $this->getTitle(), 'target' => $this->getTarget(), 'accesskey' => $this->getAccesskey(), 'rel' => $this->getRel(), 'rev' => $this->getRev(), 'customHtmlAttribs' => $this->getCustomHtmlAttribs(), 'order' => $this->getOrder(), 'resource' => $this->getResource(), 'privilege' => $this->getPrivilege(), 'active' => $this->isActive(), 'visible' => $this->isVisible(), 'type' => get_class($this), 'pages' => parent::toArray()));
 }
Пример #4
0
 public function save(Container $row)
 {
     $id = isAke($row->toArray(), 'id', null);
     return is_null($id) ? $this->add($row) : $this->insertRow($this->toArray($row));
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $this->fillSpan();
     return parent::toArray();
 }
 /**
  * allow to join two blue objects into one
  *
  * @param \BlueContainer\Container $object
  * @return $this
  */
 public function mergeBlueObject(Container $object)
 {
     $newData = $object->toArray();
     foreach ($newData as $key => $value) {
         $this->appendData($key, $value);
     }
     $this->_dataChanged = true;
     return $this;
 }