Ejemplo n.º 1
0
 /**
  * 格式化从Data class获得的配置信息
  *
  * @param array $options
  * @return array
  */
 protected function normalizeOptions(array $options)
 {
     $options = array_merge(array('service' => null, 'collection' => null, 'attributes' => array(), 'readonly' => false, 'strict' => false), $options);
     $primary_key = array();
     foreach ($options['attributes'] as $key => $attribute) {
         $attribute = Types::normalizeAttribute($attribute);
         if ($attribute['strict'] === null) {
             $attribute['strict'] = $options['strict'];
         }
         if ($attribute['primary_key'] && !$attribute['deprecated']) {
             $primary_key[] = $key;
         }
         $options['attributes'][$key] = $attribute;
     }
     if (!$primary_key) {
         throw new \RuntimeException('Mapper: undefined primary key');
     }
     $options['primary_key'] = $primary_key;
     return $options;
 }