Exemplo n.º 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['ObjectCategory'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['ObjectCategory'][$this->hashCode()] = true;
     $keys = ObjectCategoryTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getIdObject(), $keys[1] => $this->getIdCategory());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aCategory) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'category';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'category';
                     break;
                 default:
                     $key = 'Category';
             }
             $result[$key] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aObject) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'object';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'object';
                     break;
                 default:
                     $key = 'Object';
             }
             $result[$key] = $this->aObject->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
Exemplo n.º 2
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['CategoryOption'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['CategoryOption'][$this->hashCode()] = true;
     $keys = CategoryOptionTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getCategoryId(), $keys[2] => $this->getDescription(), $keys[3] => $this->getComment(), $keys[4] => $this->getModComment(), $keys[5] => $this->getValue(), $keys[6] => $this->getSequence(), $keys[7] => $this->getParentId());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aCategory) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'category';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'category';
                     break;
                 default:
                     $key = 'Category';
             }
             $result[$key] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aCategoryOptionRelatedByParentId) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'categoryOption';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'category_option';
                     break;
                 default:
                     $key = 'CategoryOption';
             }
             $result[$key] = $this->aCategoryOptionRelatedByParentId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collCategoryOptionsRelatedById) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'categoryOptions';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'category_options';
                     break;
                 default:
                     $key = 'CategoryOptions';
             }
             $result[$key] = $this->collCategoryOptionsRelatedById->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collRatingValues) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'ratingValues';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'rating_values';
                     break;
                 default:
                     $key = 'RatingValues';
             }
             $result[$key] = $this->collRatingValues->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }