Setup Drupal settings local include.

@return $this
349056
protected function setupDrupalSettingsLocalInclude()
    {
        $this->taskWriteToFile($this->settingFile)
            ->append()
            ->appendUnlessMatches(
                '/if.+\/settings\.local\.php.+{\n.+\n\}/',
                $this->drupalSettingsLocalInclude()
            )
            ->run();

        return $this;
    }
1219691
function setup() {
        global $SESSION;

        if (empty($this->columns) || empty($this->uniqueid)) {
            return false;
        }

        // Load any existing user preferences.
        if ($this->persistent) {
            $this->prefs = json_decode(get_user_preferences('flextable_' . $this->uniqueid), true);
            $oldprefs = $this->prefs;
        } else if (isset($SESSION->flextable[$this->uniqueid])) {
            $this->prefs = $SESSION->flextable[$this->uniqueid];
            $oldprefs = $this->prefs;
        }

        // Set up default preferences if needed.
        if (!$this->prefs or optional_param($this->request[TABLE_VAR_RESET], false, PARAM_BOOL)) {
            $this->prefs = array(
                'collapse' => array(),
                'sortby'   => array(),
                'i_first'  => '',
                'i_last'   => '',
                'textsort' => $this->column_textsort,
            );
        }

        if (!isset($oldprefs)) {
            $oldprefs = $this->prefs;
        }

        if (($showcol = optional_param($this->request[TABLE_VAR_SHOW], '', PARAM_ALPHANUMEXT)) &&
                isset($this->columns[$showcol])) {
            $this->prefs['collapse'][$showcol] = false;

        } else if (($hidecol = optional_param($this->request[TABLE_VAR_HIDE], '', PARAM_ALPHANUMEXT)) &&
                isset($this->columns[$hidecol])) {
            $this->prefs['collapse'][$hidecol] = true;
            if (array_key_exists($hidecol, $this->prefs['sortby'])) {
                unset($this->prefs['sortby'][$hidecol]);
            }
        }

        // Now, update the column attributes for collapsed columns
        foreach (array_keys($this->columns) as $column) {
            if (!empty($this->prefs['collapse'][$column])) {
                $this->column_style[$column]['width'] = '10px';
            }
        }

        if (($sortcol = optional_param($this->request[TABLE_VAR_SORT], '', PARAM_ALPHANUMEXT)) &&
                $this->is_sortable($sortcol) && empty($this->prefs['collapse'][$sortcol]) &&
                (isset($this->columns[$sortcol]) || in_array($sortcol, get_all_user_name_fields())
                && isset($this->columns['fullname']))) {

            if (array_key_exists($sortcol, $this->prefs['sortby'])) {
                // This key already exists somewhere. Change its sortorder and bring it to the top.
                $sortorder = $this->prefs['sortby'][$sortcol] == SORT_ASC ? SORT_DESC : SORT_ASC;
                unset($this->prefs['sortby'][$sortcol]);
                $this->prefs['sortby'] = array_merge(array($sortcol => $sortorder), $this->prefs['sortby']);
            } else {
                // Key doesn't exist, so just add it to the beginning of the array, ascending order
                $this->prefs['sortby'] = array_merge(array($sortcol => SORT_ASC), $this->prefs['sortby']);
            }

            // Finally, make sure that no more than $this->maxsortkeys are present into the array
            $this->prefs['sortby'] = array_slice($this->prefs['sortby'], 0, $this->maxsortkeys);
        }

        // MDL-35375 - If a default order is defined and it is not in the current list of order by columns, add it at the end.
        // This prevents results from being returned in a random order if the only order by column contains equal values.
        if (!empty($this->sort_default_column))  {
            if (!array_key_exists($this->sort_default_column, $this->prefs['sortby'])) {
                $defaultsort = array($this->sort_default_column => $this->sort_default_order);
                $this->prefs['sortby'] = array_merge($this->prefs['sortby'], $defaultsort);
            }
        }

        $ilast = optional_param($this->request[TABLE_VAR_ILAST], null, PARAM_RAW);
        if (!is_null($ilast) && ($ilast ==='' || strpos(get_string('alphabet', 'langconfig'), $ilast) !== false)) {
            $this->prefs['i_last'] = $ilast;
        }

        $ifirst = optional_param($this->request[TABLE_VAR_IFIRST], null, PARAM_RAW);
        if (!is_null($ifirst) && ($ifirst === '' || strpos(get_string('alphabet', 'langconfig'), $ifirst) !== false)) {
            $this->prefs['i_first'] = $ifirst;
        }

        // Save user preferences if they have changed.
        if ($this->prefs != $oldprefs) {
            if ($this->persistent) {
                set_user_preference('flextable_' . $this->uniqueid, json_encode($this->prefs));
            } else {
                $SESSION->flextable[$this->uniqueid] = $this->prefs;
            }
        }
        unset($oldprefs);

        if (empty($this->baseurl)) {
            debugging('You should set baseurl when using flexible_table.');
            global $PAGE;
            $this->baseurl = $PAGE->url;
        }

        $this->currpage = optional_param($this->request[TABLE_VAR_PAGE], 0, PARAM_INT);
        $this->setup = true;

        // Always introduce the "flexible" class for the table if not specified
        if (empty($this->attributes)) {
            $this->attributes['class'] = 'flexible';
        } else if (!isset($this->attributes['class'])) {
            $this->attributes['class'] = 'flexible';
        } else if (!in_array('flexible', explode(' ', $this->attributes['class']))) {
            $this->attributes['class'] = trim('flexible ' . $this->attributes['class']);
        }
    }
