/** * Handle the command. */ public function handle() { $tree = $this->builder->getTree(); $model = $this->builder->getModel(); /** * If the model is already instantiated * then use it as is. */ if (is_object($model)) { $tree->setModel($model); return; } /** * If no model is set, try guessing the * model based on best practices. */ if (!$model) { $parts = explode('\\', str_replace('TreeBuilder', 'Model', get_class($this->builder))); unset($parts[count($parts) - 2]); $model = implode('\\', $parts); $this->builder->setModel($model); } /** * If the model is not set then skip it. */ if (!class_exists($model)) { return; } /** * Set the model on the tree! */ $tree->setModel(app($model)); }
/** * Handle the command. * * @param ResponseFactory $response */ public function handle(ResponseFactory $response) { $tree = $this->builder->getTree(); $options = $tree->getOptions(); $data = $tree->getData(); $tree->setResponse($response->view($options->get('wrapper_view', 'streams::blank'), $data)); }
/** * Handle the command. */ public function handle() { $tree = $this->builder->getTree(); $model = $tree->getModel(); /** * If a repository is set * then we don't have * anything to do. */ if ($this->builder->getTreeRepository()) { return; } $repository = $tree->getOption('repository'); /** * If there is no repository * then skip this step. */ if (!$repository) { return; } /** * Set the repository on the form! */ $tree->setRepository(app()->make($repository, compact('model', 'tree'))); }
/** * Handle the command. */ public function handle() { $tree = $this->builder->getTree(); $options = $tree->getOptions(); $data = $tree->getData(); $content = view($options->get('tree_view', 'streams::tree/tree'), $data)->render(); $tree->setContent($content); $tree->addData('content', $content); }
/** * Handle the command. * * @param Resolver $resolver * @param Evaluator $evaluator */ public function handle(Resolver $resolver, Evaluator $evaluator) { $arguments = ['builder' => $this->builder]; $tree = $this->builder->getTree(); $options = $this->builder->getOptions(); $options = $resolver->resolve($options, $arguments); $options = $evaluator->evaluate($options, $arguments); foreach ($options as $key => $value) { $tree->setOption($key, $value); } }
/** * Handle the command. */ public function handle() { $tree = $this->builder->getTree(); /* * Set the default options handler based * on the builder class. Defaulting to * no handler. */ if (!$tree->getOption('options')) { $options = str_replace('TreeBuilder', 'TreeOptions', get_class($this->builder)); if (class_exists($options)) { app()->call($options . '@handle', compact('builder', 'tree')); } } /* * Set the default data handler based * on the builder class. Defaulting to * no handler. */ if (!$tree->getOption('data')) { $options = str_replace('TreeBuilder', 'TreeData', get_class($this->builder)); if (class_exists($options)) { $tree->setOption('data', $options . '@handle'); } } /* * Set a optional entries handler based * on the builder class. Defaulting to * no handler in which case we will use * the model and included repositories. */ if (!$tree->getOption('entries')) { $entries = str_replace('TreeBuilder', 'TreeEntries', get_class($this->builder)); if (class_exists($entries)) { $tree->setOption('entries', $entries . '@handle'); } } /* * Set the default options handler based * on the builder class. Defaulting to * no handler. */ if (!$tree->getOption('repository')) { $model = $tree->getModel(); if (!$tree->getOption('repository') && $model instanceof EntryModel) { $tree->setOption('repository', EntryTreeRepository::class); } if (!$tree->getOption('repository') && $model instanceof EloquentModel) { $tree->setOption('repository', EloquentTreeRepository::class); } } }
/** * Handle the command. */ public function handle() { $tree = $this->builder->getTree(); $model = $this->builder->getModel(); if (is_string($model) && !class_exists($model)) { return; } if (is_string($model)) { $model = app($model); } if ($model instanceof EntryInterface) { $tree->setStream($model->getStream()); } }
/** * Handle the command. * * @param Container $container * @param ViewTemplate $template * @param BreadcrumbCollection $breadcrumbs */ public function handle(Container $container, ViewTemplate $template, BreadcrumbCollection $breadcrumbs) { $tree = $this->builder->getTree(); $tree->addData('tree', $tree); if ($handler = $tree->getOption('data')) { $container->call($handler, compact('tree')); } if ($layout = $tree->getOption('layout_view')) { $template->put('layout', $layout); } if ($title = $tree->getOption('title')) { $template->put('title', $title); } if ($breadcrumb = $tree->getOption('breadcrumb')) { $breadcrumbs->put($breadcrumb, '#'); } }
/** * Build the buttons. * * @param TreeBuilder $builder * @param $entry * @return ButtonCollection */ public function build(TreeBuilder $builder, $entry) { $tree = $builder->getTree(); $buttons = new ButtonCollection(); $this->input->read($builder, $entry); foreach ($builder->getButtons() as $button) { if (!array_get($button, 'enabled', true)) { continue; } $button = $this->evaluator->evaluate($button, compact('entry', 'tree')); $button = $this->parser->parse($button, $entry); $button = $this->factory->make($button); $buttons->push($button); } return $buttons; }
/** * 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; }