/** * @param string $ability * @param mixed $arguments * @param ErrorCollection $errors * * @return bool * * @SuppressWarnings(PHPMD.StaticAccess) */ protected function checkAllow($ability, $arguments, ErrorCollection $errors) { $isAllowed = $this->getGate()->allows($ability, $arguments); if ($isAllowed === false) { $title = T::trans(T::KEY_ERR_UNAUTHORIZED); $errors->add(new Error(null, null, null, null, $title)); } return $isAllowed; }
/** * @param array $data * @param array $rules * @param Schema $schema * @param ErrorCollection $errors */ protected function validateBelongsToRelationships(array $data, array $rules, Schema $schema, ErrorCollection $errors) { $validator = $this->createValidator($data, $rules); if ($validator->fails() === true) { $map = $schema->getModelBelongsToRelationshipsToResourceMap(); $errors->addRelationshipErrorsFromMessageBag($validator->messages(), $map); } }