Setup yiiStrap, works even if YiiBooster is used in main app.
358888
public function initYiiStrap()
    {
        // check that we are in a web application
        if (!(Yii::app() instanceof CWebApplication))
            return;
        // and in this module
        $route = explode('/', Yii::app()->urlManager->parseUrl(Yii::app()->request));
        if ($route[0] != $this->id)
            return;
        // and yiiStrap is not configured
        if (Yii::getPathOfAlias('bootstrap') && file_exists(Yii::getPathOfAlias('bootstrap.helpers') . '/TbHtml.php'))
            return;
        // try to guess yiiStrapPath
        if ($this->yiiStrapPath === null)
            $this->yiiStrapPath = Yii::getPathOfAlias('vendor.crisu83.yiistrap');
        // check for valid path
        if (!realpath($this->yiiStrapPath))
            return;
        // setup yiiStrap components
        Yii::setPathOfAlias('bootstrap', realpath($this->yiiStrapPath));
        Yii::import('bootstrap.helpers.*');
        Yii::import('bootstrap.widgets.*');
        Yii::import('bootstrap.behaviors.*');
        Yii::import('bootstrap.form.*');
        Yii::app()->setComponents(array(
            'bootstrap' => array(
                'class' => 'bootstrap.components.TbApi',
            ),
        ), false);
    }
687694
public function init()
	{
		parent::init();
		Yii::setPathOfAlias('gii',dirname(__FILE__));
		Yii::app()->setComponents(array(
			'errorHandler'=>array(
				'class'=>'CErrorHandler',
				'errorAction'=>$this->getId().'/default/error',
			),
			'user'=>array(
				'class'=>'CWebUser',
				'stateKeyPrefix'=>'gii',
				'loginUrl'=>Yii::app()->createUrl($this->getId().'/default/login'),
			),
			'widgetFactory' => array(
				'class'=>'CWidgetFactory',
				'widgets' => array()
			)
		), false);
		$this->generatorPaths[]='gii.generators';
		$this->controllerMap=$this->findGenerators();
	}
658904
public static function setInstalled()
		{
			// Set App secret
			Yii::$app->config->set(Enum::APP_SECRET, md5(uniqid(time(), TRUE)));

			$param = Configuration::getParam();
			$param[Enum::APP_INSTALLED] = TRUE;
			Configuration::setParam($param);
		}
621292
def setup(app):
    """"""
    app.connect('html-page-context', add_html_link)
    app.connect('build-finished', create_sitemap)
    app.set_translator('html', HTMLTranslator)
    app.sitemap_links = []
426515
public function bootstrap($app)
    {

        if ($app instanceof \yii\web\Application) {
            $started = false;
            $search = null;
            if (false === empty($this->searchClass)) {
                if (true === class_exists($this->searchClass)) {
                    $config = array_merge(['class' => $this->searchClass], $this->searchConfig);
                    $search = Yii::createObject($config);
                    $started = $search->getStarted();
                }
                if (false === $started) {
                    $search = new Search;
                }
                $this->search = $search;
            }
            $this->controllerMap['sort'] = [
                'class' => SortController::className(),
            ];
        }
        if ($app instanceof \yii\console\Application) {
            if ($this->searchClass === Elastic::class) {
                $this->controllerMap['elastic'] = [
                    'class' => ElasticIndexController::class,
                ];
            }
            $this->controllerMap['translate-eav'] = [
                'class' => TranslateEavController::class,
            ];
        }

        $this->registerTranslations();
    }
1136248
public function run()
	{
		if($this->getIsContentCached())
		{
			if($this->getController()->isCachingStackEmpty())
				echo $this->getController()->processDynamicOutput($this->_content);
			else
				echo $this->_content;
		}
		elseif($this->_cache!==null)
		{
			$this->_content=ob_get_clean();
			$this->getController()->getCachingStack()->pop();
			$data=array($this->_content,$this->_actions);
			if(is_array($this->dependency))
				$this->dependency=Yii::createComponent($this->dependency);
			$this->_cache->set($this->getCacheKey(),$data,$this->duration,$this->dependency);

			if($this->getController()->isCachingStackEmpty())
				echo $this->getController()->processDynamicOutput($this->_content);
			else
				echo $this->_content;
		}
	}
15044
private function setupApp()
    {
        if ($this->session instanceof \SessionHandlerInterface)
        {
            $serverStack = new SessionProvider(
                new WampServer(
                    $this->getContainer()->get("jdare_clank.clank_app")
                ),
                $this->session
            );

        }else{
            $serverStack = new WampServer(
                $this->getContainer()->get("jdare_clank.clank_app")
            );
        }


        $this->app = new WsServer(
            $serverStack
        );
    }
