/** * A convenience method to copy attributes from the PDO * to the Bean. Will automatically set the useTargetVars * attribute of the CopyBeanOption. * * @access private * @param pdo The Venue PDO object (source) * @return bean The Venue bean */ private function pdoToBean($pdo) { global $logger; $logger->debug(get_class($this) . "::pdoToBean({$pdo})"); $copyOption = new CopyBeanOption(); $copyOption->setUseTargetVars(true); $copyOption->setScalarsOnly(true); $bean = new Venue(); $bean = BeanUtil::copyBean($pdo, $bean, $copyOption); // Convert the pubState to a string $ps = ''; if ($pdo->getPubState() != null) { $ps = $pdo->getPubState()->getValue(); } $bean->setPubState($ps); $logger->debug("pubstate: " . $bean->getPubState()); // Convert the Address to bean $addrBean = new Address(); if ($pdo->getAddress() != null) { $addrBean = BeanUtil::copyBean($pdo->getAddress(), $addrBean, $copyOption); } $bean->setAddress($addrBean); $logger->debug("address: " . $bean->getAddress()); // related events from array of pdos to keyed array of oids $events = $pdo->getEvents(); $logger->debug("events: " . count($events)); if (!empty($events) && '' != get_class($events[0])) { $es = new EventService(); $related = array(); foreach ($events as $event) { $logger->debug("event: " . $event); $related[] = $es->getEventById($event->getScope(), $event->getOid()); } $bean->setEvents($related); } return $bean; }
/** * A convenience method to copy attributes from the PDO * to the Bean. Will automatically set the useTargetVars * attribute of the CopyBeanOption. * * @access private * @param pdo The Venue PDO object (source) * @return bean The Venue bean */ private function pdoToBean($pdo) { global $logger; $logger->debug(get_class($this) . "::pdoToBean({$pdo})"); $copyOption = new CopyBeanOption(); $copyOption->setUseTargetVars(true); $copyOption->setScalarsOnly(true); $bean = new $pdo->scope(); $bean = BeanUtil::copyBean($pdo, $bean, $copyOption); // pubState to a string $ps = ''; if ($pdo->getPubState() != null) { $ps = $pdo->getPubState()->getValue(); } $bean->setPubState($ps); // related events from array of pdos to keyed array of oids $events = $pdo->getEvents(); if (!empty($events)) { $es = new EventService(); $related = array(); foreach ($events as $event) { $related[] = $es->getEventById($event->getScope(), $event->getOid()); } $bean->setEvents($related); } return $bean; }