コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $resource_id = $input->getArgument('resource-id');
     $rest_resources = $this->getRestResources();
     $rest_resources_ids = array_merge(array_keys($rest_resources['enabled']), array_keys($rest_resources['disabled']));
     if (!$resource_id) {
         $resource_id = $io->choiceNoList($this->trans('commands.rest.enable.arguments.resource-id'), $rest_resources_ids);
     }
     $this->validateRestResource($resource_id, $rest_resources_ids, $this->getTranslator());
     $input->setArgument('resource-id', $resource_id);
     // Calculate states available by resource and generate the question
     $plugin = $this->pluginManagerRest->getInstance(['id' => $resource_id]);
     $states = $plugin->availableMethods();
     $state = $io->choice($this->trans('commands.rest.enable.arguments.states'), $states);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-state') . ' ' . $state);
     // Get Authentication Provider and generate the question
     $authenticationProviders = $this->authenticationCollector->getSortedProviders();
     $authenticationProvidersSelected = $io->choice($this->trans('commands.rest.enable.messages.authentication-providers'), array_keys($authenticationProviders), 0, true);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-authentication-providers') . ' ' . implode(', ', $authenticationProvidersSelected));
     $rest_settings = $this->getRestDrupalConfig();
     $rest_settings[$resource_id][$state]['supported_formats'] = $formats;
     $rest_settings[$resource_id][$state]['supported_auth'] = $authenticationProvidersSelected;
     $config = $this->configFactory->getEditable('rest.settings');
     $config->set('resources', $rest_settings);
     $config->save();
     return 0;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $composer = $input->getOption('composer');
     $module = $input->getArgument('module');
     $this->site->loadLegacyFile('/core/modules/system/system.module');
     $coreExtension = $this->configFactory->getEditable('core.extension');
     // Get info about modules available
     $moduleData = system_rebuild_module_data();
     $moduleList = array_combine($module, $module);
     if ($composer) {
         //@TODO: check with Composer if the module is previously required in composer.json!
         foreach ($module as $moduleItem) {
             $command = sprintf('composer remove drupal/%s ', $moduleItem);
             $shellProcess = $this->get('shell_process');
             if ($shellProcess->exec($command)) {
                 $io->success(sprintf($this->trans('commands.module.uninstall.messages.composer-success'), $moduleItem));
             }
         }
     }
     if ($missingModules = array_diff_key($moduleList, $moduleData)) {
         $io->error(sprintf($this->trans('commands.module.uninstall.messages.missing'), implode(', ', $module), implode(', ', $missingModules)));
         return 1;
     }
     $installedModules = $coreExtension->get('module') ?: array();
     if (!($moduleList = array_intersect_key($moduleList, $installedModules))) {
         $io->info($this->trans('commands.module.uninstall.messages.nothing'));
         return 0;
     }
     if (!($force = $input->getOption('force'))) {
         $dependencies = [];
         while (list($module) = each($moduleList)) {
             foreach (array_keys($moduleData[$module]->required_by) as $dependency) {
                 if (isset($installedModules[$dependency]) && !isset($moduleList[$dependency]) && $dependency != $profile) {
                     $dependencies[] = $dependency;
                 }
             }
         }
         if (!empty($dependencies)) {
             $io->error(sprintf($this->trans('commands.module.uninstall.messages.dependents'), implode('", "', $moduleList), implode(', ', $dependencies)));
             return 1;
         }
     }
     try {
         $this->moduleInstaller->uninstall($moduleList);
         $io->info(sprintf($this->trans('commands.module.uninstall.messages.success'), implode(', ', $moduleList)));
         $io->comment(sprintf($this->trans('commands.module.uninstall.messages.composer-success'), implode(', ', $moduleList), false));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $configName = $input->getArgument('name');
     $key = $input->getArgument('key');
     $value = $input->getArgument('value');
     $config = $this->configFactory->getEditable($configName);
     $configurationOverrideResult = $this->overrideConfiguration($config, $key, $value);
     $config->save();
     $io->info($this->trans('commands.config.override.messages.configuration'), false);
     $io->comment($configName);
     $tableHeader = [$this->trans('commands.config.override.messages.configuration-key'), $this->trans('commands.config.override.messages.original'), $this->trans('commands.config.override.messages.updated')];
     $tableRows = $configurationOverrideResult;
     $io->table($tableHeader, $tableRows);
     $config->save();
 }
