<?php

namespace YiiElfinder2;


use yiins\web\Action;
use yiins\Yii;

class FileManagerPage extends Action
{
    public $config = [];

    /**
     * @return string
     * @throws \CException
     */
    public function run()
    {
        AssetBundle::register();
        $assetUrl = AssetBundle::getUrl();
        $config = \CJavaScript::encode($this->config);
        $js = <<<JS
window.assetUrl = '{$assetUrl}';
define('elFinderConfig', {$config});
JS;
        Yii::web()->clientScript->registerScript('yiielfinder2-page', $js);

        return $this->controller->render(__DIR__ . '/views/page');
    }
}