Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Cassani committed Jun 9, 2017
1 parent 9a01ba0 commit b6d7877
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
5 changes: 2 additions & 3 deletions DataCollector/CacheCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public function collect(Request $request, Response $response, \Exception $except

/** @var Client $client */
$cacheClient = $this->cache->getClient();
foreach ($cacheClient->getIndex() as $key => $item){

foreach ($cacheClient->getIndex() as $key => $item) {
$data = unserialize($item);
$size = $size + $data['size'];

Expand Down Expand Up @@ -89,4 +88,4 @@ public function getName()
{
return 'in_memory_list_data_collector';
}
}
}
4 changes: 2 additions & 2 deletions DependencyInjection/InMemoryListExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function load(array $configs, ContainerBuilder $container)

// Includes services_dev.yml only
// if we are in debug mode
if(in_array($container->getParameter('kernel.environment'), ['dev', 'test'])){
if (in_array($container->getParameter('kernel.environment'), ['dev', 'test'])) {
$loader->load('services_dev.yml');
}

Expand All @@ -36,4 +36,4 @@ public function load(array $configs, ContainerBuilder $container)
// set Symfony parameter called 'in_memory_list'
$container->setParameter('in_memory_list', $config);
}
}
}
2 changes: 1 addition & 1 deletion InMemoryListBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

class InMemoryListBundle extends Bundle
{
const VERSION = '1.0.0';
const VERSION = '1.0.1';
}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ public function indexAction(Request $request)
]);
}
```

To loop data in your twig files you can use `item` function;

```twig
{% for list in cachedList %}
<li>{{ item(list).userId }}</li>
<li>{{ item(list).id }}</li>
<li>{{ item(list).title }}</li>
<li>{{ item(list).body }}</li>
{% endfor %}
```

## Support ##

If you found an issue or had an idea please refer [to this section](https://github.com/mauretto78/in-memory-list-bundle/issues).
Expand Down
8 changes: 4 additions & 4 deletions Twig/UnserializeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

class UnserializeExtension extends \Twig_Extension
{
public function getFilters()
public function getFunctions()
{
return array(
new \Twig_SimpleFilter('unserialize', array($this, 'unserializeFilter')),
new \Twig_SimpleFunction('item', [$this, 'unserializeFunction']),
);
}

public function unserializeFilter($string)
public function unserializeFunction($string)
{
return unserialize($string);
}
}
}

0 comments on commit b6d7877

Please sign in to comment.