yii\base\Component -----
432044
public function behaviors() {

		$behaviors = parent::behaviors();

		$behaviors[ 'rbac' ][ 'actions' ][ 'gallery' ] = [ 'permission' => $this->crudPermission ];
		$behaviors[ 'rbac' ][ 'actions' ][ 'data' ] = [ 'permission' => $this->crudPermission ];
		$behaviors[ 'rbac' ][ 'actions' ][ 'config' ] = [ 'permission' => $this->crudPermission ];
		$behaviors[ 'rbac' ][ 'actions' ][ 'settings' ] = [ 'permission' => $this->crudPermission ];

		$behaviors[ 'verbs' ][ 'actions' ][ 'gallery' ] = [ 'get' ];
		$behaviors[ 'verbs' ][ 'actions' ][ 'data' ] = [ 'get', 'post' ];
		$behaviors[ 'verbs' ][ 'actions' ][ 'config' ] = [ 'get', 'post' ];
		$behaviors[ 'verbs' ][ 'actions' ][ 'settings' ] = [ 'get', 'post' ];

		$behaviors[ 'activity' ] = [
			'class' => ActivityBehavior::class,
			'admin' => true,
			'create' => [ 'create' ],
			'update' => [ 'update' ],
			'delete' => [ 'delete' ]
		];

		return $behaviors;
	}
