| @@ 40-55 (lines=16) @@ | ||
| 37 | /** |
|
| 38 | * @inheritdoc |
|
| 39 | */ |
|
| 40 | public function addModifier(ModifierInterface $modifier, $position = null, $continue = null) |
|
| 41 | { |
|
| 42 | if (null === $position) { |
|
| 43 | $position = sizeof($this->modifiers) ? (max(array_keys($this->modifiers)) + 1) : 0; |
|
| 44 | } |
|
| 45 | ||
| 46 | if (null === $continue) { |
|
| 47 | $continue = (!$modifier instanceof FilterInterface) && (!$modifier instanceof ValidatorInterface); |
|
| 48 | } |
|
| 49 | ||
| 50 | if (array_key_exists($position, $this->modifiers)) { |
|
| 51 | throw new \InvalidArgumentException(sprintf('There already is a modifier at position %d', $position)); |
|
| 52 | } |
|
| 53 | ||
| 54 | $this->modifiers[$position] = [$modifier, $continue]; |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * @inheritdoc |
|
| @@ 58-73 (lines=16) @@ | ||
| 55 | * |
|
| 56 | * @throws \InvalidArgumentException If there already is a modifier at the given position |
|
| 57 | */ |
|
| 58 | public function addModifier(ModifierInterface $modifier, $position = null, $continue = null) |
|
| 59 | { |
|
| 60 | if (null === $position) { |
|
| 61 | $position = sizeof($this->modifiers) ? (max(array_keys($this->modifiers)) + 1) : 0; |
|
| 62 | } |
|
| 63 | ||
| 64 | if (null === $continue) { |
|
| 65 | $continue = (!$modifier instanceof FilterInterface) && (!$modifier instanceof ValidatorInterface); |
|
| 66 | } |
|
| 67 | ||
| 68 | if (array_key_exists($position, $this->modifiers)) { |
|
| 69 | throw new \InvalidArgumentException(sprintf('There already is a modifier at position %d', $position)); |
|
| 70 | } |
|
| 71 | ||
| 72 | $this->modifiers[$position] = [$modifier, $continue]; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * Adds the given modifier between the start and end index, if there is a vacant position. |
|