Symfony3 Doctrine2 can not access variable in the loop
<h2>ENVIRONMENT</h2>

<p>I am using:</p>

<ul>
<li>Symfony v3.1.0;</li>
<li>Doctrine v2.5.4</li>
</ul>

<h2>PROBLEM</h2>

<p>I am importing data from XML file. Import works fine, but I have problems with update.</p>

<p>I just can not get proper <code>day_id</code> in the loop.</p>

<pre><code>$newest_day_id = $this-&gt;getNewestDayId();
...
-&gt;setParameter(7, $newest_day_id)
</code></pre>

<p>gives ID that is by 1 smaller than actual id</p>

<p>if I try:</p>

<pre><code>$newest_day_id = $this-&gt;getNewestDayId();
...
-&gt;setParameter(7, $newest_day_id + 1)
</code></pre>

<p>it gives an error</p>

<pre><code>An exception occurred while executing 'UPDATE item SET name_lv = ?, name_ru = ?, description_lv = ?, description_ru = ?, price = ?, in_stock = ?, day_id = ? WHERE unique_id = ?' with params ["EDIT My Product Name LV", "EDIT My Product Name RU", "EDIT", "EDIT", "999.00", "99", 34, "0361-my-product-unique-id"]:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`tevlvnews`.`item`, CONSTRAINT `FK_1F1B251E9C24126` FOREIGN KEY (`day_id`) REFERENCES `day` (`id`) ON DELETE CASCADE)
</code></pre>

<p>and if I try:</p>

<pre><code>....
-&gt;setParameter(7, $day-&gt;getId)
</code></pre>

<p>I get <code>NULL</code> in the <code>day_id</code> field in the database</p>

<h2>CODE</h2>

<p>here is my controller:</p>

<pre><code>&lt;?php

namespace AppBundle\Controller;

use \DateTime;
use AppBundle\Entity\Day;
use AppBundle\Entity\Item;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\DomCrawler\Crawler;

