Ejemplo n.º 1
0
 /**
  * Load all attributes after an select.
  *
  * @param Doctrine_Event $event Event.
  *
  * @return void
  */
 public function postHydrate(Doctrine_Event $event)
 {
     $data = $event->data;
     $tableName = $this->getTableNameFromEvent($event);
     $idColumn = $this->getIdColumnFromEvent($event);
     $dataForObjectUtil = array();
     $dataForObjectUtil[$idColumn] = $data[$idColumn];
     ObjectUtil::expandObjectWithAttributes($dataForObjectUtil, $tableName, $idColumn);
     if (isset($dataForObjectUtil['__ATTRIBUTES__'])) {
         $data['__ATTRIBUTES__'] = $dataForObjectUtil['__ATTRIBUTES__'];
     }
 }
Ejemplo n.º 2
0
 /**
  * Post-processing for selected objects.
  *
  * This routine is responsible for reading the 'extra' data
  * (attributes, categories, and meta data) from the database and inserting the relevant sub-objects into the object.
  *
  * @param array   $objects     The object-array or the object we just selected.
  * @param string  $table       The treated table reference.
  * @param integer $idFieldName The id column for the object/table combination.
  *
  * @return array the object with it's relevant sub-objects set.
  *
  * @deprecated
  * @see    CategorisableListener, AttributableListener, MetaDataListener
  */
 public static function _selectPostProcess($objects, $table, $idFieldName)
 {
     // nothing to do if objects is empty
     if (is_array($objects) && count($objects) == 0) {
         return $objects;
     }
     $tables = self::getTables();
     $enableAllServices = isset($tables["{$table}_db_extra_enable_all"]) && $tables["{$table}_db_extra_enable_all"];
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_categorization"]) && $tables["{$table}_db_extra_enable_categorization"]) && System::getVar('Z_CONFIG_USE_OBJECT_CATEGORIZATION') && strcmp($table, 'categories_') !== 0 && strcmp($table, 'objectdata_attributes') !== 0 && strcmp($table, 'objectdata_log') !== 0 && ModUtil::available('ZikulaCategoriesModule')) {
         if (is_array($objects)) {
             $ak = array_keys($objects);
             if ($ak && is_array($objects[$ak[0]])) {
                 ObjectUtil::expandObjectArrayWithCategories($objects, $table, $idFieldName);
             } else {
                 ObjectUtil::expandObjectWithCategories($objects, $table, $idFieldName);
             }
         }
     }
     // temporary hack to prevent recursive loop because available() calls selectObjectArray again (Guite)
     if ($table == 'modules') {
         return $objects;
     }
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_attribution"]) && $tables["{$table}_db_extra_enable_attribution"] || System::getVar('Z_CONFIG_USE_OBJECT_ATTRIBUTION')) && strcmp($table, 'objectdata_attributes') !== 0 && strcmp($table, 'objectdata_log') !== 0) {
         if (is_array($objects)) {
             $ak = array_keys($objects);
             if ($ak && is_array($objects[$ak[0]])) {
                 foreach ($ak as $k) {
                     ObjectUtil::expandObjectWithAttributes($objects[$k], $table, $idFieldName);
                 }
             } else {
                 ObjectUtil::expandObjectWithAttributes($objects, $table, $idFieldName);
             }
         }
     }
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_meta"]) && $tables["{$table}_db_extra_enable_meta"] || System::getVar('Z_CONFIG_USE_OBJECT_META')) && strcmp($table, 'objectdata_attributes') !== 0 && strcmp($table, 'objectdata_meta') !== 0 && strcmp($table, 'objectdata_log') !== 0) {
         if (is_array($objects)) {
             $ak = array_keys($objects);
             if ($ak && is_array($objects[$ak[0]])) {
                 foreach ($ak as $k) {
                     ObjectUtil::expandObjectWithMeta($objects[$k], $table, $idFieldName);
                 }
             } else {
                 ObjectUtil::expandObjectWithMeta($objects, $table, $idFieldName);
             }
         }
     }
     return $objects;
 }