1275303
private function includeAll()
    {
        $config = $this->readConfig();
        $files = array_merge(
            (array) $this->goals['include'],
            (array) $config['components']['include']
        );
        $this->includeGoals($files);
    }
401256
public function setupFilesystem()
    {
        $config = $this['config'];

        if (!is_dir($config->get('concrete.cache.directory'))) {
            @mkdir($config->get('concrete.cache.directory'), $config->get('concrete.filesystem.permissions.directory'));
            @touch($config->get('concrete.cache.directory') . '/index.html', $config->get('concrete.filesystem.permissions.file'));
        }
    }
388765
final public function setup()
    {
        if (!$this->setup) {
            // configure our datagrid
            $resolver = new OptionsResolver();
            $this->configureOptions($resolver);
            $this->options = $resolver->resolve($this->getOptions());

            $this->setup = true;
        }
    }
1130522
public function loadSettings()
    {
        $extra = $this->composer->getPackage()->getExtra();
        $config = array_merge(
            array(
                'include' => array(),
                'require' => array(),
                'recurse' => true,
                'replace' => false,
                'ignore-duplicates' => false,
                'merge-dev' => true,
                'merge-extra' => false,
                'merge-extra-deep' => false,
                'merge-scripts' => false,
            ),
            isset($extra['merge-plugin']) ? $extra['merge-plugin'] : array()
        );

        $this->includes = (is_array($config['include'])) ?
            $config['include'] : array($config['include']);
        $this->requires = (is_array($config['require'])) ?
            $config['require'] : array($config['require']);
        $this->recurse = (bool)$config['recurse'];
        $this->replace = (bool)$config['replace'];
        $this->ignore = (bool)$config['ignore-duplicates'];
        $this->mergeDev = (bool)$config['merge-dev'];
        $this->mergeExtra = (bool)$config['merge-extra'];
        $this->mergeExtraDeep = (bool)$config['merge-extra-deep'];
        $this->mergeScripts = (bool)$config['merge-scripts'];
    }
