Brought to you with tenderness by the Knp team
KnpIpsum

A Symfony2 Tutorial Application

Gedmo Doctrine Extensions Tutorial

List of things

Here is the list of things from your database:

You should have a look at

src/Knp/IpsumBundle/Entity/TimedThing.php

What can I do with Gedmo?

Code behind this page

Controller Code

src/Knp/IpsumBundle/Controller/GedmoExtensionsController.php:10
public function indexAction()
{
    $em = $this->get('doctrine')->getEntityManager();
    $things = $em->getRepository('KnpIpsumBundle:TimedThing')->findAll();
     return $this->render('KnpIpsumBundle:GedmoExtensions:index.html.twig', array(
        'things' => $things,
    ));
}

Template Code

src/Knp/IpsumBundle/Resources/views/GedmoExtensions/index.html.twig
{% extends "KnpIpsumBundle:GedmoExtensions:layout.html.twig" %}

{% block content_gedmo %}
    <h1>List of things</h1>

    <p>Here is the list of things from your database:</p>

    {% if things %}
        <ul>
        {% for thing in things %}
            <li>
                * {{ thing.name }}
                − created at {{ thing.createdAt|date }} and updated at {{ thing.updatedAt|date }}
                − <a href="{{ path('knp_ipsum_gedmo_extensions_update', {'id': thing.id}) }}">UPDATE</a>
            </li>
        {% endfor %}
        </ul>
    {% else %}
        <p>− There are no things yet!</p>
    {% endif %}

    <p>You should have a look at <pre>src/Knp/IpsumBundle/Entity/TimedThing.php</pre></p>
{% endblock %}