コード例 #1
0
 /**
  * @see Stockpile_Interface::add();
  * on insert, set the pos column of the sort table to match current time.
  * on dupe key violation, update the pos column to match current time
  */
 public function add($item_id, $quantity = 1, array $data = NULL)
 {
     $res = $this->core->add($item_id, $quantity, $data);
     try {
         $this->storage('sorter')->sort(Base::time(), array($item_id));
     } catch (Exception $e) {
         throw $this->handle($e);
     }
     if ($this->cacher) {
         $this->cacher->set($item_id, $now, $this->cacheTimeout());
         Transaction::onRollback(array($this->cacher, 'delete'), array($item_id));
     }
     return $res;
 }
コード例 #2
0
 /**
  * @see Stockpile_Interface::add();
  * only bump up to the top the first time we add this item id to the inventory.
  * after that, just let it slide.
  */
 public function add($item_id, $quantity = 1, array $data = NULL)
 {
     $res = $this->core->add($item_id, $quantity, $data);
     $now = Base::time();
     try {
         $ct = $this->storage('sorter')->sort($now, array($item_id), $ignore = TRUE);
     } catch (\Exception $e) {
         throw $this->handle($e);
     }
     if ($ct < 1 || !$this->cacher) {
         return $res;
     }
     $this->cacher->set($item_id, $now, 0, $this->cacheTimeout());
     if ($this->inTran()) {
         Transaction::onRollback(array($cache, 'delete'), array($item_id));
     }
     return $res;
 }
コード例 #3
0
 public static function now()
 {
     return Base::time();
 }