793867
public function init()
    {
        parent::init();
	if (get_class(Yii::app()) != "CConsoleApplication")
	{
		$asset = Yii::app()->assetManager->publish(__DIR__.DS.'..'.DS.'assets'.DS.'dist', true, -1, YII_DEBUG);
		$cs    = Yii::app()->getClientScript();

		$cs->registerScriptFile($asset.(YII_DEBUG ? '/ciianalytics.js' : '/ciianalytics.min.js'));

		$cs->registerScript('ciianalytics', 'ciianalytics.init();');
	}
    }
1266417
public function actionActivate ()
		{
			if (Yii::$app->request->isAjax)
			{
				$post = Yii::$app->request->post();
				$page = Page::findOne($post[ 'id' ]);
				$page->updateAttributes([ 'active' => $page->active ? 0 : 1 ]);

				echo $page->active;
			}
			Yii::$app->end();
		}
65872
public function init()
    {
        $this->conf = $this->getConfiguration();
        if (!isset($this->conf)) {
            throw new Exception("Adapter configuration not set, cannot initialize");
        }
        $this->adapters = array();
        foreach ($this->conf['adapters'] as $key => $adapter) {
            $adapterConf = ArrayHelper::merge($this->conf['common'], $adapter);

            $adapterConf['paymentHandler'] = $this;
            $adapterConf['adapterTag'] = $key;
            $this->adapters[$key] = \Yii::createObject($adapterConf);
        }
    }
271145
function init(): void {
    $helpers = [
      'app' => \Yii::$app,
      'format' => new helpers\Format,
      'html' => new helpers\Html,
      'i18n' => new helpers\I18N,
      'url' => new helpers\Url
    ];

    $options = [
      'charset' => \Yii::$app->charset,
      'entity_flags' => ENT_QUOTES | ENT_SUBSTITUTE,
      'escape' => [Html::class, 'encode'],
      'helpers' => ArrayHelper::merge($helpers, $this->helpers),
      'partials_loader' => new Loader(['viewRenderer' => $this]),
      'strict_callables' => true
    ];

    if ($this->enableCaching) {
      /** @var \yii\caching\Cache $cache */
      $cache = Instance::ensure($this->cache, \yii\caching\Cache::class);
      $this->cache = $cache;
      $options['cache'] = new Cache(['viewRenderer' => $this]);
    }

    if ($this->enableLogging) $options['logger'] = new Logger;
    $this->engine = new \Mustache_Engine($options);

    parent::init();
    $this->helpers = [];
  }
87462
public function run()
	{
		$id=$this->getId();
		if(isset($this->htmlOptions['id']))
			$id=$this->htmlOptions['id'];
		else
			$this->htmlOptions['id']=$id;

		echo CHtml::openTag($this->tagName,$this->htmlOptions);
		echo CHtml::closeTag($this->tagName);

		$this->options['value']=$this->value;
		$options=CJavaScript::encode($this->options);
		Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').progressbar($options);");
	}
745037
public function run()
    {
        // todo: think of a better way of doing this.
        $script = "jQuery('{$this->selector}').attr('data-spy', 'scroll');";
        if (isset($this->target)) {
            $script .= "jQuery('{$this->selector}').attr('data-target', '{$this->target}');";
        }
        if (isset($this->offset)) {
            $script .= "jQuery('{$this->selector}').attr('data-offset', '{$this->offset}');";
        }
        Yii::app()->clientScript->registerScript($this->getId(), $script, CClientScript::POS_BEGIN);
        $this->registerEvents($this->selector, $this->events);
    }
