/**
  * Indexing the contents of the specified models.
  * @throws InvalidConfigException
  */
 public function index()
 {
     if ($this->luceneIndex->count() !== 0) {
         $this->luceneIndex = Lucene::create($this->indexDirectory);
     }
     /** @var \yii\db\ActiveRecord $model */
     foreach ($this->models as $model) {
         if (!is_subclass_of($model::className(), __NAMESPACE__ . '\\SearchInterface')) {
             throw new InvalidConfigException('The model object must implement `SearchInterface`');
         }
         /** @var SearchInterface $page */
         foreach ($model::find()->all() as $page) {
             $this->luceneIndex->addDocument($this->createDocument($page->getSearchTitle(), $page->getSearchBody(), $page->getSearchUrl()));
         }
     }
 }
 /**
  * Indexing the contents of the specified models.
  * @throws InvalidConfigException
  */
 public function index()
 {
     if ($this->luceneIndex->count() !== 0) {
         $this->luceneIndex = Lucene::create($this->indexDirectory);
     }
     /** @var \yii\db\ActiveRecord $modelName */
     foreach ($this->models as $modelName) {
         /** @var behaviors\SearchBehavior $model */
         /** @var array $page */
         $model = new $modelName();
         if ($model->hasMethod('getSearchModels')) {
             foreach ($model->getSearchModels()->all() as $pageModel) {
                 $this->luceneIndex->addDocument($this->createDocument(call_user_func($model->searchFields, $pageModel)));
             }
         } else {
             throw new InvalidConfigException("Not found right `SearchBehavior` behavior in `{$modelName}`.");
         }
     }
 }