253378
public function init() {

		parent::init();

		// Permission
		$this->crudPermission = CoreGlobal::PERM_CORE;

		// Config
		$this->apixBase = 'core/city';

		// Services
		$this->modelService		= Yii::$app->factory->get( 'cityService' );

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

		// Sidebar
		$this->sidebar = [ 'parent' => 'sidebar-core', 'child' => 'country' ];

		// Return Url
		$this->returnUrl = Url::previous( 'cities' );
		$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/core/province/city/all' ], true );

		// Country Url
		$countryUrl = Url::previous( 'countries' );
		$countryUrl = isset( $countryUrl ) ? $countryUrl : Url::toRoute( [ '/core/country/all' ], true );

		// Province Url
		$provinceUrl = Url::previous( 'provinces' );
		$provinceUrl = isset( $provinceUrl ) ? $provinceUrl : Url::toRoute( [ '/core/country/province/all' ], true );

		// Breadcrumbs
		$this->breadcrumbs = [
			'base' => [
				[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ],
				[ 'label' => 'Countries', 'url' =>  $countryUrl ],
				[ 'label' => 'Provinces', 'url' =>  $provinceUrl ]
			],
			'all' => [ [ 'label' => 'Cities' ] ],
			'create' => [ [ 'label' => 'Cities', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
			'update' => [ [ 'label' => 'Cities', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
			'delete' => [ [ 'label' => 'Cities', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ]
		];
	}
600786
public static function getImageComponent()
    {
        // Get image component
        if (is_object(static::$_imageComponent)) {
            $imageComponent = static::$_imageComponent;
        } else {
            $imageComponent = Yii::createObject([
                'class' => 'yii\image\ImageDriver',
            ]);
            // Store component for future using
            static::$_imageComponent = $imageComponent;
        }

        return $imageComponent;
    }
247966
public function actionAllCmd()
    {
        /**
         * @var $controllerHelp HelpController
         */
        $controllerHelp = \Yii::$app->createController('help')[0];
        $commands = $controllerHelp->getCommands();

        foreach ($controllerHelp->getCommands() as $controller) {
            $subController = \Yii::$app->createController($controller)[0];
            $actions = $controllerHelp->getActions($subController);

            if ($actions) {
                foreach ($actions as $actionId) {
                    $commands[] = $controller . "/" . $actionId;
                }
            }
        };

        $this->stdout(implode("\n", $commands));
    }
556362
public function init()
	{
		//assert proper model is set
		if ($this->subject === null || !ComponentConfig::isActiveRecord($this->subject, false)) {
			$msg = Yii::t('app', 'Setting the model property of type ActiveRecord is mandatory');
			throw new InvalidConfigException($msg);
		}
		ComponentConfig::hasBehavior($this->subject, CommentsBehavior::className(), true);

		//load the comments
		$this->loadComments();

		//prepare options
		Html::addCssClass($this->options, 'widget-comments');
		Html::addCssClass($this->commentOptions, 'comment');
	}
902036
public function actionGenerate()
    {
        $this->stdout("Polary Devkit Tool (based on Yii)\n\n");
        try {
            $component = $this->getComponent();
            $configList = $this->getConfig($component);
            $config = new Config([
                'files' => $configList,
            ]);
            $builder = new Builder([
                'components' => $config->getComponents(),
                'template'   => require __DIR__ . '/templates/helper.php',
            ]);
            if ($component->result === null) {
                $component->result = ($this->getDetector()->detect() === 'basic') ?
                    '@app/_ide_components.php' :
                    '@console/../_ide_components.php';
            }

            $result = Yii::getAlias($component->result);
            $result = FileHelper::normalizePath($result);

            $this->stdout("Generate new IDE auto-completion code '{$result}'\n");
            $time = microtime(true);
            $builder->build($result);
            $this->stdout('New auto-completion code created successfully. (time: ' . sprintf('%.3f', microtime
                    (true) - $time) . "s)\n", Console::FG_GREEN);
        } catch (Exception $exception) {
            $this->stdout('Generate failed ' . $exception->getMessage() .  "\n", Console::FG_RED);
        }
    }
1313631
public function init() 
	{
		$arrThemes = $this->currentTemplate('public');
		Yii::app()->theme = $arrThemes['folder'];
		$this->layout = $arrThemes['layout'];
		//$this->pageGuest = true;
	}
1103082
public function actionIndex()
    {
        $this->showDescription();
        try {
            $component = $this->getComponent();
            $configList = $this->getConfig($component);
            $config = new Config([
                'files' => $configList,
            ]);
            $builder = new Builder([
                'components' => $config->getComponents(),
                'template' => require __DIR__ . '/template.php',
            ]);
            if ($component->result === null) {
                $component->result = ($this->getDetector()->detect() === 'basic') ?
                    '@app/_ide_components.php' :
                    '@console/../_ide_components.php';
            }
            $result = Yii::getAlias($component->result);
            $result = FileHelper::normalizePath($result);
            if ($builder->build($result)) {
                $this->stdout("Success: {$result}\n", Console::FG_GREEN);
            } else {
                $this->stdout("Fail!\n", Console::FG_RED);
            }
        } catch (Exception $exception) {
            $this->stdout($exception->getMessage() . "\n\n", Console::FG_RED);
            $this->stdout("Please read the package documentation: https://github.com/iiifx-production/yii2-autocomplete-helper\n");
            $this->stdout("or create new issue: https://github.com/iiifx-production/yii2-autocomplete-helper/issues/new\n");
        }
    }
1199887
public function init()
	{
		parent::init();
		if($this->basePath===null)
			$this->basePath=Yii::getPathOfAlias('application.messages');
	}
35958
public function actionEdit ()
		{
			$id = Yii::$app->request->get('id');
			$menu = Menu::findOne($id);
			if ($menu == null)
			{
				Yii::$app->notification->messageToSession(Yii::tr('Menu item not found.', [], 'menu'));
				$this->redirect(Yii::$app->request->referrer);
			}
			if (Yii::$app->request->isPost)
			{
				$post = Yii::$app->request->post('Menu');

				$menu->updateAttributes([
					'title' => $post[ 'title' ],
					'url'   => $post[ 'url' ],
					'path'  => $post[ 'path' ]
				]);

				$menu->save();
				Yii::$app->notification->messageToSession(Yii::tr('Menu item was saved.', [], 'menu'));
				$this->redirect(Url::toRoute([ '/menu/index', 'type' => $menu->typeID ]));
			}
			$this->data('model', $menu);
			$this->setTitle(Yii::tr('Edit menu item', [], 'menu'));
			$this->_tpl = '@menuViews/add';
		}
760449
public function actionMain()
    {
        switch (yii::$app->getDb()->driverName) {
            case "mysql":
                $dbInfo = 'MySQL ' . (new Query())->select('version()')->one()['version()'];
                break;
            case "pgsql":
                $dbInfo = (new Query())->select('version()')->one()['version'];
                break;
            default:
                $dbInfo = "Unknown";
        }
        $info = [
            'OPERATING_ENVIRONMENT' => PHP_OS . ' ' . $_SERVER['SERVER_SOFTWARE'],
            'PHP_RUN_MODE' => php_sapi_name(),
            'DB_INFO' => $dbInfo,
            'PROGRAM_VERSION' => "1.0",
            'UPLOAD_MAX_FILESIZE' => ini_get('upload_max_filesize'),
            'MAX_EXECUTION_TIME' => ini_get('max_execution_time') . "s"
        ];
        $obj = new ServerInfo();
        $serverInfo = $obj->getinfo();
        error_reporting(E_ALL);
        $status = [
            'DISK_SPACE' => [
                'NUM' => ceil( $serverInfo['diskTotal'] - $serverInfo['freeSpace'] ) . 'G' . ' / ' . ceil($serverInfo['diskTotal']) . 'G',
                'PERCENTAGE' => (floatval($serverInfo['diskTotal']) != 0) ? round(($serverInfo['diskTotal'] - $serverInfo['freeSpace']) / $serverInfo['diskTotal'] * 100, 2) : 0,
            ],
            'MEM' => [
                'NUM' => $serverInfo["UsedMemory"] . ' / ' . $serverInfo['TotalMemory'],
                'PERCENTAGE' => $serverInfo["memPercent"],
            ],
            'REAL_MEM' => [
                'NUM' => $serverInfo["memRealUsed"] . "(Cached {$serverInfo['CachedMemory']})" . ' / ' . $serverInfo['TotalMemory'],
                'PERCENTAGE' => $serverInfo['memRealPercent'] . '%',
            ],
        ];
        $temp = [
            'ARTICLE' => ArticleModel::find()->where(['type' => ArticleModel::ARTICLE])->count('id'),
            'COMMENT' => Comment::find()->count('id'),
            'USER' => User::find()->count('id'),
            'FRIEND_LINK' => FriendlyLink::find()->count('id'),
        ];
        $statics = [
            'ARTICLE' => [
                $temp['ARTICLE'],
                $temp['ARTICLE'] == 0 ? 0 :
                number_format(ArticleModel::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-01')),
                        strtotime(date('Y-m-01 23:59:59') . " +1 month -1 day")
                    ])->count('id') / $temp['ARTICLE'] * 100, 2)
            ],
            'COMMENT' => [
                $temp['COMMENT'],
                $temp['COMMENT'] == 0 ? 0 :
                number_format(Comment::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-d 00:00:00')),
                        time()
                    ])->count('id') / $temp['COMMENT'] * 100, 2)
            ],
            'USER' => [
                $temp['USER'],
                $temp['USER'] == 0 ? 0 :
                number_format(User::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-01')),
                        strtotime(date('Y-m-01 23:59:59') . " +1 month -1 day")
                    ])->count('id') / $temp['USER'] * 100, 2)
            ],
            'FRIEND_LINK' => [
                $temp['FRIEND_LINK'],
                $temp['FRIEND_LINK'] == 0 ? 0 :
                number_format(FriendlyLink::find()->where([
                        'between',
                        'created_at',
                        strtotime(date('Y-m-01')),
                        strtotime(date('Y-m-01 23:59:59') . " +1 month -1 day")
                    ])->count('id') / $temp['FRIEND_LINK'] * 100, 2)
            ],
        ];
        $comments = BackendComment::getRecentComments(6);
        return $this->render('main', [
            'info' => $info,
            'status' => $status,
            'statics' => $statics,
            'comments' => $comments,
        ]);
    }
