private function constructMetaclass($modelClass, $collectionName, array $options) { $metaclass = new Metaclass(); $metaclass->setModelClass($modelClass); $metaclass->setStorageName($collectionName); if (array_key_exists('properties', $options)) { $properties = $options['properties']; } else { if (!$this->adapter->supportsReflection()) { throw new Exception("This adapter does not support reflection ; you must provide a properties array"); } $properties = $this->adapter->reflect($collectionName); } $include = array_key_exists('include_properties', $options) ? $options['include_properties'] : false; $exclude = array_key_exists('exclude_properties', $options) ? $options['exclude_properties'] : array(); $ref = new ReflectionClass($modelClass); foreach ($properties as $property) { if (!$ref->hasProperty($property->name)) { throw new Exception("Property '{$property->name}' not found in {$modelClass} ; mapping fails"); } if (($include === false || in_array($property->name, $include)) && !in_array($property->name, $exclude)) { $metaclass->{$property->name} = $property; } } return $metaclass; }