826148
public function setup()
	{
		$this->addRule('title', function($data)
		{
			if (!isset($data['title']) || $data['title'] == '')
			{
				return 'Title is required.';
			}

			$exist = self::all()
				->whereEquals('title', $data['title'])
				->whereEquals('parent_id', $data['parent_id'])
				->where('id', '<>', $data['id'])
				->count();

			return $exist ? 'Access group title already exists.' : false;
		});
	}
849751
public function prepareLocal() {
    $do_composer_install = TRUE;
    $project_properties = $this->getProjectProperties();
    $grab_database = $this->confirm("Load a database backup?");
    if ($grab_database == 'y') {
      $do_composer_install = $this->getDatabaseOfTruth();
    }
    if ($do_composer_install) {
      $this->taskComposerInstall()
        ->optimizeAutoloader()
        ->run();
      $drush_commands = [
        'drush_clear_cache' => 'drush cr',
        'drush_update_database' => 'drush updb',
        'drush_grab_config_changes' => 'drush config-import -y',
        'drush_grab_config_local_changes' => 'drush config-split:import local -y',
      ];
      $this->taskExec(implode(' && ', $drush_commands))
        ->dir($project_properties['web_root'])
        ->run();
    }
  }
736427
function init() {
		$this->setTemplateDir(Yii::getAlias($this->themePath.$this->themeName.'/templates'))
			 ->addPluginsDir(Yii::getAlias($this->commonPluginsPath))
			 ->addPluginsDir(Yii::getAlias($this->themePath.$this->themeName.'/plugins'))
			 ->setConfigDir(Yii::getAlias($this->themePath.$this->themeName.'/configs'))
			 ->setCompileDir(Yii::getAlias($this->compilePath))
			 ->setCacheDir(Yii::getAlias($this->cachePath));
		foreach ($this->options as $key => $value) {
			$this->$key = $value;
		}
	}
874023
public function setup(){
		if($this->hasOption('autoinit') && $this->options()->autoinit){
			if($this->hasOption('default')){
				$this->setValue($this->options()->default);
			}else{
				$this->setValue('now');
			}
		}
	}
224036
public function install()
    {
        $this->ensureNotInstalledBefore();

        if ($this->locator) {
            $this->path = $this->locator->locate($this->slug);
        }

        $this->validate();

        $this->make();

        $this->register();

        $this->migrate();

        $this->installSubAddons();

        AddonInstalledEvent::dispatch($this->addon);

        return $this;
    }
74727
public function admin_init() {
		add_settings_section(
			'soter_general',
			'General Settings',
			[ $this, 'render_section_general' ],
			'soter'
		);

		add_settings_section(
			'soter_email',
			'Email Settings',
			[ $this, 'render_section_email' ],
			'soter'
		);

		add_settings_section(
			'soter_slack',
			'Slack Settings',
			[ $this, 'render_section_slack' ],
			'soter'
		);

		add_settings_field(
			'soter_should_nag',
			'Notification Frequency',
			[ $this, 'render_should_nag' ],
			'soter',
			'soter_general'
		);

		add_settings_field(
			'soter_ignored_plugins',
			'Ignored Plugins',
			[ $this, 'render_ignored_plugins' ],
			'soter',
			'soter_general'
		);

		add_settings_field(
			'soter_ignored_themes',
			'Ignored Themes',
			[ $this, 'render_ignored_themes' ],
			'soter',
			'soter_general'
		);

		add_settings_field(
			'soter_email_enabled',
			'Send Email Notifications',
			[ $this, 'render_email_enabled' ],
			'soter',
			'soter_email'
		);

		add_settings_field(
			'soter_email_address',
			'Email Address',
			[ $this, 'render_email_address' ],
			'soter',
			'soter_email'
		);

		add_settings_field(
			'soter_email_type',
			'Email Type',
			[ $this, 'render_email_type' ],
			'soter',
			'soter_email'
		);

		add_settings_field(
			'soter_slack_enabled',
			'Send Slack Notifications',
			[ $this, 'render_slack_enabled' ],
			'soter',
			'soter_slack'
		);

		add_settings_field(
			'soter_slack_url',
			'WebHook URL',
			[ $this, 'render_slack_url' ],
			'soter',
			'soter_slack'
		);
	}
