<?php

namespace PortalPeople\mcp;

use yii\base\BootstrapInterface;
use yii\base\Module as BaseModule;
use yii\console\Application as ConsoleApplication;

class Module extends BaseModule implements BootstrapInterface
{
    public $controllerNamespace = 'PortalPeople\\mcp\\controllers';

    public function bootstrap($app)
    {
        $this->id = 'mcp';

        if (!isset($app->getModules()[$this->id])) {
            $app->setModule($this->id, $this);
        }

        if (!($app instanceof ConsoleApplication) && isset($app->urlManager)) {
            $app->urlManager->addRules([
                'mcp/rpc' => 'mcp/mcp/rpc',
                'mcp/setup' => 'mcp/config/setup',
                'mcp/config/setup' => 'mcp/config/setup',
            ], false);
        }
    }
}