624469
public function run()
    {
        /** @var Model $model */
        $model = $this->model;
        $options = $this->options;
        unset($options['id']);

        // Add model meta
        $modelClassName = $model::className();
        $modelMeta = $model::meta();
        if (\Yii::$app->has('frontendState')) {
            \Yii::$app->frontendState->set('config.types.metas.' . $modelClassName, $modelMeta);
        } else {
            $jsArgs = [Json::encode($modelClassName), Json::encode($modelMeta)];
            \Yii::$app->view->registerJs('__appTypes.addModelMeta(' . implode(', ', $jsArgs) . ')', View::POS_END, 'app-form-' . $model::className());
        }

        // Add enums
        foreach ($model::meta() as $item) {
            if (!empty($item['enumClassName'])) {
                /** @var Enum $enumClass */
                $enumClass = $item['enumClassName'];
                $enumClassName = $enumClass::className();
                $props = [
                    'labels' => $enumClass::getLabels(),
                ];

                if (\Yii::$app->has('frontendState')) {
                    \Yii::$app->frontendState->set('config.types.enums.' . $enumClassName, $props);
                } else {
                    $jsArgs = [Json::encode($enumClassName), Json::encode($props)];
                    \Yii::$app->view->registerJs('__appTypes.addEnum(' . implode(', ', $jsArgs) . ')', View::POS_END, 'app-enum-' . $enumClass::className());
                }
            }
        }

        // Render field
        $props = array_merge([
            'formId' => $this->field ? $this->field->form->id : 'f' . ++self::$idCounter,
            'model' => $model::className(),
            'prefix' => $model->formName(),
            'attribute' => Html::getAttributeName($this->attribute),
        ], $options);
        if (\Yii::$app->has('frontendState')) {
            \Yii::$app->frontendState->add('config.types.toRenderField', [$this->id, $props]);
        } else {
            $jsArgs = [Json::encode($this->id), Json::encode($props)];
            \Yii::$app->view->registerJs('__appTypes.renderField(' . implode(', ', $jsArgs) . ')', View::POS_END, $this->id);
        }
        return Html::tag('span', '', ['id' => $this->id]);
    }
1039948
public function init()
    {
        // parsing needed if urlFormat 'path'
        if (Yii::app() instanceof CWebApplication) {
            Yii::app()->urlManager->parseUrl(Yii::app()->getRequest());
        }

        // 1. get language preference
        $preferred = null;
        if (isset($_GET[self::DATA_KEY])) {
            // use language from URL
            $preferred = $_GET[self::DATA_KEY];
        } elseif ($this->usePreferred) {
            // use preferred browser language as default
            $preferred = Yii::app()->request->preferredLanguage;
        } else {
            $preferred = Yii::app()->language;
        }

        // 2. select language based on available languages and mappings
        $lang = $this->resolveLanguage($preferred);

        if (is_null($lang) && $this->matchShort === true) {
            $preferredShort = substr($preferred, 0, 2);
            $lang           = $this->resolveLanguage($preferredShort);
        }
        // 3. set the language
        if (in_array($lang, $this->languages)) {
            Yii::app()->setLanguage($lang);
        } else {
            // fallback or output error
            if ($this->fallback) {
                // default app language
            } else {
                throw new CHttpException(404, "Language '{$_GET[self::DATA_KEY]}' is not available.");
            }
        }

        if ($this->localizedHomeUrl) {
            $controller         = new CController('P3LangHandlerDummy');
            Yii::app()->homeUrl = $controller->createUrl('/');
        }
    }
1283496
public function run() {

		if( isset( $this->model ) ) {

			$modelCommentService = Yii::$app->factory->get( 'modelCommentService' );

			$user = Yii::$app->user->getIdentity();

			$modelClass = $modelCommentService->getModelClass();

			$modelComment	= new $modelClass;
			$commentForm	= new Comment();

			$modelComment->siteId		= Yii::$app->core->getSiteId();
			$modelComment->parentId		= $this->model->id;
			$modelComment->parentType	= $this->parentType;

			$modelComment->status	= $this->status;
			$modelComment->type		= $this->modelType;

			// To set name and email in case user is logged in. The same details can be fetched from user table using createdBy column.
			if( $this->setUser && isset( $user ) ) {

				$modelComment->name		= $user->getName();
				$modelComment->email	= $user->email;
			}

			if( isset( $this->scenario ) ) {

				$commentForm->scenario = $this->scenario;
			}

			if( $commentForm->load( Yii::$app->request->post(), $commentForm->getClassName() ) && $commentForm->validate() ) {

				$modelComment->copyForUpdateFrom( $commentForm, [ 'baseId', 'bannerId', 'videoId', 'avatarUrl', 'websiteUrl', 'rating', 'anonymous', 'content' ] );

				if( !$this->setUser || !isset( $user ) ) {

					$modelComment->copyForUpdateFrom( $commentForm, [ 'name', 'email' ] );
				}

				$modelComment = $modelCommentService->create( $modelComment );

				if( isset( $modelComment ) ) {

					// Refresh model for further processing
					$modelComment->refresh();

					// Set controller model for post processing
					if( Yii::$app->controller->hasProperty( 'modelComment' ) ) {

						Yii::$app->controller->modelComment = $modelComment;
					}

					// Attach media to comment if allowed and available
					if( $this->media ) {

						$filesCount = count( Yii::$app->request->post( $this->mediaModel ) );

						$files = $this->initFiles( $filesCount );

						if( File::loadMultiple( $files, Yii::$app->request->post(), $this->mediaModel ) && File::validateMultiple( $files ) ) {

							foreach( $files as $file ) {

								$modelCommentService->attachMedia( $modelComment, $file, $this->mediaType, ModelComment::TYPE_COMMENT );
							}
						}
					}

					// Trigger Ajax Success
					return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ) );
				}
			}

			// Generate Validation Errors
			$errors = AjaxUtil::generateErrorMessage( $commentForm );

			// Trigger Ajax Failure
			return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
		}

		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
