/** * Class constructor. * * @param string $cid * The cache ID. * @param array $input * The input parameter accepts an array. * @param int $flags * Flags to control the behaviour of the ArrayObject object. * @param string $iterator_class * Specify the class that will be used for iteration of the ArrayObject * object. ArrayIterator is the default class used. */ public function __construct($cid, array $input = NULL, $flags = 0, $iterator_class = "ArrayIterator") { $this->cid($cid); if (isset($input)) { $this->set($input); $this->exists = TRUE; } elseif (($cache = drush_cache_get($this->cid(), 'lwg')) && isset($cache->data)) { $this->exchangeArray($cache->data); $this->exists = TRUE; } }
function commandfile_searchpaths($phase, $phase_max = FALSE) { if (!$phase_max) { $phase_max = $phase; } $searchpath = array(); switch ($phase) { case BackdropBoot::BOOTSTRAP_ROOT: $backdrop_root = drush_get_context('DRUSH_SELECTED_BACKDROP_ROOT'); $searchpath[] = $backdrop_root . '/../drush'; $searchpath[] = $backdrop_root . '/drush'; $searchpath[] = $backdrop_root . '/sites/all/drush'; // Add the drupalboot.drush.inc commandfile. // $searchpath[] = __DIR__; break; case BackdropBoot::BOOTSTRAP_SITE: // If we are going to stop bootstrapping at the site, then // we will quickly add all commandfiles that we can find for // any extension associated with the site, whether it is enabled // or not. If we are, however, going to continue on to bootstrap // all the way to DRUSH_BOOTSTRAP_DRUPAL_FULL, then we will // instead wait for that phase, which will more carefully add // only those Drush commandfiles that are associated with // enabled modules. if ($phase_max < BackdropBoot::BOOTSTRAP_FULL) { $searchpath = array_merge($searchpath, $this->contrib_modules_paths()); // Adding commandfiles located within /profiles. Try to limit to one // profile for speed. Note that Backdrop allows enabling modules from // a non-active profile so this logic is kinda dodgy. $cid = $this->install_profile_cid(); if ($cached = drush_cache_get($cid)) { $profile = $cached->data; $searchpath[] = "profiles/{$profile}/modules"; $searchpath[] = "profiles/{$profile}/themes"; } else { // If install_profile is not available, scan all profiles. $searchpath[] = "profiles"; $searchpath[] = "sites/all/profiles"; } $searchpath = array_merge($searchpath, $this->contrib_themes_paths()); } break; case BackdropBoot::BOOTSTRAP_CONFIGURATION: // Nothing to do here anymore. Left for documentation. break; case BackdropBoot::BOOTSTRAP_FULL: // Add enabled module paths, excluding the install profile. Since we are // bootstrapped we can use the Backdrop API. $ignored_modules = drush_get_option_list('ignored-modules', array()); $cid = $this->install_profile_cid(); if ($cached = drush_cache_get($cid)) { $ignored_modules[] = $cached->data; } foreach (array_diff($this->module_list(), $ignored_modules) as $module) { $filepath = backdrop_get_path('module', $module); if ($filepath && $filepath != '/') { $searchpath[] = $filepath; } } $searchpath[] = backdrop_get_path('theme', config_get('system.core', 'theme_default')); $searchpath[] = backdrop_get_path('theme', config_get('system.core', 'theme_admin')); break; } return $searchpath; }
/** * Attempt to load the full Drupal system. */ function bootstrap_drupal_full() { drush_include_engine('drupal', 'environment'); $this->add_logger(); // Write correct install_profile to cache as needed. Used by _drush_find_commandfiles(). $cid = drush_cid_install_profile(); $install_profile = $this->get_profile(); if ($cached_install_profile = drush_cache_get($cid)) { // We have a cached profile. Check it for correctness and save new value if needed. if ($cached_install_profile->data != $install_profile) { drush_cache_set($cid, $install_profile); } } else { // No cached entry so write to cache. drush_cache_set($cid, $install_profile); } _drush_log_drupal_messages(); }
/** * Determine whether a user is logged-in to a Provider. * * @return bool * TRUE if they are. */ public function authIsLoggedIn() { $session = drush_cache_get('session', $this->drushCacheBinAuthName()); return isset($session->data) ? TRUE : FALSE; }
/** * Wrapper for alias file that builds out aliases * @param array $aliases aliases from drush sa command */ function _elmsln_alises_build(&$aliases) { // static cache assembled aliases as this can get tripped often static $pulledaliases = array(); // check for pervasive cache if static is empty if (empty($pulledaliases)) { $cache = drush_cache_get(drush_get_cid('elmsln_remote_aliases')); $pulledaliases = $cache->data; if (empty($pulledaliases)) { // read off the .elmsln/elmsln-hosts manifest $pulledaliases = array(); $home = getenv("HOME"); // if somehow that isn't set.. if (empty($home)) { $usr = posix_getpwuid(posix_getuid()); $home = $user['dir']; } $file = "{$home}/.elmsln/elmsln-hosts"; $hosts = file_get_contents($file); $lines = explode("\n", $hosts); // read each line of the config file foreach ($lines as $key => $line) { // make sure this line isn't a comment and has a= if (strpos($line, 'ssh') === 0) { $server = array(); $line = str_replace('ssh ', '', $line); $tmp = explode(' ', $line); foreach ($tmp as $item) { if (strpos($item, '@')) { $tmp2 = explode('@', $item); if (count($tmp2) == 2) { $server['remote-user'] = $tmp2[0]; $server['remote-host'] = $tmp2[1]; } } else { $server['ssh-options'] .= $item . ' '; } } // ensure we have 2 settings before doing this if (count($server) == 3) { // try for a nice name if ($key > 0 && strpos($lines[$key - 1], '#') === 0) { $aliaskey = _elmsln_alias_server_name($lines[$key - 1]); } else { $aliaskey = _elmsln_alias_server_name($server['remote-host']); } $pulledaliases[$aliaskey] = _elmsln_alias_build_aliases($aliaskey, $server); } } } // write this back to the cache drush_cache_set(drush_get_cid('elmsln_remote_aliases'), $pulledaliases); } } //print_r($pulledaliases); // @todo add support for bundled stacks across deployments // for example: elmsln-courses-all which trips all the courses-all // stacks found across known hosts. This could allow for applying // something JUST to all courses that we are managing // add support for bundled and nested targets $aliases['elmsln-all'] = array('site-list' => array()); // now convert these to aliases style foreach ($pulledaliases as $system => $onsystem) { $aliases[$system] = array('site-list' => array()); array_push($aliases['elmsln-all']['site-list'], '@' . $system); foreach ($onsystem as $alias => $settings) { $alias = str_replace('elmsln.', '', $alias); if ($alias == 'elmsln') { continue; } // don't double push -all targets to larger -all target buckets if (!strpos($alias, '-all') && $alias != 'none') { array_push($aliases[$system]['site-list'], '@' . $system . '.' . $alias); } // deep load and repair parents to point into the system if (isset($settings['parent'])) { $settings['parent'] = str_replace('@', '@' . $system . '.', $settings['parent']); $settings['parent'] = str_replace('.elmsln', '', $settings['parent']); } // same but for site listings if (isset($settings['site-list'])) { foreach ($settings['site-list'] as $sitekey => $site) { $settings['site-list'][$sitekey] = str_replace('@', '@' . $system . '.', $site); $settings['site-list'][$sitekey] = str_replace('.elmsln', '', $settings['site-list'][$sitekey]); } } $aliases[$system . '.' . $alias] = $settings; } } }
/** * Determine whether a user is logged-in to a Provider. * * @return bool * TRUE if they are. */ public function authIsLoggedIn() { $email = drush_cache_get('email', $this->drushCacheBinAuthName()); $password = drush_cache_get('password', $this->drushCacheBinAuthName()); return isset($email->data) && isset($password->data) ? TRUE : FALSE; }