/**
  * @param AbstractItem $existedItem
  * @param array $data
  * @return AbstractItem|null
  */
 protected function _updateItem(AbstractItem $existedItem, array $data)
 {
     $previousId = $existedItem->getId();
     $foundItem = $this->_getItem($existedItem->getArrayCopy());
     if (empty($foundItem)) {
         return null;
     }
     $foundItem->update($data);
     if (isset($this->_storage[$previousId])) {
         unset($this->_storage[$previousId]);
     }
     $this->_storage[$foundItem->getId()] = $foundItem;
     return $foundItem;
 }
Example #2
0
 /**
  * Constructor
  *
  * @param $data     All data of this item received from api.
  */
 public function __construct($data)
 {
     if ($data->comments->count > 0) {
         foreach ($data->comments->data as $comment_data) {
             $this->_comments[] = new Comment($comment_data);
         }
     }
     parent::__construct($data);
 }
Example #3
0
 /**
  * @param string|null $label
  * @param string|null $uri
  */
 public function __construct($label = null, $uri = null)
 {
     parent::__construct();
     if (null !== $label) {
         $this->label = $label;
     }
     if (null !== $uri) {
         $this->uri = $uri;
     }
 }
Example #4
0
 public function save($deep = true)
 {
     if ($this->isFieldDirty('Data') && $this->Media) {
         if ($this->Content) {
             $this->Media->ContextClass = $this->Content->getRootClass();
             $this->Media->ContextID = $this->ContentID;
         }
         if (array_key_exists('Caption', $this->Data)) {
             $this->Media->Caption = $this->Data['Caption'];
             unset($this->Data['Caption']);
         }
         $this->Media->save();
     }
     parent::save($deep);
 }
 /**
  * {@inheritdoc}
  */
 public function isTypeOf($type_name)
 {
     return $type_name === 'block' || parent::isTypeOf($type_name);
 }
 public function __construct($key, $label, $url, $icon = null, $permission = null, AbstractMenuList $children = null)
 {
     parent::__construct($key, $label, $url, $icon, $permission, $children);
 }
Example #7
0
 /**
  * @param array|string $idOrData
  */
 public function __construct($idOrData)
 {
     $idOrData = is_string($idOrData) ? ['id' => $idOrData] : $idOrData;
     $idOrData = array_merge(['id' => uniqid('B'), 'name' => '', 'itemsAmount' => 0, 'totalPrice' => 0], $idOrData);
     parent::__construct(static::_parse($idOrData), \ArrayObject::ARRAY_AS_PROPS, 'ArrayIterator');
 }
Example #8
0
 /**
  * Checks wether a specific item already is registered
  *
  * @param Game\AbstractItem $item
  * @return boolean true when already in stack
  */
 protected function itemExists(AbstractItem $item)
 {
     foreach ($this->itemsWithQuantity as $itemWithQuantity) {
         if ($itemWithQuantity[0]->getName() === $item->getName()) {
             return true;
         }
     }
     return false;
 }
Example #9
0
 public function __construct($cost, $damage, $armor)
 {
     parent::__construct($cost, $damage, $armor);
 }