/** * Adds row to entity table, fills error collection and builds model. * @param array $data Data. * @param ErrorCollection $errorCollection Error collection. * @return \Bitrix\Disk\Internals\Model|static|null * @throws \Bitrix\Main\NotImplementedException * @internal */ public static function add(array $data, ErrorCollection $errorCollection) { $result = FileTable::add($data); if (!$result->isSuccess()) { $errorCollection->addFromResult($result); return null; } $file = static::buildFromResult($result); return $file; }
/** * Adds row to entity table, fills error collection and builds model. * @param array $data Data. * @param ErrorCollection $errorCollection Error collection. * @return \Bitrix\Disk\Internals\Model|static|null * @throws \Bitrix\Main\NotImplementedException * @internal */ public static function add(array $data, ErrorCollection $errorCollection) { $result = FileTable::add($data); if (!$result->isSuccess()) { $errorCollection->addFromResult($result); return null; } $file = static::buildFromResult($result); if ($file && $file->getCreatedBy()) { $driver = Driver::getInstance(); $driver->getRecentlyUsedManager()->push($file->getCreatedBy(), $file->getId()); } return $file; }
/** * Validates value. * Uses validating logic by table class (DataManager). * Be careful! This method may be deleted or changed. * @param $fieldName * @param $value * @param ErrorCollection $errorCollection * @return bool * @throws ArgumentException * @throws NotImplementedException * @internal */ public static function isValidValueForField($fieldName, $value, ErrorCollection $errorCollection = null) { $result = new Result(); /** @var DataManager $tableClassName */ $tableClassName = static::getTableClassName(); $tableClassName::getEntity()->getField($fieldName)->validateValue($value, null, array(), $result); if (!$result->isSuccess()) { $errorCollection && $errorCollection->addFromResult($result); return false; } return true; }
private function deleteOneNegative(array $right) { $result = RightTable::delete($right['ID']); if ($result->isSuccess()) { $this->errorCollection->addFromResult($result); return false; } $firstNegative = false; foreach ($this->getParentRights() as $parentRight) { if ($this->isEqual($parentRight, $right)) { $firstNegative = true; break; } if ($this->isOpposite($parentRight, $right)) { $firstNegative = false; break; } } if ($firstNegative) { //parent negative is like current negative right ($right) return true; } /** * Insert all simple rights in sub-tree before positive rights and negative rights. */ return true; }