Skip to content
Snippets Groups Projects
Select Git revision
  • 9e8d55e7e275d9591cfbc3d757d49de80cc9478c
  • master default
  • 1
  • 2
  • 3
  • 4
  • branche_annexe
  • test
  • Mechanical
  • platypus
  • wiikip
  • arnold
  • laBandaEwen
  • debuging
  • yolo
  • premiere_branche
  • coshyp
  • nvlle_branche
  • Alberich
  • branchpourtoncasser
  • branch_tcd
21 results

App.test.js

Blame
  • Forked from Thomas Sainrat / formation-git
    Source project has a limited visibility.
    NotificationOnDeviceRepository.php 1.48 KiB
    <?php
    /**
     * Created by PhpStorm.
     * User: jeremyguiselin
     * Date: 01/11/2016
     * Time: 17:31
     */
    
    namespace BackendBundle\Repository;
    
    
    use BackendBundle\Entity\Device;
    use BackendBundle\Entity\Notification;
    use BackendBundle\Entity\NotificationOnDevice;
    use Doctrine\ORM\EntityRepository;
    
    class NotificationOnDeviceRepository extends EntityRepository
    {
        public function findNotificationsByDevice(array $notifications, Device $device)
        {
            return $this->createQueryBuilder('s')
                ->where('s.notification IN (:notifications)')
                ->andWhere('s.device = :device')
                ->setParameters([
                    'device' => $device,
                    'notifications' => $notifications
                ])
                ->getQuery()
                ->getResult();
        }
    
        public function updateStatusOnAllDevices(array $devices, Notification $notification)
        {
            foreach ($devices as $device) {
                $notifOnDevice = new NotificationOnDevice();
                $notifOnDevice->setDevice($device);
                $notifOnDevice->setNotification($notification);
                $this->getEntityManager()->persist($notifOnDevice);
            }
    
            $this->getEntityManager()->flush();
        }
    
        public function readAllNotifications(Device $device)
        {
            $qb = $this->createQueryBuilder('n');
            $qb
                ->update('n')
                ->set('n.status', NotificationOnDevice::STATUS_READ)
                ->where('n.device = :device')
                ->setParameter('device', $device);
        }
    }