class AdminController extends Controller
{
    /**
     * @Route("/import", name="admin_import")
     */
    public function importAction(Request $request)
    {
        $document = new \DOMDocument();
        $tev_file_path = 'http://dev.izjoko.lv/test.xml';
        $document-&gt;loadXml(file_get_contents($tev_file_path));

        $now_date_time = date('Y-m-d H:i:s');
        $nodeList = $document-&gt;getElementsByTagName('item');

        $crawler = new Crawler();
        $crawler-&gt;addDocument($document);
        $crawler-&gt;addNodeList($nodeList);
        $xml_item_counts = $nodeList-&gt;length;

        // find newest DAY record
        $em = $this-&gt;getDoctrine()-&gt;getManager();
        $query = $em-&gt;createQueryBuilder()
            -&gt;select('d')
            -&gt;from('AppBundle:Day', 'd')
            -&gt;orderBy('d.updated_at', 'DESC')
            -&gt;getQuery();
        $db_date_time = $query-&gt;getResult();
        $db_date_time_size = sizeof($db_date_time);

        // setup www folder for image path
        $current_env = $this-&gt;container-&gt;get('kernel')-&gt;getEnvironment();
        if ($current_env == 'dev') 
        {
            $www_dir = 'web';
        }
        elseif ($current_env == 'prod')
        {
            $www_dir = 'www';
        }

        $fs = new Filesystem();
        $local_image_uploads_path = $this-&gt;container-&gt;getParameter('kernel.root_dir') . '/../' . $www_dir . '/uploads/';
        $local_image_uploads_path = str_replace("app/../", "", $local_image_uploads_path);

        // make folder uploads inside web
        if (!$fs-&gt;exists($local_image_uploads_path)) 
        {
            try 
            {
                $fs-&gt;mkdir($local_image_uploads_path);
            }
            catch (IOExceptionInterface $e) 
            {
                echo "An error occurred while creating your directory at " . $e-&gt;getPath();
            }
        }

        // if database is empty
        if ($db_date_time_size == 0)
        {
            $day = new Day();
            $day-&gt;setUpdatedAt(new DateTime($now_date_time));

            for ($i = 0; $i &lt; $xml_item_count; $i++)
            {
                $unique_id = $document-&gt;getElementsByTagName('unique_id')-&gt;item($i)-&gt;textContent;
                $name_lv = $document-&gt;getElementsByTagName('name_lv')-&gt;item($i)-&gt;textContent;
                $name_ru = $document-&gt;getElementsByTagName('name_ru')-&gt;item($i)-&gt;textContent;
                $link_lv = $document-&gt;getElementsByTagName('link_lv')-&gt;item($i)-&gt;textContent;
                $link_ru = $document-&gt;getElementsByTagName('link_ru')-&gt;item($i)-&gt;textContent;
                $category = $document-&gt;getElementsByTagName('category')-&gt;item($i)-&gt;textContent;
                $category_full = $document-&gt;getElementsByTagName('category_full')-&gt;item($i)-&gt;textContent;
                $external_image_small = $document-&gt;getElementsByTagName('image_th')-&gt;item($i)-&gt;textContent;
                $external_image_big = $document-&gt;getElementsByTagName('image')-&gt;item($i)-&gt;textContent;
                $description_lv = $document-&gt;getElementsByTagName('description_lv')-&gt;item($i)-&gt;textContent;
                $description_ru = $document-&gt;getElementsByTagName('description_ru')-&gt;item($i)-&gt;textContent;
                $price = $document-&gt;getElementsByTagName('price')-&gt;item($i)-&gt;textContent;
                $in_stock = $document-&gt;getElementsByTagName('in_stock')-&gt;item($i)-&gt;textContent;

                // add new record to database
                $item = new Item();
                $item-&gt;setUniqueId($unique_id);
                $item-&gt;setNameLv($name_lv);
                $item-&gt;setNameRu($name_ru);
                $item-&gt;setLinkLv($link_lv);
                $item-&gt;setLinkRu($link_ru);
                $item-&gt;setCategory($category);
                $item-&gt;setCategoryFull($category_full);

                /* -----------------------------------------------------
                 * small picture
                ----------------------------------------------------- */
                $image_small = file_get_contents($external_image_small);
                $hex_random_bytes = bin2hex(random_bytes(8));
                $file_name_small = 'img_' . $hex_random_bytes . '_th.jpg';
                $local_image_small_full_path = $this-&gt;container-&gt;getParameter('kernel.root_dir') . '/../' . $www_dir . '/uploads/' . $file_name_small;
                $local_image_small_full_path = str_replace("app/../", "", $local_image_small_full_path);
                try 
                {
                    $fs-&gt;dumpFile($local_image_small_full_path, $image_small);
                }
                catch (IOExceptionInterface $e) 
                {
                    echo "An error occurred while saving your image at " . $e-&gt;getPath();
                }
                $local_image_small_path = 'uploads/' . $file_name_small;
                $item-&gt;setLocalImageSmallUrl($local_image_small_path);

                /* -----------------------------------------------------
                 * big picture
                ----------------------------------------------------- */
                $image_big = file_get_contents($external_image_big);
                $file_name_big = 'img_' . $hex_random_bytes . '.jpg';
                $local_image_big_full_path = $this-&gt;container-&gt;getParameter('kernel.root_dir') . '/../' . $www_dir . '/uploads/' . $file_name_big;
                $local_image_big_full_path = str_replace("app/../", "", $local_image_big_full_path);
                try 
                {
                    $fs-&gt;dumpFile($local_image_big_full_path, $image_big);
                }
                catch (IOExceptionInterface $e) 
                {
                    echo "An error occurred while saving your image at " . $e-&gt;getPath();
                }
                $local_image_big_path = 'uploads/' . $file_name_big;
                $item-&gt;setLocalImageBigUrl($local_image_big_path);

                $item-&gt;setDescriptionLv($description_lv);
                $item-&gt;setDescriptionRu($description_ru);
                $item-&gt;setPrice($price);
                $item-&gt;setInStock($in_stock);

                $em-&gt;persist($item);
                $item-&gt;setDay($day);
            }

            $em-&gt;persist($day);
            $em-&gt;flush();
        }

        return $this-&gt;render('admin/import_tev.html.twig', array('tev_file_path' =&gt; $tev_file_path, 'xml_date_time' =&gt; $now_date_time, 'xml_item_count' =&gt; $xml_item_count));
    }

