class IntegrityViolationList
Collection of integrity violations.
Hierarchy
- class \Drupal\rules\Engine\IntegrityViolationList extends \Drupal\rules\Engine\ArrayIterator
Expanded class hierarchy of IntegrityViolationList
4 files declare their use of IntegrityViolationList
- ActionExpression.php in src/
Plugin/ RulesExpression/ ActionExpression.php - ConditionExpression.php in src/
Plugin/ RulesExpression/ ConditionExpression.php - ContextHandlerIntegrityTrait.php in src/
Context/ ContextHandlerIntegrityTrait.php - LoopExpression.php in src/
Plugin/ RulesExpression/ LoopExpression.php
File
-
src/
Engine/ IntegrityViolationList.php, line 11
Namespace
Drupal\rules\EngineView source
class IntegrityViolationList extends \ArrayIterator {
/**
* {@inheritdoc}
*/
public function add(IntegrityViolation $violation) {
$this[] = $violation;
}
/**
* {@inheritdoc}
*/
public function addAll(IntegrityViolationList $other_list) {
foreach ($other_list as $violation) {
$this[] = $violation;
}
}
/**
* Returns the violation at a given offset.
*
* @param int $offset
* The offset of the violation.
*
* @return \Drupal\rules\Engine\IntegrityViolationInterface
* The violation.
*
* @throws \Drupal\rules\Exception\OutOfBoundsException
* Thrown if the offset does not exist.
*/
public function get($offset) {
try {
return $this->offsetGet($offset);
} catch (\OutOfBoundsException $e) {
throw new OutOfBoundsException();
}
}
/**
* Returns whether the given offset exists.
*
* @param int $offset
* The violation offset.
*
* @return bool
* Whether the offset exists.
*/
public function has($offset) {
return $this->offsetExists($offset);
}
/**
* Creates a new violation with the message and adds it to this list.
*
* @param \Drupal\Core\StringTranslation\TranslatableMarkup $message
* The violation message.
* @param string $uuid
* (optional) UUID of the expression where the violation occurred.
*/
public function addViolationWithMessage(TranslatableMarkup $message, $uuid = NULL) {
$violation = new IntegrityViolation();
$violation->setMessage($message);
$violation->setUuid($uuid);
$this[] = $violation;
}
/**
* {@inheritdoc}
*/
public function getFor($uuid) {
$uuid_violations = [];
foreach ($this as $violation) {
if ($violation->getUuid() === $uuid) {
$uuid_violations[] = $violation;
}
}
return $uuid_violations;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
IntegrityViolationList::add | public | function | |
IntegrityViolationList::addAll | public | function | |
IntegrityViolationList::addViolationWithMessage | public | function | Creates a new violation with the message and adds it to this list. |
IntegrityViolationList::get | public | function | Returns the violation at a given offset. |
IntegrityViolationList::getFor | public | function | |
IntegrityViolationList::has | public | function | Returns whether the given offset exists. |