/** * Constructor * * @param array $options */ public function __construct(array $options = array()) { if (!isset($options['name'])) { throw new \Exception('[Norm/Collection] Missing name, check collection configuration!'); } $this->clazz = Inflector::classify($options['name']); $this->name = Inflector::tableize($this->clazz); if (isset($options['connection'])) { $this->connection = $options['connection']; unset($options['connection']); $options['debug'] = $this->connection->option('debug') ? true : false; } if (isset($options['observers'])) { foreach ($options['observers'] as $Observer => $observerOptions) { if (is_int($Observer)) { $Observer = $observerOptions; $observerOptions = null; } if (is_string($Observer)) { $Observer = new $Observer($observerOptions); } $this->observe($Observer); } } if (isset($options['schema'])) { $this->schema = new Object($options['schema']); unset($options['schema']); } else { $this->schema = new Object(); } $this->options = $options; $this->applyHook('initialized', $this); $this->resetCache(); }