示例#1
0
 /**
  * {@inheritdoc}
  */
 public function rewind()
 {
     $this->action = $this->context->getAction();
     $this->index = -1;
     $this->maxIndex = isset($this->processors[$this->action]) ? count($this->processors[$this->action]) - 1 : -1;
     $this->nextApplicable();
 }
 /**
  * {@inheritdoc}
  */
 public function isApplicable(ContextInterface $context, array $processorAttributes)
 {
     if (null === $this->processorBag || empty($processorAttributes['group']) || !$context->getFirstGroup() && !$context->getLastGroup()) {
         return self::ABSTAIN;
     }
     $this->ensureGroupsLoaded($context->getAction());
     $group = $processorAttributes['group'];
     if (isset($this->groups[$group])) {
         $groupIndex = $this->groups[$group];
         $firstGroup = $context->getFirstGroup();
         if ($firstGroup && isset($this->groups[$firstGroup]) && $groupIndex < $this->groups[$firstGroup]) {
             return self::NOT_APPLICABLE;
         }
         $lastGroup = $context->getLastGroup();
         if ($lastGroup && isset($this->groups[$lastGroup]) && $groupIndex > $this->groups[$lastGroup]) {
             return self::NOT_APPLICABLE;
         }
     }
     return self::ABSTAIN;
 }