    /**
     * @Route("/update", name="admin_update")
     */
    public function updateAction(Request $request)
    {
        $document = new \DOMDocument();
        $tev_file_path = 'http://dev.izjoko.lv/test.xml';
        $document-&gt;loadXml(file_get_contents($tev_file_path));

        $now_date_time = date('Y-m-d H:i:s');
        $nodeList = $document-&gt;getElementsByTagName('item');

        $crawler = new Crawler();
        $crawler-&gt;addDocument($document);
        $crawler-&gt;addNodeList($nodeList);
        $xml_item_count = $nodeList-&gt;length;

        // find newest DAY record
        $em = $this-&gt;getDoctrine()-&gt;getManager();
        $query = $em-&gt;createQueryBuilder()
            -&gt;select('d')
            -&gt;from('AppBundle:Day', 'd')
            -&gt;orderBy('d.updated_at', 'DESC')
            -&gt;getQuery();
        $db_date_time = $query-&gt;getResult();
        $db_date_time_size = sizeof($db_date_time);

        // setup www folder for image path
        $current_env = $this-&gt;container-&gt;get('kernel')-&gt;getEnvironment();
        if ($current_env == 'dev')
        {
            $www_dir = 'web';
        } 
        elseif ($current_env == 'prod')
        {
            $www_dir = 'www';
        }

        $fs = new Filesystem();
        $local_image_uploads_path = $this-&gt;container-&gt;getParameter('kernel.root_dir') . '/../' . $www_dir . '/uploads/';
        $local_image_uploads_path = str_replace("app/../", "", $local_image_uploads_path);

        // make folder uploads inside web
        if (!$fs-&gt;exists($local_image_uploads_path))
        {
            try
            {
                $fs-&gt;mkdir($local_image_uploads_path);
            }
            catch (IOExceptionInterface $e)
            {
                echo "An error occurred while creating your directory at " . $e-&gt;getPath();
            }
        }

        $day = new Day();
        $day-&gt;setUpdatedAt(new DateTime($now_date_time));

        for ($i = 0; $i &lt; $xml_item_count; $i++)
        {
            $unique_id = $document-&gt;getElementsByTagName('unique_id')-&gt;item($i)-&gt;textContent;
            $name_lv = $document-&gt;getElementsByTagName('name_lv')-&gt;item($i)-&gt;textContent;
            $name_ru = $document-&gt;getElementsByTagName('name_ru')-&gt;item($i)-&gt;textContent;
            $link_lv = $document-&gt;getElementsByTagName('link_lv')-&gt;item($i)-&gt;textContent;
            $link_ru = $document-&gt;getElementsByTagName('link_ru')-&gt;item($i)-&gt;textContent;
            $category = $document-&gt;getElementsByTagName('category')-&gt;item($i)-&gt;textContent;
            $category_full = $document-&gt;getElementsByTagName('category_full')-&gt;item($i)-&gt;textContent;
            $external_image_small = $document-&gt;getElementsByTagName('image_th')-&gt;item($i)-&gt;textContent;
            $external_image_big = $document-&gt;getElementsByTagName('image')-&gt;item($i)-&gt;textContent;
            $description_lv = $document-&gt;getElementsByTagName('description_lv')-&gt;item($i)-&gt;textContent;
            $description_ru = $document-&gt;getElementsByTagName('description_ru')-&gt;item($i)-&gt;textContent;
            $price = $document-&gt;getElementsByTagName('price')-&gt;item($i)-&gt;textContent;
            $in_stock = $document-&gt;getElementsByTagName('in_stock')-&gt;item($i)-&gt;textContent;

            if ($this-&gt;checkIfUniqueIdRecordExistsAction($unique_id) == true)
            {
                // update existing record
                $newest_day_id = $this-&gt;getNewestDayId();
                $em = $this-&gt;getDoctrine()-&gt;getManager();
                $qb = $em-&gt;createQueryBuilder();
                $q = $qb-&gt;update('AppBundle:Item', 'i')
                    -&gt;set('i.name_lv', '?1')
                    -&gt;set('i.name_ru', '?2')
                    -&gt;set('i.description_lv', '?3')
                    -&gt;set('i.description_ru', '?4')
                    -&gt;set('i.price', '?5')
                    -&gt;set('i.in_stock', '?6')
                    -&gt;set('i.day', '?7')
                    -&gt;where('i.unique_id = :unique_id')
                    -&gt;setParameter('unique_id', $unique_id)
                    -&gt;setParameter(1, $name_lv)
                    -&gt;setParameter(2, $name_ru)
                    -&gt;setParameter(3, $description_lv)
                    -&gt;setParameter(4, $description_ru)
                    -&gt;setParameter(5, $price)
                    -&gt;setParameter(6, $in_stock)
                    -&gt;setParameter(7, $newest_day_id)
                    -&gt;getQuery();

                $q-&gt;execute();

            }
            elseif ($this-&gt;checkIfUniqueIdRecordExistsAction($unique_id) == false)
            {
                //TODO: add new data
                $item = new Item();
                $item-&gt;setUniqueId($unique_id);
                $item-&gt;setNameLv($name_lv);
                $item-&gt;setNameRu($name_ru);
                $item-&gt;setLinkLv($link_lv);
                $item-&gt;setLinkRu($link_ru);
                $item-&gt;setCategory($category);
                $item-&gt;setCategoryFull($category_full);

                /* -----------------------------------------------------
                 * small image
                ----------------------------------------------------- */
                $image_small = file_get_contents($external_image_small);
                $hex_random_bytes = bin2hex(random_bytes(8));
                $file_name_small = 'img_' . $hex_random_bytes . '_th.jpg';
                $local_image_small_full_path = $this-&gt;container-&gt;getParameter('kernel.root_dir') . '/../' . $www_dir . '/uploads/' . $file_name_small;
                $local_image_small_full_path = str_replace("app/../", "", $local_image_small_full_path);
                try
                {
                    $fs-&gt;dumpFile($local_image_small_full_path, $image_small);
                }
                catch (IOExceptionInterface $e)
                {
                    echo "An error occurred while saving your image at " . $e-&gt;getPath();
                }
                $local_image_small_path = 'uploads/' . $file_name_small;
                $item-&gt;setLocalImageSmallUrl($local_image_small_path);

                /* -----------------------------------------------------
                 * big image
                ----------------------------------------------------- */
                $image_big = file_get_contents($external_image_big);
                $file_name_big = 'img_' . $hex_random_bytes . '.jpg';
                $local_image_big_full_path = $this-&gt;container-&gt;getParameter('kernel.root_dir') . '/../' . $www_dir . '/uploads/' . $file_name_big;
                $local_image_big_full_path = str_replace("app/../", "", $local_image_big_full_path);
                try
                {
                    $fs-&gt;dumpFile($local_image_big_full_path, $image_big);
                }
                catch (IOExceptionInterface $e)
                {
                    echo "An error occurred while saving your image at " . $e-&gt;getPath();
                }
                $local_image_big_path = 'uploads/' . $file_name_big;
                $item-&gt;setLocalImageBigUrl($local_image_big_path);

                $item-&gt;setDescriptionLv($description_lv);
                $item-&gt;setDescriptionRu($description_ru);
                $item-&gt;setPrice($price);
                $item-&gt;setInStock($in_stock);

                $em-&gt;persist($item);
                $item-&gt;setDay($day);
            }

        }
        $em-&gt;persist($day);
        $em-&gt;flush();

        return $this-&gt;render('admin/import_tev.html.twig', array('tev_file_path' =&gt; $tev_file_path, 'xml_date_time' =&gt; $now_date_time, 'xml_item_count' =&gt; $xml_item_count));
    }