1326214
public function generateModules()
	{
		$modules = $this->getModulesFromDir();
		$modulePath = Yii::getPathOfAlias('application.modules');
		$moduleComponent = array('assets','components','controllers','models','views');

		if(count($modules) > 0) {
			foreach($modules as $module) {
				$moduleClass = ucfirst($module).'Module';
				$module_path = $modulePath.'/'.$module;
				$module_class = $module_path.'/'.$moduleClass.'.php';

				if(!file_exists($module_class)) {
					$this->generateModuleDirectory($module_path);
	
					foreach($moduleComponent as $component) {
						$module_component_path = $module_path.'/'.$component;
						$this->generateModuleDirectory($module_component_path);
					}

					$config = "<?php\n";
					$config .= "/**\n";
					$config .= " * $moduleClass\n";
					$config .= " *\n";
					$config .= " * @author Putra Sudaryanto <putra@sudaryanto.id>\n";
					$config .= " * @contact (+62)856-299-4114\n";
					$config .= " * @copyright Copyright (c) ".date('Y')." Ommu Platform (www.ommu.co)\n";
					$config .= " * @created date ".date('j F Y, H:i')." WIB\n";
					$config .= " *\n";
					$config .= " *----------------------------------------------------------------------------------------------------------\n */\n\n";
					$config .= "Yii::import('application.vendor.ommu.$module.$moduleClass');";

					if(!file_exists($module_class)) {
						$fileHandle = @fopen($module_class, 'w');
						@fwrite($fileHandle, $config, strlen($config));
						@fclose($fileHandle);
					}
				}
			}
		}
	}