コード例 #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $config = $this->configFactory->getEditable('system.theme');
     $this->themeHandler->refreshInfo();
     $theme = $input->getArgument('theme');
     $default = $input->getOption('set-default');
     if ($default && count($theme) > 1) {
         $io->error($this->trans('commands.theme.install.messages.invalid-theme-default'));
         return;
     }
     $themes = $this->themeHandler->rebuildThemeData();
     $themesAvailable = [];
     $themesInstalled = [];
     $themesUnavailable = [];
     foreach ($theme as $themeName) {
         if (isset($themes[$themeName]) && $themes[$themeName]->status == 0) {
             $themesAvailable[] = $themes[$themeName]->info['name'];
         } elseif (isset($themes[$themeName]) && $themes[$themeName]->status == 1) {
             $themesInstalled[] = $themes[$themeName]->info['name'];
         } else {
             $themesUnavailable[] = $themeName;
         }
     }
     if (count($themesAvailable) > 0) {
         try {
             if ($this->themeHandler->install($theme)) {
                 if (count($themesAvailable) > 1) {
                     $io->info(sprintf($this->trans('commands.theme.install.messages.themes-success'), implode(',', $themesAvailable)));
                 } else {
                     if ($default) {
                         // Set the default theme.
                         $config->set('default', $theme[0])->save();
                         $io->info(sprintf($this->trans('commands.theme.install.messages.theme-default-success'), $themesAvailable[0]));
                     } else {
                         $io->info(sprintf($this->trans('commands.theme.install.messages.theme-success'), $themesAvailable[0]));
                     }
                 }
             }
         } catch (UnmetDependenciesException $e) {
             $io->error(sprintf($this->trans('commands.theme.install.messages.success'), $theme));
             drupal_set_message($e->getTranslatedMessage($this->getStringTranslation(), $theme), 'error');
         }
     } elseif (empty($themesAvailable) && count($themesInstalled) > 0) {
         if (count($themesInstalled) > 1) {
             $io->info(sprintf($this->trans('commands.theme.install.messages.themes-nothing'), implode(',', $themesInstalled)));
         } else {
             $io->info(sprintf($this->trans('commands.theme.install.messages.theme-nothing'), implode(',', $themesInstalled)));
         }
     } else {
         if (count($themesUnavailable) > 1) {
             $io->error(sprintf($this->trans('commands.theme.install.messages.themes-missing'), implode(',', $themesUnavailable)));
         } else {
             $io->error(sprintf($this->trans('commands.theme.install.messages.theme-missing'), implode(',', $themesUnavailable)));
         }
     }
     // Run cache rebuild to see changes in Web UI
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
コード例 #5
0
 /**
  * Delete given config name.
  *
  * @param String $name Given config name.
  */
 private function removeConfig($name)
 {
     try {
         $this->configFactory->getEditable($name)->delete();
     } catch (\Exception $e) {
         throw new RuntimeException($e->getMessage());
     }
 }
