/** * This function check indexes and applies them to the collection if needed * see CModel::init() * * @see EMongoEmbeddedDocument::init() * @since v1.1 */ public function init() { parent::init(); if ($this->ensureIndexes && !isset(self::$_indexes[$this->getCollectionName()])) { $indexInfo = $this->getCollection()->getIndexInfo(); array_shift($indexInfo); // strip out default _id index $indexes = array(); foreach ($indexInfo as $index) { $indexes[$index['name']] = array('key' => $index['key'], 'unique' => isset($index['unique']) ? $index['unique'] : false); } self::$_indexes[$this->getCollectionName()] = $indexes; $this->ensureIndexes(); } }