    private function checkIfUniqueIdRecordExistsAction($unique_id)
    {
        // check if record with identic unique_id is already in database
        $em = $this-&gt;getDoctrine()-&gt;getManager();
        $query = $em-&gt;createQueryBuilder()
            -&gt;select('i')
            -&gt;from('AppBundle:Item', 'i')
            -&gt;where('i.unique_id = :unique_id')
            -&gt;setParameter('unique_id', $unique_id)
            -&gt;setMaxResults(1)
            -&gt;getQuery();

        $db_unique_id = $query-&gt;getResult();
        $db_unique_id_size = sizeof($db_unique_id);

        if ($db_unique_id_size == 0) {
            // not in database
            return false;
        } elseif ($db_unique_id_size &gt; 0) {
            // exists in database
            return true;
        }
    }

    private function getNewestDayId()
    {
        // fnd newest DAY record id
        $em = $this-&gt;getDoctrine()-&gt;getManager();
        $query = $em-&gt;createQueryBuilder()
            -&gt;select('d')
            -&gt;from('AppBundle:Day', 'd')
            -&gt;orderBy('d.updated_at', 'DESC')
            -&gt;setMaxResults(1)
            -&gt;getQuery();

        $db_date_time = $query-&gt;getResult();
        $db_date_time_id = $db_date_time[0]-&gt;getId();

        return $db_date_time_id;
    }
}
</code></pre>

