Book Image

Symfony2 Essentials

Book Image

Symfony2 Essentials

Overview of this book

Table of Contents (17 chapters)
Symfony2 Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a list of tasks


After we are set, we should create a table with a list of our unfinished tasks. In the previous chapter, when we created a database model we didn't add a column to flag the finished task, so we will do this now to demonstrate how the database model should be amended while the project is growing.

Modify the src/AppBundle/Entity/Task.php file and add the following:

    // ... 
    /**
     * @ORM\Column(type="datetime")
     */
    private $created_at;

    // add the code below, to recognize finished tasks:
    /**
     * @ORM\Column(type="boolean")
     */
    private $finished = false;

Update the database and generate the following new methods:

$ php app/console doctrine:schema:update --force
$ php app/console doctrine:generate:entities --no-backup AppBundle

Now we need to modify our data fixtures. In the previous chapter, we created an example tag fixture, now we need to add an example task. Add the following code to the file:

<?php

// file: src/AppBundle/DataFixtures...