/** * @param ObjectManager $entityManager */ public function load(ObjectManager $entityManager) { echo "Loading dog data.\n"; $dogs = array(array("callName" => "Masher", "regName" => "Livewire It's All Gravy", "sex" => 1, "breed" => 263, "dateOfBirth" => "2015-01-01", "height" => 11, "champion" => 1, "rescue" => 0, "primary" => 2), array("callName" => "Stunner", "regName" => "Livewire-ETS Excessive Force", "sex" => 1, "breed" => 263, "dateOfBirth" => "2015-01-01", "height" => 10, "champion" => 0, "rescue" => 0, "primary" => 2), array("callName" => "Shady", "regName" => "Livewire-ETS Lewd'N Lascivious", "sex" => 1, "breed" => 263, "dateOfBirth" => "2015-01-01", "height" => 10, "champion" => 1, "rescue" => 0, "primary" => 2), array("callName" => "Breaker", "regName" => "Birinci's Livewire-ETS Ice Breaker", "sex" => 1, "breed" => 22, "dateOfBirth" => "2015-01-01", "height" => 26, "champion" => 0, "rescue" => 0, "primary" => 2), array("callName" => "Dax", "regName" => "Easy To Spot Never A Dull Moment", "sex" => 1, "breed" => 121, "dateOfBirth" => "2015-01-01", "height" => 23, "champion" => 1, "rescue" => 0, "primary" => 2)); foreach ($dogs as $dogData) { $dogData['breed'] = $entityManager->getRepository('Application\\Entity\\Breed')->find($dogData['breed']); $dogData['primary'] = $entityManager->getRepository('Application\\Entity\\Member')->find($dogData['primary']); $dogData['dateOfBirth'] = new \DateTime($dogData['dateOfBirth']); $dog = new Dog(); $dog->setServiceLocator($this->getServiceLocator()); $hydrator = new ClassMethods(); $hydrator->hydrate($dogData, $dog); $entityManager->persist($dog); } $entityManager->flush(); }
/** * @return string * @Grid\Header(label="Dog", sort={"dog.regNumber"}) */ public function getDogDisplay() { return $this->dog ? $this->dog->getRegNumberDisplay() : null; }
/** * @param array $dogData * @return Dog */ public function registerNewDog(array $dogData) { $hydrator = new DoctrineHydrator($this->getEntityManager()); $dog = new Dog(); $dog->setServiceLocator($this->getServiceLocator()); $dog = $hydrator->hydrate($dogData, $dog); $entityManager = $this->getEntityManager(); $entityManager->persist($dog); $entityManager->flush(); $mailService = $this->getMailService(); $message = $mailService->prepareMessage('register', array('dog' => $dog)); $message->addTo($dog->getPrimary()->getEmail(), $dog->getPrimary()->getName()); $message->setSubject('USCSS New Dog Registration: ' . $dog->getCallName()); $mailService->send($message); return $dog; }