示例#1
0
 /**
  * Add site
  *
  * @return \BX\MVC\SiteController
  * @throws InvalidArgumentException
  */
 public function addSite()
 {
     foreach (func_get_args() as $site) {
         if (!$site instanceof SiteEntity) {
             throw new InvalidArgumentException('Error site must be Site type');
         }
         if (!$site->checkFields()) {
             $this->log()->error('Site add error: ' . implode(',', $site->getErrors()->all()));
             throw new InvalidArgumentException('Error validate site');
         }
         $this->site->add($site);
     }
     return $this;
 }
示例#2
0
文件: Repository.php 项目: jarick/bx
 /**
  * Execute sql query
  * @param Collection $collection
  * @return boolean
  */
 private function send(Collection $collection)
 {
     foreach ($collection as $update) {
         if (!$update->commit()) {
             if ($this->bad_entity === null) {
                 $this->bad_entity = $update->getEntity();
             }
             return false;
         } else {
             $this->success->add($update);
         }
     }
     return true;
 }
示例#3
0
文件: SqlBuilder.php 项目: jarick/bx
 /**
  * Convert values from db
  * @param array $values
  * @return \BX\Base\Collection
  */
 public function convertFromArray(array $values)
 {
     $collection = new Collection($this->entity_class);
     foreach ($values as $value) {
         $entity = new $this->entity_class();
         $entity->setData($this->prepareArrayFromDb($value), true);
         $collection->add($entity);
     }
     return $collection;
 }