/** * 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, '#'); } }
/** * Handle the command. * * @param Container $container * @param ViewTemplate $template * @param BreadcrumbCollection $breadcrumbs */ public function handle(Container $container, ViewTemplate $template, BreadcrumbCollection $breadcrumbs) { $form = $this->builder->getForm(); if ($handler = $form->getOption('data')) { $container->call($handler, compact('form')); } if ($layout = $form->getOption('layout_view')) { $template->put('layout', $layout); } if ($title = $form->getOption('title')) { $template->put('title', $title); } // Move this to options so we can read it. $this->builder->setFormOption('read_only', $this->builder->isReadOnly()); $form->addData('form', $form); if ($breadcrumb = $form->getOption('breadcrumb', 'streams::form.mode.' . $this->builder->getFormMode())) { $breadcrumbs->put($breadcrumb, '#'); } }
/** * Handle the command. * * @param Request $request * @param Authorizer $authorizer * @param BreadcrumbCollection $breadcrumbs */ public function handle(Request $request, Authorizer $authorizer, BreadcrumbCollection $breadcrumbs) { $links = $this->builder->getControlPanelNavigation(); /** * If we already have an active link * then we don't need to do this. */ if ($active = $links->active()) { return; } /* @var NavigationLinkInterface $link */ foreach ($links as $link) { /** * Get the HREF for both the active * and loop iteration link. */ $href = array_get($link->getAttributes(), 'data-href', array_get($link->getAttributes(), 'href')); $activeHref = ''; if ($active && $active instanceof NavigationLinkInterface) { $activeHref = array_get($active->getAttributes(), 'data-href', array_get($active->getAttributes(), 'href')); } /** * If the request URL does not even * contain the HREF then skip it. */ if (!str_contains($request->url(), $href)) { continue; } /** * Compare the length of the active HREF * and loop iteration HREF. The longer the * HREF the more detailed and exact it is and * the more likely it is the active HREF and * therefore the active link. */ $hrefLength = strlen($href); $activeHrefLength = strlen($activeHref); if ($hrefLength > $activeHrefLength) { $active = $link; } } // No active link! if (!$active) { return; } // Active navigation link! $active->setActive(true); // Authorize the active link. if (!$authorizer->authorize($active->getPermission())) { abort(403); } // Add the bread crumb. if (($breadcrumb = $active->getBreadcrumb()) !== false) { $breadcrumbs->put($breadcrumb ?: $active->getTitle(), $active->getHref()); } }
/** * Return a form for an existing post type field and assignment. * * @param AssignmentFormBuilder $form * @param TypeRepositoryInterface $types * @param BreadcrumbCollection $breadcrumbs * @param $id * @return \Symfony\Component\HttpFoundation\Response */ public function assignment(AssignmentFormBuilder $form, TypeRepositoryInterface $types, BreadcrumbCollection $breadcrumbs, $id, $assignment) { $type = $types->find($id); $breadcrumbs->put('module::breadcrumb.fields', 'admin/posts/types/fields/' . $type->getId()); return $form->render($assignment); }
/** * Return a form for an existing page type field and assignment. * * @param AssignmentFormBuilder $form * @param StreamRepositoryInterface $streams * @param TypeRepositoryInterface $types * @param BreadcrumbCollection $breadcrumbs * @param $id * @return \Symfony\Component\HttpFoundation\Response */ public function assignment(AssignmentFormBuilder $form, StreamRepositoryInterface $streams, TypeRepositoryInterface $types, BreadcrumbCollection $breadcrumbs, $id, $assignment) { $type = $types->find($id); $breadcrumbs->put('streams::breadcrumb.assignments', 'admin/pages/types/assignments/' . $type->getId()); return $form->render($assignment); }
/** * Handle the command. * * @param Request $request * @param Authorizer $authorizer * @param BreadcrumbCollection $breadcrumbs */ public function handle(Request $request, Authorizer $authorizer, BreadcrumbCollection $breadcrumbs) { $controlPanel = $this->builder->getControlPanel(); $sections = $controlPanel->getSections(); /* * If we already have an active section * then we don't need to do this. */ if ($active = $sections->active()) { return; } /* @var SectionInterface $section */ foreach ($sections as $section) { if (($matcher = $section->getMatcher()) && str_is($matcher, $request->path())) { $active = $section; } /* * Get the HREF for both the active * and loop iteration section. */ $href = $section->getPermalink() ?: array_get($section->getAttributes(), 'href'); $activeHref = ''; if ($active && $active instanceof SectionInterface) { $activeHref = $active->getPermalink() ?: array_get($active->getAttributes(), 'href'); } /* * If the request URL does not even * contain the HREF then skip it. */ if (!str_contains($request->url(), $href)) { continue; } /* * Compare the length of the active HREF * and loop iteration HREF. The longer the * HREF the more detailed and exact it is and * the more likely it is the active HREF and * therefore the active section. */ $hrefLength = strlen($href); $activeHrefLength = strlen($activeHref); if ($hrefLength > $activeHrefLength) { $active = $section; } } /** * If we have an active section determined * then mark it as such. * * @var SectionInterface $active * @var SectionInterface $section */ if ($active) { if ($active->getParent()) { $active->setActive(true); $section = $sections->get($active->getParent(), $sections->first()); $section->setHighlighted(true); $breadcrumbs->put($section->getBreadcrumb() ?: $section->getTitle(), $section->getHref()); } else { $active->setActive(true)->setHighlighted(true); } } elseif ($active = $sections->first()) { $active->setActive(true)->setHighlighted(true); } // No active section! if (!$active) { return; } // Authorize the active section. if (!$authorizer->authorize($active->getPermission())) { abort(403); } // Add the bread crumb. if (($breadcrumb = $active->getBreadcrumb()) !== false) { $breadcrumbs->put($breadcrumb ?: $active->getTitle(), $active->getHref()); } }