Checks we're in console mode

@param array $config
@return bool
512553
public static function start(&$config)
    {
        $config = array_merge(array(
        
            // directory where scripts are stored
            'scripts_dir'    => 'app/scripts'
            
        ), $config);
        self::$config = &$config;

        self::$console = new ConsoleKit\Console();
        self::$console->addCommand('Atomik\Console::generate');
        
        // checks if we are in the CLI
        if (PHP_SAPI !== 'cli') {
            return false;
        }
    }
734991
protected function parseConfig(array $config)
    {
        $config = $this->setHost($config);
        $config = $this->setPort($config);
        $config = $this->setProtocol($config);
        $config = $this->setServiceId($config);
        $config = $this->setTNS($config);
        $config = $this->setCharset($config);

        return $config;
    }
180635
protected function isParsedConfigValid(array $config, array $required)
    {
        $inConfig = count(array_intersect_key(array_flip($required), array_filter($config)));

        return $inConfig === count($required);
    }
504905
public function beginActiveForm(array $config = [])
    {
        $className = $this->activeFormClassName;
        $this->_activeForm = $className::begin($config);
        return $this->_activeForm;
    }
920398
public static function isEnabled($config)
    {
        $value = self::getConfigValue('cache.enabled', $config);
        return empty($value) ? false : ((trim($value) == true || trim($value) == 'true') ? true : false);
    }
469162
final public static function setConfigDefault(array $config = [])
    {
        $calledClass = get_called_class();

        if (!isset(self::$loadedConfigSet[$calledClass])) {
            static::$config = $config;
        } else {
            self::$loadedConfigSet[$calledClass] = array_merge(self::$configDefault, $config);
        }

        return true;
    }
229096
public function setConfig(array $config = [])
    {
        // 设置App Key
        $this->appKey = isset($config['appKey']) ? $config['appKey'] : '';

        // 设置App Secret
        $this->appSecret = isset($config['appSecret']) ? $config['appSecret'] : '';

        // 沙箱环境
        $this->sandbox = isset($config['sandbox']) ? (bool)$config['sandbox'] : false;

        // 使用HTTPS
        $this->secure = isset($config['secure']) ? (bool)$config['secure'] : false;

        return $this;
    }
635389
protected function checkMigrationsPath(array $config)
    {
        // Check if $config['migration_path'] is already defined
        $migrationPath = isset($config['migration_path']) ? $config['migration_path'] : false;

        $migrationPath = str_replace('FCPATH', '', $migrationPath);
        // Check if $config['migration_path'] directory is not available yet, create new one
        if ($migrationPath !== false && !is_dir($migrationPath)) {
            mkdir($migrationPath, 0755, true);
        }

        return $migrationPath;
    }
679339
public function check(array $config): bool
    {
        $this->missingLocales = new Collection(Arr::get($config, 'required_locales', []));
        if ($this->missingLocales->isEmpty()) {
            return true;
        }

        if (!$this->systemFunctions->isFunctionAvailable('shell_exec')) {
            $this->message = trans('self-diagnosis::checks.locales_are_installed.message.shell_exec_not_available');
            return false;
        }

        if ($this->systemFunctions->isWindowsOperatingSystem()) {
            $this->message = trans('self-diagnosis::checks.locales_are_installed.message.cannot_run_on_windows');
            return false;
        }

        $locales = $this->systemFunctions->callShellExec('locale -a');
        if ($locales === null || $locales === '') {
            $this->message = trans('self-diagnosis::checks.locales_are_installed.message.locale_command_not_available');
            return false;
        }

        $locales = explode("\n" , $locales);

        $this->missingLocales = $this->missingLocales->reject(function ($loc) use ($locales) {
            return in_array($loc, $locales);
        });

        return $this->missingLocales->isEmpty();
    }
