Example #1
0
 protected function setAttributesFromResult(Result $result)
 {
     if (!$result->isSuccess()) {
         throw new ArgumentException('Result is not success');
     }
     $attributes = $result->getData();
     if ($result instanceof AddResult) {
         $attributes['ID'] = $result->getId();
     }
     return $this->setAttributes($attributes);
 }
Example #2
0
 /**
  * Builds model from \Bitrix\Main\Entity\Result.
  * @param Result $result Query result.
  * @return static
  * @throws \Bitrix\Main\ArgumentException
  */
 public static function buildFromResult(Result $result)
 {
     $data = $result->getData();
     if ($result instanceof AddResult) {
         $data['ID'] = $result->getId();
     }
     $className = static::getClassNameModel($data);
     /** @var BaseObject $model */
     $model = new $className();
     return $model->setAttributesFromResult($result);
 }