コード例 #1
0
ファイル: PersonService.php プロジェクト: justinlyon/scc
 /**
  * Converts the given Person PDO to a bean object.
  * This includes the conversion from nested lists
  * of PDO objects to usable lists of oids/names to be used
  * by the page renderer.
  * 
  * @access private
  * @param pdo $pdo Person
  * @return bean Person
  */
 private function pdoToBean($pdo)
 {
     global $logger;
     $logger->debug(get_class($this) . "::pdoToBean({$pdo})");
     // if this is an artist, be sure to get the artist PDO not the person
     $scope = $pdo->getScope();
     $id = $pdo->getOid();
     if ($scope == 'Artist') {
         $epm = epManager::instance();
         $pdo = $epm->get('Artist', $id);
     }
     $bean = new $scope($pdo->epGetVars());
     // pubState to a string
     $ps = '';
     if ($pdo->getPubState() != null) {
         $ps = $pdo->getPubState()->getValue();
     }
     $bean->setPubState($ps);
     // if it is an artist, convert the exhibitions
     if (get_class($bean) == 'Artist') {
         $exhibitions = $pdo->exhibitions;
         if ($exhibitions) {
             $related = array();
             foreach ($exhibitions as $event) {
                 $related[] = new Exhibition($event->epGetVars());
             }
             $bean->setExhibitions($related);
         }
     }
     return $bean;
 }