Exemple #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['UnitI18n'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['UnitI18n'][$this->hashCode()] = true;
     $keys = UnitI18nTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getUnitId(), $keys[1] => $this->getLocale(), $keys[2] => $this->getUnitName());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aUnit) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'unit';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'unit';
                     break;
                 default:
                     $key = 'Unit';
             }
             $result[$key] = $this->aUnit->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
Exemple #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['Product'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Product'][$this->hashCode()] = true;
     $keys = ProductTableMap::getFieldNames($keyType);
     $keys_resource = \App\Propel\Map\ResourceTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getProductId(), $keys[1] => $this->getResourceId(), $keys[2] => $this->getProductName(), $keys[3] => $this->getProductDescription(), $keys[4] => $this->getCategoryId(), $keys[5] => $this->getProviderId(), $keys[6] => $this->getUnitId(), $keys[7] => $this->getProductRange(), $keys[8] => $this->getProductPrice(), $keys[9] => $this->getProductIsActive(), $keys[10] => $this->getProductPic(), $keys[11] => $this->getCreatedAt(), $keys[12] => $this->getUpdatedAt(), $keys_resource[1] => $this->getResourceType(), $keys_resource[2] => $this->getSocialViews(), $keys_resource[3] => $this->getSocialLikes(), $keys_resource[4] => $this->getSocialDislikes(), $keys_resource[5] => $this->getSocialComments(), $keys_resource[6] => $this->getSocialFavourites(), $keys_resource[7] => $this->getSocialRecommendations());
     if ($result[$keys[11]] instanceof \DateTime) {
         $result[$keys[11]] = $result[$keys[11]]->format('c');
     }
     if ($result[$keys[12]] instanceof \DateTime) {
         $result[$keys[12]] = $result[$keys[12]]->format('c');
     }
     $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->aProvider) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'provider';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'provider';
                     break;
                 default:
                     $key = 'Provider';
             }
             $result[$key] = $this->aProvider->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aUnit) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'unit';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'unit';
                     break;
                 default:
                     $key = 'Unit';
             }
             $result[$key] = $this->aUnit->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->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->collOrderProducts) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'orderProducts';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'order_products';
                     break;
                 default:
                     $key = 'OrderProducts';
             }
             $result[$key] = $this->collOrderProducts->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collProductHighlighteds) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'productHighlighteds';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'product_highlighteds';
                     break;
                 default:
                     $key = 'ProductHighlighteds';
             }
             $result[$key] = $this->collProductHighlighteds->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collProductVariationTypes) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'productVariationTypes';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'product_variation_types';
                     break;
                 default:
                     $key = 'ProductVariationTypes';
             }
             $result[$key] = $this->collProductVariationTypes->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collWishlistProducts) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'wishlistProducts';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'wishlist_products';
                     break;
                 default:
                     $key = 'WishlistProducts';
             }
             $result[$key] = $this->collWishlistProducts->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }