/** * 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; }
/** * 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; }
/** * 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; }