/** * Handle the command. * * @param GetSegmentValue $command * @return mixed */ public function handle(GetSegmentValue $command) { $entry = $command->getEntry(); $tree = $command->getTree(); $segment = $command->getSegment(); return $this->value->make($tree, $segment, $entry); }
/** * Build the segments. * * @param TreeBuilder $builder * @param $entry * @return SegmentCollection */ public function build(TreeBuilder $builder, $entry) { $tree = $builder->getTree(); $segments = new SegmentCollection(); if (!$builder->getSegments()) { $builder->setSegments(['entry.edit_link']); } $this->input->read($builder, $entry); foreach ($builder->getSegments() as $segment) { array_set($segment, 'entry', $entry); $segment = $this->evaluator->evaluate($segment, compact('entry', 'tree')); if (array_get($segment, 'enabled', null) === false) { continue; } $segment['value'] = $this->value->make($tree, $segment, $entry); $segments->push($this->factory->make($segment)); } return $segments; }