Пример #1
0
 /**
  * @inheritdoc
  */
 public function build(CreateGoalsTask $createTask, array $options = [])
 {
     $eventNameTemplate = isset($options[self::EVENT_NAME_TEMPLATE]) ? $options[self::EVENT_NAME_TEMPLATE] : '%prefix%Event';
     $goalName = isset($options[self::GOAL_NAME]) ? $options[self::GOAL_NAME] : uniqid('Goal-');
     $goalConfig = ['name' => $goalName, 'type' => 'action', 'conditions' => [['type' => 'exact', 'url' => str_replace('%prefix%', $createTask->getEventPrefix(), $eventNameTemplate)]], 'class' => 0];
     return new \ArrayIterator([new Goal($goalConfig)]);
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function build(CreateGoalsTask $createTask, array $options = [])
 {
     if (!isset($options[self::EVENTS])) {
         throw new \RuntimeException(self::EVENTS . ' option is not set.');
     }
     $goalName = isset($options[self::GOAL_NAME]) ? $options[self::GOAL_NAME] : uniqid('Goal-');
     $goalConfig = ['name' => $goalName, 'type' => 'step', 'steps' => [], 'class' => 0];
     $position = 1;
     foreach ($options[self::EVENTS] as $eventOptions) {
         $goalConfig['steps'][] = $this->buildStep($eventOptions, $position++, $createTask->getEventPrefix());
     }
     return new \ArrayIterator([new Goal($goalConfig)]);
 }