public function getModelsClasses($modelsPath, $modelsNamespace)
    {
        $path = Yii::getAlias($modelsPath);
        $files = @scandir($path);

        if ($files === false) {
            throw new InvalidConfigException('Path to sitemap models "' . $modelsPath . '"(' .
                $path . ') is incorrect');
        }

        $buffer = [];
        foreach ($files as $file) {
            if ($file == '.' || $file == '..' || !is_file($path . DIRECTORY_SEPARATOR . $file)) {
                continue;
            }

            // Search only .php files
            $ext = substr($file, -4);
            if ($ext !== '.php') {
                continue;
            }

            // Combine model class name
            $className = $modelsNamespace . '\\' . str_replace($ext, '', $file);

            // Create new model instance
            $model = Yii::createObject($className);

            if (!$model instanceof Basic) {
                $this->printMessage('Warning: model "' . $className . '" does not implement interface ' .
                    '"demi\sitemap\interfaces\Basic"');

                continue;
            }

            // Add class to list
            $buffer[] = $model;

            // Analysis xml-schemas by $model interfaces
            $this->collectSchemas($model);
        }

        return $buffer;
    }
public function getModelsClasses($modelsPath, $modelsNamespace)
    {
        $path = Yii::getAlias($modelsPath);
        $files = @scandir($path);

        if ($files === false) {
            throw new InvalidConfigException('Path to sitemap models "' . $modelsPath . '"(' .
                $path . ') is incorrect');
        }

        $buffer = [];
        foreach ($files as $file) {
            if ($file == '.' || $file == '..' || !is_file($path . DIRECTORY_SEPARATOR . $file)) {
                continue;
            }

            // Search only .php files
            $ext = substr($file, -4);
            if ($ext !== '.php') {
                continue;
            }

            // Combine model class name
            $className = $modelsNamespace . '\\' . str_replace($ext, '', $file);

            // Create new model instance
            $model = Yii::createObject($className);

            if (!$model instanceof Basic) {
                $this->printMessage('Warning: model "' . $className . '" does not implement interface ' .
                    '"demi\sitemap\interfaces\Basic"');

                continue;
            }

            // Add class to list
            $buffer[] = $model;

            // Analysis xml-schemas by $model interfaces
            $this->collectSchemas($model);
        }

        return $buffer;
    }
public function getModelsClasses ( $ modelsPath , $ modelsNamespace ) { $ path = Yii :: getAlias ( $ modelsPath ) ; $ files = @ scandir ( $ path ) ; if ( $ files === false ) { throw new InvalidConfigException ( 'Path to sitemap models "' . $ modelsPath . '"(' . $ path . ') is incorrect' ) ; } $ buffer = [ ] ; foreach ( $ files as $ file ) { if ( $ file == '.' || $ file == '..' || ! is_file ( $ path . DIRECTORY_SEPARATOR . $ file ) ) { continue ; } // Search only .php files $ ext = substr ( $ file , - 4 ) ; if ( $ ext !== '.php' ) { continue ; } // Combine model class name $ className = $ modelsNamespace . '\\' . str_replace ( $ ext , '' , $ file ) ; // Create new model instance $ model = Yii :: createObject ( $ className ) ; if ( ! $ model instanceof Basic ) { $ this -> printMessage ( 'Warning: model "' . $ className . '" does not implement interface ' . '"demi\sitemap\interfaces\Basic"' ) ; continue ; } // Add class to list $ buffer [ ] = $ model ; // Analysis xml-schemas by $model interfaces $ this -> collectSchemas ( $ model ) ; } return $ buffer ; }
Get list of sitemap model instancies

@param string $modelsPath Alias to sitemap-models dir
@param string $modelsNamespace

@throws \yii\base\InvalidConfigException
@return ActiveRecord[]|Basic[]
Get list of sitemap model instancies