/** * {@inheritDoc} */ public function addTrigger(Trigger\TriggerInterface $trigger) { if (!in_array($trigger->getName(), $this->_type->validTriggers())) { throw new \LogicException('Triggers of type `' . $trigger->getName() . '` cannot be set on rewards with a type of `' . $this->_type->getName() . '`'); } if (null === $this->_triggers) { $this->_triggers = new Trigger\Collection(); } $this->_triggers->add($trigger); }
/** * {@inheritDoc} */ public function getCollectionFromType(Type\TypeInterface $type) { $collection = $this->getCollection(); foreach ($this->_completeCollection as $entity) { if (!$entity instanceof TriggerInterface) { throw new \LogicException('Entity must be an instance of TriggerInterface!'); } if (in_array($entity->getName(), $type->validTriggers())) { $collection->add($entity); } } return $collection; }