<?php namespace BackendBundle\Repository; use BackendBundle\Entity\Device; use Doctrine\ORM\EntityRepository; /** * DeviceRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. */ class DeviceRepository extends EntityRepository { /** * @param array $data */ public function hydrate(array $data) { $device = new Device(); $device->setUuid($data['uuid']); $this->updateChangingInfo($data, $device); $this->_em->persist($device); $this->_em->flush(); } /** * @param array $data * @param Device $device */ public function updateInfo(array $data, Device $device) { $this->updateChangingInfo($data, $device); $this->_em->flush(); } /** * @param array $data * @param Device $device */ private function updateChangingInfo(array $data, Device $device) { $device ->setModel($data['model']) ->setPlatform($data['platform']) ->setToken($data['token']) ->setLocale($data['locale']) ->setVersion($data['version']); } }