Skip to content

Commit

Permalink
Add twig doc + tag 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PETIT Yoann committed May 26, 2014
1 parent be0b1b8 commit 97370b6
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 14 deletions.
2 changes: 0 additions & 2 deletions Annotation/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,4 @@ public function getAttributes()
{
return $this->attributes;
}


}
9 changes: 6 additions & 3 deletions BreadcrumbTrail/Trail.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ private function insert($breadcrumb, $position)
*
* @return self
*/
public function reset() {
public function reset()
{
$this->breadcrumbs->removeAll($this->breadcrumbs);

return $this;
Expand All @@ -184,14 +185,16 @@ public function reset() {
/**
* {@inheritDoc}
*/
public function count() {
public function count()
{
return $this->breadcrumbs->count();
}

/**
* {@inheritDoc}
*/
public function getIterator() {
public function getIterator()
{
return $this->breadcrumbs;
}
}
28 changes: 26 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
`20 Janvier 2013`
#2014-04-18
- Rewrite documentation

#2013-12-13
- Handle slug parameters in breadcrumb title

#2013-07-29
- Handle slug parameters in route parameters

#2013-01-25
- Add additional attributes for the breadcrumb

#2013-01-24
- Add override template features

#2013-01-20
- Add position parameter
- Update documentation
- Update documentation

#2012-06-30
- Manage JMSSecurityExtraBundle proxy class

#2012-04-27
- Translate titles

#2011-12-17
- Initial commit
1 change: 1 addition & 0 deletions EventListener/BreadcrumbListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function onKernelController(FilterControllerEvent $event)
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
$this->breadcrumbTrail->reset();

// Annotations from class
$this->addBreadcrumbsFromAnnotations($this->reader->getClassAnnotations($class));

// Annotations from method
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Getting Started With BreadcrumbTrailBundle
==========================================

This bundle provides a breacrumb trail service also known as breadcrumbs or Fil d'Ariane.

Breadcrumbs can be defined with annotations or/and PHP.
This bundle provides a breacrumb trail service also known as breadcrumbs or Fil d'Ariane.
Breadcrumbs can be defined with annotations, PHP and Twig.

**Version**: 1.2 (2014/05/26)
**Compatibility**: The bundle is compatible with Symfony 2.0 upwards.

## Installation
Expand All @@ -15,7 +15,6 @@ Please follow the steps given [here](https://github.com/Abhoryo/APYBreadcrumbTra

- [Annotation configuration](Resources/doc/annotation_configuration.md)
- [PHP configuration](Resources/doc/php_configuration.md)
- [Twig configuration](Resources/doc/twig_configuration.md)
- [Render the breadcrumb trail](Resources/doc/rendering.md)
- [Override the template](Resources/doc/override_template.md)

## Todo
29 changes: 29 additions & 0 deletions Resources/doc/twig_configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Twig configuration

Add breadcumbs to the trail with Twig in your template works exactly like the [PHP configuration](php_configuration.md).
You just have to add the service in a global variable.

## Configuration

```yml
#app/config/config.yml
twig:
globals:
breadcrumb_trail: "@apy_breadcrumb_trail"
```
## Basic example
```django
<!-- MyProject\MyBundle\Resources\views\myTemplate.html.twig -->
{% do breadcrumb_trail.add('My new breadcrumb') %}
{{ apy_breadcrumb_trail_render() }}
```

Functions are chainable so you can write this code:

```django
<!-- MyProject\MyBundle\Resources\views\myTemplate.html.twig -->
{% do breadcrumb_trail.reset().add('breadcrumb 1').add('breadcrumb 2') %}
{{ apy_breadcrumb_trail_render() }}
```
2 changes: 0 additions & 2 deletions Resources/views/breadcrumbtrail.html.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{%- if breadcrumbs.count %}
<ul id="breadcrumbtrail">
{% for breadcrumb in breadcrumbs %}

{% set class = (loop.first ? 'home' : (loop.last ? 'current' : '')) %}

<li {% for attr,value in breadcrumb.attributes -%}
{%- if attr == 'class' %}{% set value = value ~ ' ' ~ class %}{% endif -%}
{{ attr }}="{{ value }}"
Expand Down

0 comments on commit 97370b6

Please sign in to comment.