コード例 #1
0
 public function getMetadata($className, $group = 'default')
 {
     $metadata = new Metadata();
     $columns = $fieldsMetadata = $groupBy = array();
     foreach ($this->getDrivers() as $driver) {
         $columns = array_merge($columns, $driver->getClassColumns($className, $group));
         $fieldsMetadata[] = $driver->getFieldsMetadata($className, $group);
         $groupBy = array_merge($groupBy, $driver->getGroupBy($className, $group));
     }
     $mappings = $cols = array();
     foreach ($columns as $fieldName) {
         $map = array();
         foreach ($fieldsMetadata as $field) {
             if (isset($field[$fieldName]) && (!isset($field[$fieldName]['groups']) || in_array($group, (array) $field[$fieldName]['groups']))) {
                 $map = array_merge($map, $field[$fieldName]);
             }
         }
         if (!empty($map)) {
             $mappings[$fieldName] = $map;
             $cols[] = $fieldName;
         }
     }
     $metadata->setFields($cols);
     $metadata->setFieldsMappings($mappings);
     $metadata->setGroupBy($groupBy);
     return $metadata;
 }