コード例 #1
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['PeriodicTypeI18n'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['PeriodicTypeI18n'][$this->hashCode()] = true;
     $keys = PeriodicTypeI18nTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getPeriodicTypeId(), $keys[1] => $this->getLocale(), $keys[2] => $this->getPeriodicTypeName());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aPeriodicType) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'periodicType';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'periodic_type';
                     break;
                 default:
                     $key = 'PeriodicType';
             }
             $result[$key] = $this->aPeriodicType->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
コード例 #2
0
ファイル: PeriodicPlan.php プロジェクト: mtornero/slowshop
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['PeriodicPlan'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['PeriodicPlan'][$this->hashCode()] = true;
     $keys = PeriodicPlanTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getPeriodicPlanId(), $keys[1] => $this->getResourceId(), $keys[2] => $this->getPeriodicPlanName(), $keys[3] => $this->getPeriodicPlanPoint(), $keys[4] => $this->getPeriodicTypeId(), $keys[5] => $this->getDelieveryPeriodicWeekday(), $keys[6] => $this->getPeriodicPlanPic(), $keys[7] => $this->getCreatedAt(), $keys[8] => $this->getUpdatedAt());
     if ($result[$keys[7]] instanceof \DateTime) {
         $result[$keys[7]] = $result[$keys[7]]->format('c');
     }
     if ($result[$keys[8]] instanceof \DateTime) {
         $result[$keys[8]] = $result[$keys[8]]->format('c');
     }
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aResource) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'resource';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'resource';
                     break;
                 default:
                     $key = 'Resource';
             }
             $result[$key] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aPeriodicType) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'periodicType';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'periodic_type';
                     break;
                 default:
                     $key = 'PeriodicType';
             }
             $result[$key] = $this->aPeriodicType->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aFile) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'file';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'file';
                     break;
                 default:
                     $key = 'File';
             }
             $result[$key] = $this->aFile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collDeliveryPeriodics) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'deliveryPeriodics';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'delivery_periodics';
                     break;
                 default:
                     $key = 'DeliveryPeriodics';
             }
             $result[$key] = $this->collDeliveryPeriodics->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collPeriodicPlanExceptions) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'periodicPlanExceptions';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'periodic_plan_exceptions';
                     break;
                 default:
                     $key = 'PeriodicPlanExceptions';
             }
             $result[$key] = $this->collPeriodicPlanExceptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collUserPeriodicPlans) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'userPeriodicPlans';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'user_periodic_plans';
                     break;
                 default:
                     $key = 'UserPeriodicPlans';
             }
             $result[$key] = $this->collUserPeriodicPlans->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }