예제 #1
0
 /**
  * @param array $args (name, type, target, value)
  * @throws InvalidConditionException
  */
 public function __construct(array $args)
 {
     $this->args = $args;
     if (Helpers::isMultiArray($args)) {
         throw new Exception('Multi dimensional array is not supported.');
     } else {
         $this->validate($this->args);
     }
 }
예제 #2
0
 public function addTotal($params = [])
 {
     if (Helpers::isMultiArray($params)) {
         foreach ($params as $total) {
             $this->addTotal($total);
         }
     }
     $total = new Total($params);
     $id = $params['id'];
     if ($this->has($id)) {
         $this->updateTotal($id, $total);
     } else {
         Event::fire($this->instance . '.adding', [$total, $this]);
         $this->put($id, $total);
         Event::fire($this->instance . '.added', [$total, $this]);
     }
 }
예제 #3
0
 public function addItem($params = [])
 {
     if (Helpers::isMultiArray($params)) {
         foreach ($params as $item) {
             $this->addItem($item);
         }
     }
     $item = new Item($params);
     $id = $params['id'];
     if ($this->has($id)) {
         $this->updateItem($id, $item);
     } else {
         Event::fire($this->instance . '.adding', [$item, $this]);
         $this->put($id, $item);
         Event::fire($this->instance . '.added', [$item, $this]);
     }
 }