示例#1
0
 /**
  * Convert entity to array
  *
  * @access private
  * @param  \CB\Entity\Entity $Entity
  * @return array
  * @static
  */
 public function serialize($Entity)
 {
     $metadata = \CB\Doctrine\EntityManager::getInstance()->getClassMetadata(get_class($Entity));
     $output = [];
     foreach ($metadata->fieldMappings as $field => $mapping) {
         $value = $metadata->reflFields[$field]->getValue($Entity);
         if ($value instanceof \DateTime) {
             $output[$field] = $value->format(\DateTime::ATOM);
         } else {
             if (is_object($value)) {
                 $output[$field] = (string) $value;
             } else {
                 $output[$field] = $value;
             }
         }
     }
     return $output;
 }
示例#2
0
 /**
  * Get entity manager.
  *
  * @access protected
  * @return \CB\Doctrine\EntityManager
  */
 protected function getEntityManager()
 {
     return \CB\Doctrine\EntityManager::getInstance();
 }
示例#3
0
文件: cli-config.php 项目: nexcra/cb5
<?php

// composer autoloader
require_once 'vendor/autoload.php';
// load climbuddy core
require_once 'CB/Core.php';
// set json friendly error handler
set_error_handler('\\CB\\errorHandler');
// register climbuddy autoloader
spl_autoload_register('\\CB\\autoLoader');
$em = \CB\Doctrine\EntityManager::getInstance();
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)));
return $helperSet;