コード例 #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $resource_id = $input->getArgument('resource-id');
     $rest_resources = $this->getRestResources();
     $rest_resources_ids = array_merge(array_keys($rest_resources['enabled']), array_keys($rest_resources['disabled']));
     if (!$resource_id) {
         $resource_id = $io->choice($this->trans('commands.rest.disable.arguments.resource-id'), $rest_resources_ids);
     }
     $this->validateRestResource($resource_id, $rest_resources_ids, $this->getTranslator());
     $input->setArgument('resource-id', $resource_id);
     $rest_settings = $this->getRestDrupalConfig();
     unset($rest_settings[$resource_id]);
     $config = $this->configFactory->getEditable('rest.settings');
     $config->set('resources', $rest_settings);
     $config->save();
     $io->success(sprintf($this->trans('commands.rest.disable.messages.success'), $resource_id));
     return 0;
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $configName = $input->getArgument('config-name');
     $editor = $input->getArgument('editor');
     $config = $this->configFactory->getEditable($configName);
     $configSystem = $this->configFactory->get('system.file');
     $temporaryDirectory = $configSystem->get('path.temporary') ?: '/tmp';
     $configFile = $temporaryDirectory . '/config-edit/' . $configName . '.yml';
     $ymlFile = new Parser();
     $fileSystem = new Filesystem();
     if (!$configName) {
         $io->error($this->trans('commands.config.edit.messages.no-config'));
         return;
     }
     try {
         $fileSystem->mkdir($temporaryDirectory);
         $fileSystem->dumpFile($configFile, $this->getYamlConfig($configName));
     } catch (IOExceptionInterface $e) {
         $io->error($this->trans('commands.config.edit.messages.no-directory') . ' ' . $e->getPath());
         return;
     }
     if (!$editor) {
         $editor = $this->getEditor();
     }
     $processBuilder = new ProcessBuilder(array($editor, $configFile));
     $process = $processBuilder->getProcess();
     $process->setTty('true');
     $process->run();
     if ($process->isSuccessful()) {
         $value = $ymlFile->parse(file_get_contents($configFile));
         $config->setData($value);
         $config->save();
         $fileSystem->remove($configFile);
     }
     if (!$process->isSuccessful()) {
         $io->error($process->getErrorOutput());
     }
 }
コード例 #8
0
 /**
  * Overrides the connection timeout based on module configuration.
  *
  * Constructor.
  * @param ConfigFactory $config_factory
  * @param ClientInterface $http_client
  *
  * @see Mollom::__construct().
  */
 public function __construct(ConfigFactory $config_factory, ClientInterface $http_client)
 {
     $this->config = $config_factory->getEditable('mollom.settings');
     $this->requestTimeout = $this->config->get('connection_timeout_seconds');
     $this->client = $http_client;
     parent::__construct();
     // Set any configured server that may be different from the default.
     $configured_server = $this->loadConfiguration('server');
     if (!empty($configured_server)) {
         $this->saveConfiguration('server', $configured_server);
     }
     $this->requestTimeout = $this->config->get('connection_timeout_seconds');
 }
コード例 #9
0
 protected function overrideConfigurations($configurations)
 {
     $result = [];
     foreach ($configurations as $configName => $options) {
         $config = $this->configFactory->getEditable($configName);
         foreach ($options as $key => $value) {
             $original = $config->get($key);
             if (is_bool($original)) {
                 $original = $original ? 'true' : 'false';
             }
             $updated = $value;
             if (is_bool($updated)) {
                 $updated = $updated ? 'true' : 'false';
             }
             $result[$configName][] = ['configuration' => $key, 'original' => $original, 'updated' => $updated];
             $config->set($key, $value);
         }
         $config->save();
     }
     //        $this->getDrupalService('settings');die();
     //
     //        $drupal = $this->getDrupalHelper();
     //        $fs = $this->getApplication()->getContainerHelper()->get('filesystem');
     //
     //        $cache_render  = '$settings = ["cache"]["bins"]["render"] = "cache.backend.null";';
     //        $cache_dynamic = '$settings =["cache"]["bins"]["dynamic_page_cache"] = "cache.backend.null";';
     //
     //        $settings_file = $fs->exists($drupal->getRoot() . '/sites/default/local.settings.php')?:$drupal->getRoot() . '/sites/default/settings.php';
     //        chmod($drupal->getRoot() . '/sites/default/', 0775);
     //        chmod($settings_file, 0775);
     //        $settings_file = $fs->dumpFile($settings_file, file_get_contents($settings_file) . $cache_render . $cache_dynamic);
     //        chmod($drupal->getRoot() . '/sites/default/', 0644);
     //        chmod($settings_file, 0644);
     //        @TODO: $io->commentBlock()
     return $result;
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 public function setConfiguration(array $configuration)
 {
     $this->configuration = $configuration;
     $this->configFactory->getEditable('printable.format')->set($this->getPluginId(), $this->configuration)->save();
 }