<?php
/**
 * FormField Repository
 *
 * @author Elze Kool <info@visualmedia.nl>
 */
namespace VisualM\FormBundle\Entity;

use VisualM\FormBundle\Model\FormFieldManager;
use Doctrine\ORM\QueryBuilder;
use VisualM\ModelManagementBundle\Definition\ModelManagerInterface;

/**
 * FormField Repository
 *
 * @author Elze Kool <info@visualmedia.nl>
 */
class FormFieldRepository extends FormFieldManager implements ModelManagerInterface
{
    /**
     * {@inheritdoc}
     */
    protected function processConditions(array $options, QueryBuilder &$qb)
    {
        foreach($options as $option => $value) {
            if ($option == 'id') {
                $qb->andWhere($qb->expr()->eq($this->getFullFieldName('id'), $qb->expr()->literal($value)));
            } elseif ($option == 'form_id') {
                $qb->andWhere($qb->expr()->eq($this->getFullFieldName('form'), $qb->expr()->literal($value)));
            } elseif ($option == 'referentie') {
                $qb->andWhere($qb->expr()->eq($this->getFullFieldName('referentie'), $qb->expr()->literal($value)));
            }
        }
    }

}
