/** * Generates: User does not have access to '{$function}' '{$module}'[ with: %property.key% '%property.value%'] * * Example: User does not have access to 'read' 'content' with: id '44', type 'article' * * @param string $module The module name should be in sync with the name of the domain object in question * @param string $function * @param array $properties Key value pair with non sensitive data on what kind of data user does not have access to * @param \Exception|null $previous */ public function __construct($module, $function, array $properties = null, Exception $previous = null) { $identificationString = ''; if ($properties !== null) { foreach ($properties as $name => $value) { $identificationString .= $identificationString === '' ? ' with:' : ','; $identificationString .= " {$name} '{$value}'"; } } parent::__construct("User does not have access to '{$function}' '{$module}'" . $identificationString, self::UNAUTHORIZED, $previous); }
/** * Generates: User does not have access to '{$function}' '{$module}'[ with: %property.key% '%property.value%']. * * Example: User does not have access to 'read' 'content' with: id '44', type 'article' * * @param string $module The module name should be in sync with the name of the domain object in question * @param string $function * @param array $properties Key value pair with non sensitive data on what kind of data user does not have access to * @param \Exception|null $previous */ public function __construct($module, $function, array $properties = null, Exception $previous = null) { $this->setMessageTemplate("User does not have access to '%function%' '%module%'"); $this->setParameters(['%module%' => $module, '%function%' => $function]); if ($properties) { $this->setMessageTemplate("User does not have access to '%function%' '%module%' with: %with%'"); $with = []; foreach ($properties as $name => $value) { $with[] = "{$name} '{$value}'"; } $this->addParameter('%with%', implode(', ', $with)); } parent::__construct($this->getBaseTranslation(), self::UNAUTHORIZED, $previous); }