|
@@ -1937,12 +1937,22 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
return $this->getParent()->getBreadcrumbs($action);
|
|
return $this->getParent()->getBreadcrumbs($action);
|
|
}
|
|
}
|
|
|
|
|
|
- return $this->buildBreadcrumbs($action);
|
|
|
|
|
|
+ $menu = $this->buildBreadcrumbs($action);
|
|
|
|
+
|
|
|
|
+ do {
|
|
|
|
+ $breadcrumbs[] = $menu;
|
|
|
|
+ } while ($menu = $menu->getParent());
|
|
|
|
+
|
|
|
|
+ $breadcrumbs = array_reverse($breadcrumbs);
|
|
|
|
+ array_shift($breadcrumbs);
|
|
|
|
+ return $breadcrumbs;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Generates the breadcrumbs array
|
|
* Generates the breadcrumbs array
|
|
*
|
|
*
|
|
|
|
+ * Note: the method will be called by the top admin instance (parent => child)
|
|
|
|
+ *
|
|
* @param string $action
|
|
* @param string $action
|
|
* @param \Knp\Menu\ItemInterface|null $menu
|
|
* @param \Knp\Menu\ItemInterface|null $menu
|
|
*
|
|
*
|
|
@@ -1956,14 +1966,14 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
|
|
|
if (!$menu) {
|
|
if (!$menu) {
|
|
$menu = $this->menuFactory->createItem('root');
|
|
$menu = $this->menuFactory->createItem('root');
|
|
- }
|
|
|
|
|
|
|
|
- $child = $menu->addChild(
|
|
|
|
- $this->trans($this->getLabelTranslatorStrategy()->getLabel('dashboard', 'breadcrumb', 'link'), array(), 'SonataAdminBundle'),
|
|
|
|
- array('uri' => $this->routeGenerator->generate('sonata_admin_dashboard'))
|
|
|
|
- );
|
|
|
|
|
|
+ $menu = $menu->addChild(
|
|
|
|
+ $this->trans($this->getLabelTranslatorStrategy()->getLabel('dashboard', 'breadcrumb', 'link'), array(), 'SonataAdminBundle'),
|
|
|
|
+ array('uri' => $this->routeGenerator->generate('sonata_admin_dashboard'))
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
|
|
- $child = $child->addChild(
|
|
|
|
|
|
+ $menu = $menu->addChild(
|
|
$this->trans($this->getLabelTranslatorStrategy()->getLabel(sprintf('%s_list', $this->getClassnameLabel()), 'breadcrumb', 'link')),
|
|
$this->trans($this->getLabelTranslatorStrategy()->getLabel(sprintf('%s_list', $this->getClassnameLabel()), 'breadcrumb', 'link')),
|
|
array('uri' => $this->hasRoute('list') && $this->isGranted('LIST') ? $this->generateUrl('list') : null)
|
|
array('uri' => $this->hasRoute('list') && $this->isGranted('LIST') ? $this->generateUrl('list') : null)
|
|
);
|
|
);
|
|
@@ -1973,45 +1983,37 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
if ($childAdmin) {
|
|
if ($childAdmin) {
|
|
$id = $this->request->get($this->getIdParameter());
|
|
$id = $this->request->get($this->getIdParameter());
|
|
|
|
|
|
- $child = $child->addChild(
|
|
|
|
|
|
+ $menu = $menu->addChild(
|
|
$this->toString($this->getSubject()),
|
|
$this->toString($this->getSubject()),
|
|
array('uri' => $this->hasRoute('edit') && $this->isGranted('EDIT') ? $this->generateUrl('edit', array('id' => $id)) : null)
|
|
array('uri' => $this->hasRoute('edit') && $this->isGranted('EDIT') ? $this->generateUrl('edit', array('id' => $id)) : null)
|
|
);
|
|
);
|
|
|
|
|
|
- return $childAdmin->buildBreadcrumbs($action, $child);
|
|
|
|
|
|
+ return $childAdmin->buildBreadcrumbs($action, $menu);
|
|
|
|
|
|
} elseif ($this->isChild()) {
|
|
} elseif ($this->isChild()) {
|
|
- if ($action != 'list') {
|
|
|
|
- $menu = $menu->addChild(
|
|
|
|
- $this->trans($this->getLabelTranslatorStrategy()->getLabel(sprintf('%s_list', $this->getClassnameLabel()), 'breadcrumb', 'link')),
|
|
|
|
- array('uri' => $this->hasRoute('list') && $this->isGranted('LIST') ? $this->generateUrl('list') : null)
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if ($action != 'create' && $this->hasSubject()) {
|
|
|
|
- $breadcrumbs = $menu->getBreadcrumbsArray($this->toString($this->getSubject()));
|
|
|
|
|
|
+ if ($action == 'list') {
|
|
|
|
+ $menu->setUri(false);
|
|
|
|
+ } elseif ($action != 'create' && $this->hasSubject()) {
|
|
|
|
+ $menu = $menu->addChild($this->toString($this->getSubject()));
|
|
} else {
|
|
} else {
|
|
- $breadcrumbs = $menu->getBreadcrumbsArray(
|
|
|
|
|
|
+ $menu = $menu->addChild(
|
|
$this->trans($this->getLabelTranslatorStrategy()->getLabel(sprintf('%s_%s', $this->getClassnameLabel(), $action), 'breadcrumb', 'link'))
|
|
$this->trans($this->getLabelTranslatorStrategy()->getLabel(sprintf('%s_%s', $this->getClassnameLabel(), $action), 'breadcrumb', 'link'))
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
} elseif ($action != 'list' && $this->hasSubject()) {
|
|
} elseif ($action != 'list' && $this->hasSubject()) {
|
|
- $breadcrumbs = $child->getBreadcrumbsArray(
|
|
|
|
- $this->toString($this->getSubject())
|
|
|
|
- );
|
|
|
|
|
|
+ $menu = $menu->addChild($this->toString($this->getSubject()));
|
|
} elseif ($action != 'list') {
|
|
} elseif ($action != 'list') {
|
|
- $breadcrumbs = $child->getBreadcrumbsArray(
|
|
|
|
|
|
+ $menu = $menu->addChild(
|
|
// $this->trans($this->getLabelTranslatorStrategy()->getLabel(sprintf('%s_%s', $this->getClassnameLabel(), $action), 'breadcrumb', 'link'))
|
|
// $this->trans($this->getLabelTranslatorStrategy()->getLabel(sprintf('%s_%s', $this->getClassnameLabel(), $action), 'breadcrumb', 'link'))
|
|
$this->toString($this->getSubject())
|
|
$this->toString($this->getSubject())
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
- $breadcrumbs = $child->getBreadcrumbsArray();
|
|
|
|
|
|
+ $menu->getBreadcrumbsArray();
|
|
}
|
|
}
|
|
|
|
|
|
- // the generated $breadcrumbs contains an empty element
|
|
|
|
- array_shift($breadcrumbs);
|
|
|
|
-
|
|
|
|
- return $this->breadcrumbs[$action] = $breadcrumbs;
|
|
|
|
|
|
+ return $this->breadcrumbs[$action] = $menu;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|