120369
public function run() {
		parent::run();
		WizardWidgetAsset::register($this->getView());


		// Wizard line calculation
		$step_count = count($this->steps)+($this->complete_content?1:0);
		$wizard_line_distribution = round(100 / $step_count); // Percentage
		$wizard_line_width = round(100 - $wizard_line_distribution); // Percentage
		$wizard_line = '';

		$tab_content = '';

		// Navigation tracker
		end($this->steps);
		$last_id = key($this->steps);

		$first = true;
		$class = '';

		foreach ($this->steps as $id => $step) {

			// Current or fist step is active, next steps are inactive (previous steps are available)
			if ($id == $this->start_step or (is_null($this->start_step) && $class == '')) {
				$class = 'active';
			} elseif ($class == 'active') {
				$class = 'disabled';
			}

			// Add icons to the wizard line
			$wizard_line .= Html::tag(
				'li',
				Html::a('<span class="round-tab"><i class="'.$step['icon'].'"></i></span>', '#step'.$id, [
					'data-toggle' => 'tab',
					'aria-controls' => 'step'.$id,
					'role' => 'tab',
					'title' => $step['title'],
				]),
				array_merge(
					[
						'role' => 'presentation',
						'class' => $class,
						'style' => ['width' => $wizard_line_distribution.'%']
					],
					isset($step['options']) ? $step['options'] : []
				)
			);

			// Setup tab content
			$tab_content .= '<div class="tab-pane '.$class.'" role="tabpanel" id="step'.$id.'">';
			$tab_content .= $step['content'];

			// Setup navigation buttons
			$buttons = [];
			$button_id = "{$this->id}_step{$id}_";
			if (!$first) {
				// Show previous button except on first step
				$buttons[] = $this->navButton('prev', $step, $button_id);
			}
			if (array_key_exists('skippable', $step) and $step['skippable'] === true) {
				// Show skip button if specified
				$buttons[] = $this->navButton('skip', $step, $button_id);
			}
			if ($id == $last_id) {
				// Show save button on last step
				$buttons[] = $this->navButton('save', $step, $button_id);
			} else {
				// On all previous steps show next button
				$buttons[] = $this->navButton('next', $step, $button_id);
			}
			// Add buttons to tab content
			$tab_content .= Html::ul($buttons, ['class' => 'list-inline pull-right', 'encode' => false]);

			// Finish tab
			$tab_content .= '</div>';

			$first = false;
		}

		// Add a completed step if specified
		if ($this->complete_content) {
			$class = 'disabled';

			// Check if completed tab is set as start_step
			if ($this->start_step == 'completed') {
				$class = 'active';
			}

			// Add completed icon to wizard line
			$wizard_line .= Html::tag(
				'li',
				Html::a('<span class="round-tab"><i class="glyphicon glyphicon-ok"></i></span>', '#complete', [
					'data-toggle' => 'tab',
					'aria-controls' => 'complete',
					'role' => 'tab',
					'title' => 'Complete',
				]),
				[
					'role' => 'presentation',
					'class' => $class,
					'style' => ['width' => $wizard_line_distribution.'%']
				]
			);

			$tab_content .= '<div class="tab-pane '.$class.'" role="tabpanel" id="complete">'.$this->complete_content.'</div>';
		}

		// Start widget
		echo '<div class="wizard" id="'.$this->id.'">';

		// Render the steps line
		echo '<div class="wizard-inner"><div class="connecting-line" style="width:'.$wizard_line_width.'%"></div>';
		echo '<ul class="nav nav-tabs" role="tablist">'.$wizard_line.'</ul>';
		echo '</div>';

		// Render the content tabs
		echo '<div class="tab-content">'.$tab_content.'</div>';

		// Finalize the content tabs
		echo '<div class="clearfix"></div>';

		// Finish widget
		echo '</div>';
	}