68207
protected function configure(array $config = [])
    {
        foreach ($config as $key => $value) {
            $method = 'set' . $key;
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
    }
254316
public function check(array $config): bool
    {
        $this->paths = Collection::make(Arr::get($config, 'directories', []));

        $this->paths = $this->paths->reject(function ($path) {
            return $this->filesystem->isWritable($path);
        });

        return $this->paths->isEmpty();
    }
413757
public function setConfig(array $config) {
        if (!$config) {
            return $this;
        }

        foreach ($config as $key => $value) {
            switch ($key) {
                case 'open':
                case 'close':
                    $this->setBrackets($config['open'], $config['close']);
                break;
                case 'locale':
                    $this->setLocale($value);
                break;
                case 'disable':
                case 'disabled':
                    $this->disable($value);
                break;
                case 'shorthand':
                case 'shorthandLinks':
                    $this->setShorthand($value);
                break;
                case 'xhtml':
                case 'xhtmlOutput':
                    $this->setXhtml($value);
                break;
                case 'escape':
                case 'escapeHtml':
                    $this->setEscaping($value);
                break;
                case 'strict':
                case 'strictMode':
                    $this->setStrict($value);
                break;
                case 'newlines':
                case 'maxNewlines':
                    $this->setMaxNewlines($value);
                break;
                case 'standaloneTags':
                    $this->setStandaloneTags($value);
                break;
                case 'lineBreaks':
                    $this->setLineBreaks($value);
                break;
                case 'removeEmpty':
                    $this->setRemoveEmptyTags($value);
                break;
                case 'cacheExpires':
                    $this->setCacheExpiration($value);
                break;

                // Doesn't need a setter as it's only used in the constructor
                case 'configPath':
                    $this->_config['configPath'] = $value;
                break;
            }
        }

        return $this;
    }
863145
public function setup($config = array())
    {
        if (isset($config['SANDBOX'])) {
            if ($config['SANDBOX']) {
                $this->defaultsData['BASE_URL'] = $this->defaultsData['SANDBOX_URL'];
                $this->runMode = 'SANDBOX';
            }
        }
        $this->processConfig($this->defaultsData);
        $this->processConfig($config);

        if ($this->commMethod == 'liveupdate' && isset($config['BACK_REF'])) {
            $this->setField("BACK_REF", $config['BACK_REF']);
        }
        if ($this->commMethod == 'liveupdate' && isset($config['TIMEOUT_URL'])) {
            $this->setField("TIMEOUT_URL", $config['TIMEOUT_URL']);
        }
        return true;
    }
320392
protected function normalizeConfig(array $config)
    {
        $final = [];
        foreach ($config as $key => $value) {
            if (is_array($value)) {
                $final[$key] = $this->normalizeConfig($value);
            } else {
                $final[$value] = [];
            }
        }

        return $final;
    }
139425
protected function assignRole(array $config)
    {
        if (!($name = ArrayHelper::get($config, 'name')) || !($role  = $this->authManager->getRole($name))){
            return false;
        }
        if (!($child = ArrayHelper::get($config, 'child'))) {
            return $role;
        }
        if ($childRoles = ArrayHelper::get($child, 'roles')) {
            foreach ($childRoles as $name) {
                if ($roleChild = $this->authManager->getRole($name)) {
                    try {
                        $this->authManager->addChild($role, $roleChild);
                        $this->stdout("\tAssign child role: {$name} - success\n", Console::FG_GREEN);
                    } catch(\Exception $e) {
                        $this->stdout("\t- already exist\n");
                    }
                }
            }
        }
        if ($childPermissions = ArrayHelper::get($child, 'permissions')) {
            foreach ($childPermissions as $name) {
                if ($permissionChild = $this->authManager->getPermission($name)) {
                    try {
                        $this->authManager->addChild($role, $permissionChild);
                        $this->stdout("\tAssign child permission: {$name} - success\n", Console::FG_GREEN);
                    } catch(\Exception $e) {
                        $this->stdout("\t- already exist\n");
                    }
                }
            }
        }
        return $role;
    }
1323398
public function enabled( $config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'name'      => 'enabled',
            'attribs'   => array(),
            'deselect'  => true,
        ))->append(array(
            'selected'  => $config->{$config->name}
        ));

        $translator = $this->getObject('translator');
        $options    = array();

        $options[] = $this->option(array('label' => $translator->translate( 'Enabled' ) , 'value' => 1 ));
        $options[] = $this->option(array('label' => $translator->translate( 'Disabled' ), 'value' => 0 ));

        //Add the options to the config object
        $config->options = $options;

        return $this->optionlist($config);
    }
476225
public function config(array $config)
    {
        parent::config($config);

        if (array_key_exists('fingerprint', $config)) {
            $this->defaults->setFingerprint($config['fingerprint']);
        }

        if (array_key_exists('path', $config)) {
            $this->defaults->setPath($config['path']);
        }

        if (array_key_exists('local_path', $config)) {
            $this->defaults->setLocalPath($config['local_path']);
        }

        if (array_key_exists('pattern', $config)) {
            $this->defaults->setPattern($config['pattern']);
        }

        if (array_key_exists('files_callback', $config)) {
            $this->defaults->setFilesCallback($config['files_callback']);
        }

        if (array_key_exists('do_cleanup', $config)) {
            $this->defaults->setDoCleanup($config['do_cleanup']);
        }

        return $this;
    }