867531
public function actionCreate()
    {
        $model = new Dump($this->getModule()->dbList);
        if (ArrayHelper::isIn($this->db, $this->getModule()->dbList)) {
            $dbInfo = $this->getModule()->getDbInfo($this->db);
            $dumpOptions = $model->makeDumpOptions();
            if ($this->gzip) {
                $dumpOptions['isArchive'] = true;
            }
            $manager = $this->getModule()->createManager($dbInfo);
            $dumpPath = $manager->makePath($this->getModule()->path, $dbInfo, $dumpOptions);
            $dumpCommand = $manager->makeDumpCommand($dumpPath, $dbInfo, $dumpOptions);
            Yii::trace(compact('dumpCommand', 'dumpPath', 'dumpOptions'), get_called_class());
            $process = new Process($dumpCommand);
            $process->run();
            if ($process->isSuccessful()) {
                if ($this->storage) {
                    if (Yii::$app->has('backupStorage')) {
                        $dumpText = fopen($dumpPath, 'r+');
                        Yii::$app->backupStorage->writeStream(StringHelper::basename($dumpPath), $dumpText);
                        fclose($dumpText);
                    } else {
                        Console::output('Storage component is not configured.');
                    }
                }
                Console::output('Dump successfully created.');
            } else {
                Console::output('Dump failed create.');
            }
        } else {
            Console::output('Database configuration not found.');
        }
    }
1101303
public function actionView()
    {
        $view = Yii::$app->getRequest()->get('type');
        if (isset($view)) {
            Yii::$app->session['view'] = $view;
        }
        $this->goBack( Yii::$app->getRequest()->getHeaders()->get('referer') );
    }
71316
public function coreComponents()
    {
        return ArrayHelper::merge(parent::coreComponents(), [
            'db' => [
                'class' => 'yii\db\Connection',
                'dsn' => getenv('DB_DSN'),
                'username' => getenv('DB_USER'),
                'password' => getenv('DB_PASSWORD'),
                'charset' => 'utf8',
                'tablePrefix' => getenv('DB_TABLE_PREFIX'),
                'enableSchemaCache' => YII_ENV_PROD ? true : false,
            ],
            'urlManager' => [
                'enablePrettyUrl' => true,
                'showScriptName' => false,
                'enableStrictParsing' => false,
            ],
            'assetManager' => [
                'linkAssets' => YII_ENV_DEV ? true : false,
            ],
            'request' => [
                //  This is required by cookie validation
                'cookieValidationKey' => getenv('REQUEST_COOKIE_VALIDATION_KEY')?
                                         getenv('REQUEST_COOKIE_VALIDATION_KEY') : 'Xd3456dZRE'
            ],
            'user' => [
                'identityClass' => 'dektrium\user\models\User',
                'enableAutoLogin' => true,
                'authTimeout' => 7200,
                'loginUrl' => ['user/security/login'],
                'returnUrl' => ['/'],
            ],
            'errorHandler' => [
                'errorAction' => 'default/error',
            ],
            'log' => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets' => [
                    [
                        'class' => 'yii\log\FileTarget',
                        'levels' => ['error', 'warning'],
                    ],
                ],
            ],
            'cache' => [
                'class' => 'yii\caching\FileCache',
            ],
            'settings' => [
                'class' => 'pheme\settings\components\Settings'
            ],
            'authManager' => [
                'class' => 'dektrium\rbac\components\DbManager',
                'defaultRoles' => ['registered'],
            ],
        ]);
    }
575809
public function actionUserRole ()
		{
			$userClass = $this->module->modelUser;
			$post = Yii::$app->request->post();
			$user = $userClass::findOne($post[ 'id' ]);
			if (!is_null($user))
			{

				LogManager::info(Yii::tr('Пользователю {user} забрали права {roles}', [ 'user' => Html::a($user->name, Url::toRoute([ 'user/view', 'id' => $user->id ])), 'roles' => implode(',', $user->getRolesNames()) ]));
				$user->revokeAllRoles();
				if (is_array($post[ 'roles' ]))
				{
					foreach ($post[ 'roles' ] as $item)
					{
						$user->assignRole($item);
					}
					LogManager::info(Yii::tr('Пользователю {user} добавили права {roles}', [ 'user' => Html::a($user->name, Url::toRoute([ 'user/view', 'id' => $user->id ])), 'roles' => implode(',', $post[ 'roles' ]) ]));
				}
			}
			Yii::$app->end();
		}
704271
public function coreComponents()
    {
        return ArrayHelper::merge(parent::coreComponents(), [
            'db' => [
                'class' => 'yii\db\Connection',
                'dsn' => getenv('DB_DSN'),
                'username' => getenv('DB_USER'),
                'password' => getenv('DB_PASSWORD'),
                'charset' => 'utf8',
                'tablePrefix' => getenv('DB_TABLE_PREFIX'),
                'enableSchemaCache' => YII_ENV_PROD ? true : false,
            ],
        ]);
    }