Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Resources/views/Admin/navigationleft.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ul class="nav nav-list menu_level_1">
{% for element in group.elements %}
<li{% if loop.last == true %} class="last"{% endif %}>
<a href="{{ path(element.baseRouteName, {element : element.id}) }}">{{ element.name|trans }}</a>
<a href="{{ path(element.baseRouteName, element.baseRouteParameters) }}">{{ element.name|trans }}</a>
</li>
{% endfor %}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Admin/navigationtop.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ul class="dropdown-menu" role="menu" aria-labelledby="drop{{ loop.index }}">
{% for element in group.elements %}
<li role="presentation">
<a role="menuitem" tabindex="-1" href="{{ path(element.baseRouteName, {element : element.id}) }}">{{ element.name|trans }}</a>
<a role="menuitem" tabindex="-1" href="{{ path(element.baseRouteName, element.baseRouteParameters) }}">{{ element.name|trans }}</a>
</li>
{% endfor %}
</ul>
Expand Down
28 changes: 26 additions & 2 deletions Structure/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace FSi\Bundle\AdminBundle\Structure;

use FSi\Bundle\AdminBundle\Exception\MissingOptionExteption;
use FSi\Bundle\AdminBundle\Exception\MissingOptionException;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

Expand All @@ -33,6 +33,22 @@ final public function initOptions($options = array())
$this->options = $optionsResolver->resolve($options);
}

/**
* Return array of parameters.
* Element id always exists in this array.
*
* @return mixed
*/
final public function getBaseRouteParameters()
{
return array_merge(
$this->getRouteParameters(),
array(
'element' => $this->getId()
)
);
}

/**
* {@inheritdoc}
*/
Expand All @@ -46,7 +62,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
public function getOption($name)
{
if (!$this->hasOption($name)) {
throw new MissingOptionExteption(sprintf('Option with name: "%s" does\'t exists.', $name));
throw new MissingOptionException(sprintf('Option with name: "%s" does\'t exists.', $name));
}

return $this->options[$name];
Expand All @@ -67,4 +83,12 @@ public function hasOption($name)
{
return isset($this->options[$name]);
}

/**
* @return array
*/
protected function getRouteParameters()
{
return array();
}
}
8 changes: 8 additions & 0 deletions Structure/ElementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public function getName();
*/
public function getBaseRouteName();

/**
* Return array of parameters.
* Element id always exists in this array under element key
*
* @return mixed
*/
public function getBaseRouteParameters();

/**
* Initialize options.
*
Expand Down