<?php

namespace AppBundle\Entity\Message\Repository;

use AppBundle\Entity\Core\File;
use Doctrine\ORM\EntityRepository;

/**
 * Description of NotificationRepository
 *
 * @author sebastienhupin
 */
class MessageRepository extends EntityRepository {

    /**
     * @param File $file
     * @return array
     */
    public function findByFiles(File $file) {
        $queryBuilder = $this->createQueryBuilder('o');
        $queryBuilder
            ->innerJoin('o.files', 'f')
            ->andWhere('f.id = :file')
            ->setParameter('file', $file->getId());

        return $queryBuilder->getQuery()->getResult();
    }
}