<p>My ITEM entity:</p>

<pre><code>namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="item")
 */
class Item
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $name_lv;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $name_ru;

    /**
     * @ORM\Column(type="string", length=200)
     */
    protected $category;

    /**
     * @ORM\Column(type="string", length=500)
     */
    protected $category_full;

    /**
     * @ORM\Column(type="string", length=500)
     */
    protected $link_lv;

    /**
     * @ORM\Column(type="string", length=500)
     */
    protected $link_ru;

    /**
     * @ORM\Column(type="string", length=500)
     */
    protected $local_image_small_url;

    /**
     * @ORM\Column(type="string", length=500)
     */
    protected $local_image_big_url;

    /**
     * @ORM\Column(type="string", length=3000)
     */
    protected $description_lv;

    /**
     * @ORM\Column(type="string", length=3000)
     */
    protected $description_ru;

    /**
     * @ORM\Column(type="decimal", scale=2)
     */
    protected $price;

    /**
     * @ORM\Column(type="integer")
     */
    protected $in_stock;

    /**
     * @ORM\ManyToOne(targetEntity="Day", inversedBy="items")
     * @ORM\JoinColumn(name="day_id", referencedColumnName="id", onDelete="CASCADE")
     */
    protected $day;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this-&gt;id;
    }

    /**
     * Set nameLv
     *
     * @param string $nameLv
     *
     * @return Item
     */
    public function setNameLv($nameLv)
    {
        $this-&gt;name_lv = $nameLv;

        return $this;
    }

    /**
     * Get nameLv
     *
     * @return string
     */
    public function getNameLv()
    {
        return $this-&gt;name_lv;
    }

    /**
     * Set nameRu
     *
     * @param string $nameRu
     *
     * @return Item
     */
    public function setNameRu($nameRu)
    {
        $this-&gt;name_ru = $nameRu;

        return $this;
    }

    /**
     * Get nameRu
     *
     * @return string
     */
    public function getNameRu()
    {
        return $this-&gt;name_ru;
    }

    /**
     * Set category
     *
     * @param string $category
     *
     * @return Item
     */
    public function setCategory($category)
    {
        $this-&gt;category = $category;

        return $this;
    }

    /**
     * Get category
     *
     * @return string
     */
    public function getCategory()
    {
        return $this-&gt;category;
    }

    /**
     * Set categoryFull
     *
     * @param string $categoryFull
     *
     * @return Item
     */
    public function setCategoryFull($categoryFull)
    {
        $this-&gt;category_full = $categoryFull;

        return $this;
    }

    /**
     * Get categoryFull
     *
     * @return string
     */
    public function getCategoryFull()
    {
        return $this-&gt;category_full;
    }

    /**
     * Set linkLv
     *
     * @param string $linkLv
     *
     * @return Item
     */
    public function setLinkLv($linkLv)
    {
        $this-&gt;link_lv = $linkLv;

        return $this;
    }

    /**
     * Get linkLv
     *
     * @return string
     */
    public function getLinkLv()
    {
        return $this-&gt;link_lv;
    }

    /**
     * Set linkRu
     *
     * @param string $linkRu
     *
     * @return Item
     */
    public function setLinkRu($linkRu)
    {
        $this-&gt;link_ru = $linkRu;

        return $this;
    }

    /**
     * Get linkRu
     *
     * @return string
     */
    public function getLinkRu()
    {
        return $this-&gt;link_ru;
    }

    /**
     * Set localImageSmallUrl
     *
     * @param string $localImageSmallUrl
     *
     * @return Item
     */
    public function setLocalImageSmallUrl($localImageSmallUrl)
    {
        $this-&gt;local_image_small_url = $localImageSmallUrl;

        return $this;
    }

    /**
     * Get localImageSmallUrl
     *
     * @return string
     */
    public function getLocalImageSmallUrl()
    {
        return $this-&gt;local_image_small_url;
    }

    /**
     * Set localImageBigUrl
     *
     * @param string $localImageBigUrl
     *
     * @return Item
     */
    public function setLocalImageBigUrl($localImageBigUrl)
    {
        $this-&gt;local_image_big_url = $localImageBigUrl;

        return $this;
    }

    /**
     * Get localImageBigUrl
     *
     * @return string
     */
    public function getLocalImageBigUrl()
    {
        return $this-&gt;local_image_big_url;
    }

    /**
     * Set descriptionLv
     *
     * @param string $descriptionLv
     *
     * @return Item
     */
    public function setDescriptionLv($descriptionLv)
    {
        $this-&gt;description_lv = $descriptionLv;

        return $this;
    }

    /**
     * Get descriptionLv
     *
     * @return string
     */
    public function getDescriptionLv()
    {
        return $this-&gt;description_lv;
    }

    /**
     * Set descriptionRu
     *
     * @param string $descriptionRu
     *
     * @return Item
     */
    public function setDescriptionRu($descriptionRu)
    {
        $this-&gt;description_ru = $descriptionRu;

        return $this;
    }

    /**
     * Get descriptionRu
     *
     * @return string
     */
    public function getDescriptionRu()
    {
        return $this-&gt;description_ru;
    }

    /**
     * Set price
     *
     * @param string $price
     *
     * @return Item
     */
    public function setPrice($price)
    {
        $this-&gt;price = $price;

        return $this;
    }

    /**
     * Get price
     *
     * @return string
     */
    public function getPrice()
    {
        return $this-&gt;price;
    }

    /**
     * Set inStock
     *
     * @param integer $inStock
     *
     * @return Item
     */
    public function setInStock($inStock)
    {
        $this-&gt;in_stock = $inStock;

        return $this;
    }

    /**
     * Get inStock
     *
     * @return integer
     */
    public function getInStock()
    {
        return $this-&gt;in_stock;
    }

    /**
     * Set day
     *
     * @param \AppBundle\Entity\Day $day
     *
     * @return Item
     */
    public function setDay(\AppBundle\Entity\Day $day = null)
    {
        $this-&gt;day = $day;

        return $this;
    }

    /**
     * Get day
     *
     * @return \AppBundle\Entity\Day
     */
    public function getDay()
    {
        return $this-&gt;day;
    }
}
</code></pre>

<p>My DAY entity:</p>

<pre><code>namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="day")
 */
class Day
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="datetime", name="updated_at")
     */
    protected $updated_at;

    /**
     * @ORM\OneToMany(targetEntity="Item", mappedBy="day")
     */
    protected $items;

    public function __construct()
    {
        $this-&gt;items = new ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this-&gt;id;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     *
     * @return Day
     */
    public function setUpdatedAt($updatedAt)
    {
        $this-&gt;updated_at = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this-&gt;updated_at;
    }

    /**
     * Add item
     *
     * @param \AppBundle\Entity\item $item
     *
     * @return Day
     */
    public function addItem(item $item)
    {
        $this-&gt;items[] = $item;

        return $this;
    }

    /**
     * Remove item
     *
     * @param \AppBundle\Entity\item $item
     */
    public function removeItem(item $item)
    {
        $this-&gt;items-&gt;removeElement($item);
    }

    /**
     * Get items
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getItems()
    {
        return $this-&gt;items;
    }
}
</code></pre>

<p>Thank you for your time and knowledge.</p>