618970
public static function setup_theme() {

		global $pagenow;

		if ( ( is_admin() && 'themes.php' == $pagenow ) || ! self::can_switch_themes() ) {
			return;
		}

		self::check_reset();
		self::load_cookie();

		if ( empty( self::$theme ) ) {
			return;
		}

		add_filter( 'pre_option_template', array( self::$theme, 'get_template' ) );
		add_filter( 'pre_option_stylesheet', array( self::$theme, 'get_stylesheet' ) );
		add_filter( 'pre_option_stylesheet_root', array( self::$theme, 'get_theme_root' ) );
		$parent = self::$theme->parent();
		add_filter( 'pre_option_template_root', array( empty( $parent ) ? self::$theme : $parent, 'get_theme_root' ) );
		add_filter( 'pre_option_current_theme', '__return_false' );
	}
67551
public function setup()
    {
        if ($this->enabled())
        {
            $this->hookupUI();

            add_action('admin_enqueue_scripts', [$this,'enqueueTheGoods']);
            add_action('wp_ajax_ilab_crop_image_page',[$this,'displayCropUI']);
            add_action('wp_ajax_ilab_perform_crop',[$this,'performCrop']);

            add_filter('ilab_s3_process_crop', function($size, $path, $sizeMeta){
                return $sizeMeta;
            }, 3, 3);
            add_filter('ilab_s3_process_file_name', function($filename) {
                return $filename;
            }, 3, 1);
        }
    }
636705
public function setDefaultsFromConfiguration()
    {
        $set = [
            "urlType",
            "siteUrl",
            "baseUrl",
            "staticSiteUrl",
            "staticBaseUrl",
            "scriptName",
        ];
        
        foreach ($set as $item) {
            if (!isset($this->config[$item])) {
                continue;
            }
            
            $this->$item = $this->config[$item];
        }

        return $this;
    }
190867
protected function doSetupDevelopmentSettings() {
    $source = __DIR__ . '/../dist/development.services.yml';
    $destination = $this->getSitesDirectory() . '/development.services.yml';
    $this->write('Make sure that Twig cache is disabled in <comment>%s</comment>', $this->shortenDirectory($destination));
    copy($source, $destination);

    $destination = $this->getDefaultDirectory() . '/default.settings.php';
    $content = file_get_contents($destination);
    $ignore_directory_setting = sprintf('$settings[\'file_scan_ignore_directories\'][] = \'%s\';', $this->getBuildRoot());
    if (strstr($content, $ignore_directory_setting) === FALSE) {
      file_put_contents($destination, $ignore_directory_setting . PHP_EOL, FILE_APPEND);
    }
    $this->write('Add build directory to list of ignored paths in <comment>%s</comment>.', $this->shortenDirectory($destination));

    $destination = $this->getDefaultDirectory() . '/settings.local.php';
    $source = $this->getSitesDirectory() . '/example.settings.local.php';
    $content = file_get_contents($source);
    $content = str_replace('# $settings[\'cache\'][\'bins\']', '$settings[\'cache\'][\'bins\']', $content);
    file_put_contents($destination, $content);
    $this->write('Setup local development settings at <comment>%s</comment>.', $this->shortenDirectory($destination));
    $this->write('Note: local development settings file is disabled by default, enable it by un-commenting related lines in your settings.php file.');
  }
715880
public function populateHelperConfig() {
    $this->set('drush.alias', $this->get('drush.default_alias'));

    if (!$this->get('multisites')) {
      $this->set('multisites', $this->getSiteDirs());
    }

    $multisites = $this->get('multisites');
    $first_multisite = reset($multisites);
    $site = $this->get('site', $first_multisite);
    $this->setSite($site);
  }