Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $environment = $input->getArgument('environment');
     $loadedConfigurations = [];
     if (in_array($environment, array('dev', 'prod'))) {
         $loadedConfigurations = $this->loadConfigurations($environment);
     } else {
         $io->error($this->trans('commands.site.mode.messages.invalid-env'));
     }
     $configurationOverrideResult = $this->overrideConfigurations($loadedConfigurations['configurations']);
     foreach ($configurationOverrideResult as $configName => $result) {
         $io->info($this->trans('commands.site.mode.messages.configuration') . ':', false);
         $io->comment($configName);
         $tableHeader = [$this->trans('commands.site.mode.messages.configuration-key'), $this->trans('commands.site.mode.messages.original'), $this->trans('commands.site.mode.messages.updated')];
         $io->table($tableHeader, $result);
     }
     $servicesOverrideResult = $this->overrideServices($loadedConfigurations['services'], $io);
     if (!empty($servicesOverrideResult)) {
         $io->info($this->trans('commands.site.mode.messages.new-services-settings'));
         $tableHeaders = [$this->trans('commands.site.mode.messages.service'), $this->trans('commands.site.mode.messages.service-parameter'), $this->trans('commands.site.mode.messages.service-value')];
         $io->table($tableHeaders, $servicesOverrideResult);
     }
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $uid = $input->getArgument('user');
     $user = User::load($uid);
     if (!$user) {
         $io->error(sprintf($this->trans('commands.user.password.reset.errors.invalid-user'), $uid));
         return 1;
     }
     $password = $input->getArgument('password');
     if (!$password) {
         $io->error(sprintf($this->trans('commands.user.password.reset.errors.empty-password'), $uid));
         return 1;
     }
     try {
         $user->setPassword($password);
         $user->save();
         $schema = $this->database->schema();
         $flood = $schema->findTables('flood');
         if ($flood) {
             $this - $this->chainQueue->addCommand('user:login:clear:attempts', ['uid' => $uid]);
         }
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $io->success(sprintf($this->trans('commands.user.password.reset.messages.reset-successful'), $uid));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $this->chainQueue->addCommand('generate:plugin:fieldtype', ['--module' => $input->getOption('module'), '--class' => $input->getOption('type-class'), '--label' => $input->getOption('type-label'), '--plugin-id' => $input->getOption('type-plugin-id'), '--description' => $input->getOption('type-description'), '--default-widget' => $input->getOption('default-widget'), '--default-formatter' => $input->getOption('default-formatter')], false);
     $this->chainQueue->addCommand('generate:plugin:fieldwidget', ['--module' => $input->getOption('module'), '--class' => $input->getOption('widget-class'), '--label' => $input->getOption('widget-label'), '--plugin-id' => $input->getOption('widget-plugin-id'), '--field-type' => $input->getOption('field-type')], false);
     $this->chainQueue->addCommand('generate:plugin:fieldformatter', ['--module' => $input->getOption('module'), '--class' => $input->getOption('formatter-class'), '--label' => $input->getOption('formatter-label'), '--plugin-id' => $input->getOption('formatter-plugin-id'), '--field-type' => $input->getOption('field-type')], false);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery'], false);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($output)) {
         return;
     }
     $module = $input->getOption('module');
     $name = $input->getOption('name');
     $class = $input->getOption('class');
     $this->generator->generate($module, $name, $class);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $postUpdateName = $input->getOption('post-update-name');
     $this->validatePostUpdateName($module, $postUpdateName);
     $this->generator->generate($module, $postUpdateName);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     try {
         $this->lock->release('cron');
         $io->info($this->trans('commands.cron.release.messages.released'));
     } catch (Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $class_name = $input->getOption('class');
     $label = $input->getOption('label');
     $plugin_id = $input->getOption('plugin-id');
     $this->generator->generate($module, $class_name, $label, $plugin_id);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $class_name = $input->getOption('class');
     $class_machine_name = $this->stringConverter->camelCaseToUnderscore($class_name);
     $title = $input->getOption('title');
     $description = $input->getOption('description');
     $this->generator->generate($module, $class_machine_name, $class_name, $title, $description);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
Example #9
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     if ($this->extensionManager->validateModuleFunctionExist($module, $module . '_help')) {
         throw new \Exception(sprintf($this->trans('commands.generate.help.messages.help-already-implemented'), $module));
     }
     $description = $input->getOption('description');
     $this->generator->generate($module, $description);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $plugins = $this->getPlugins();
     // @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $pluginId = $input->getOption('plugin-id');
     $plugin = ucfirst($this->stringConverter->underscoreToCamelCase($pluginId));
     // Confirm that plugin.manager is available
     if (!$this->validator->validatePluginManagerServiceExist($pluginId, $plugins)) {
         throw new \Exception(sprintf($this->trans('commands.generate.plugin.skeleton.messages.plugin-dont-exist'), $pluginId));
     }
     if (array_key_exists($pluginId, $this->pluginGeneratorsImplemented)) {
         $io->warning(sprintf($this->trans('commands.generate.plugin.skeleton.messages.plugin-generator-implemented'), $pluginId, $this->pluginGeneratorsImplemented[$pluginId]));
     }
     $className = $input->getOption('class');
     $services = $input->getOption('services');
     // @see use Drupal\Console\Command\Shared\ServicesTrait::buildServices
     $buildServices = $this->buildServices($services);
     $pluginMetaData = $this->getPluginMetadata($pluginId);
     $this->generator->generate($module, $pluginId, $plugin, $className, $pluginMetaData, $buildServices);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     if (!$this->lock->acquire('cron', 900.0)) {
         $io->warning($this->trans('commands.cron.execute.messages.lock'));
         return 1;
     }
     if (in_array('all', $modules)) {
         $modules = $this->moduleHandler->getImplementations('cron');
     }
     foreach ($modules as $module) {
         if (!$this->moduleHandler->implementsHook($module, 'cron')) {
             $io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
             continue;
         }
         try {
             $io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
             $this->moduleHandler->invoke($module, 'cron');
         } catch (\Exception $e) {
             watchdog_exception('cron', $e);
             $io->error($e->getMessage());
         }
     }
     $this->state->set('system.cron_last', REQUEST_TIME);
     $this->lock->release('cron');
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
     $io->success($this->trans('commands.cron.execute.messages.success'));
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return 1;
     }
     $module = $input->getOption('module');
     $class_name = $input->getOption('class');
     $label = $input->getOption('label');
     $plugin_id = $input->getOption('plugin-id');
     $services = $input->getOption('services');
     $theme_region = $input->getOption('theme-region');
     $inputs = $input->getOption('inputs');
     $theme = $this->configFactory->get('system.theme')->get('default');
     $themeRegions = \system_region_list($theme, REGIONS_VISIBLE);
     if (!empty($theme_region) && !isset($themeRegions[$theme_region])) {
         $io->error(sprintf($this->trans('commands.generate.plugin.block.messages.invalid-theme-region'), $theme_region));
         return 1;
     }
     // @see use Drupal\Console\Command\Shared\ServicesTrait::buildServices
     $build_services = $this->buildServices($services);
     $this->generator->generate($module, $class_name, $label, $plugin_id, $build_services, $inputs);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
     if ($theme_region) {
         // Load block to set theme region
         $block = $this->entityTypeManager->getStorage('block')->create(array('id' => $plugin_id, 'plugin' => $plugin_id, 'theme' => $theme));
         $block->setRegion($theme_region);
         $block->save();
     }
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $updateNumber = $input->getOption('update-n');
     $lastUpdateSchema = $this->getLastUpdate($module);
     if ($updateNumber <= $lastUpdateSchema) {
         throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.update.messages.wrong-update-n'), $updateNumber));
     }
     $this->generator->generate($module, $updateNumber);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
Example #14
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']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     //$state = $this->getDrupalService('state');
     $io->info($this->trans('commands.site.maintenance.messages.maintenance-on'));
     $io->info($this->trans('commands.update.entities.messages.start'));
     $this->state->set('system.maintenance_mode', true);
     try {
         $this->entityDefinitionUpdateManager->applyUpdates();
         /* @var EntityStorageException $e */
     } catch (EntityStorageException $e) {
         /* @var Error $variables */
         $variables = Error::decodeException($e);
         $io->info($this->trans('commands.update.entities.messages.error'));
         $io->info($variables);
     }
     $this->state->set('system.maintenance_mode', false);
     $io->info($this->trans('commands.update.entities.messages.end'));
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
     $io->info($this->trans('commands.site.maintenance.messages.maintenance-off'));
 }
 /**
  * {@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']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $module = $input->getArgument('module');
     $latest = $input->getOption('latest');
     $composer = $input->getOption('composer');
     $this->site->loadLegacyFile('/core/includes/bootstrap.inc');
     // check module's requirements
     $this->moduleRequirement($module);
     if ($composer) {
         foreach ($module as $moduleItem) {
             $command = sprintf('composer show drupal/%s ', $moduleItem);
             $processBuilder = new ProcessBuilder([]);
             $processBuilder->setWorkingDirectory($this->appRoot);
             $processBuilder->setArguments(explode(" ", $command));
             $process = $processBuilder->getProcess();
             $process->setTty('true');
             $process->run();
             if ($process->isSuccessful()) {
                 $io->info(sprintf('Module %s was downloaded with Composer.', $moduleItem));
             } else {
                 $io->error(sprintf('Module %s seems not to be installed with Composer. Halting.', $moduleItem));
                 throw new \RuntimeException($process->getErrorOutput());
                 return 0;
             }
         }
         $unInstalledModules = $module;
     } else {
         $resultList = $this->downloadModules($io, $module, $latest);
         $invalidModules = $resultList['invalid'];
         $unInstalledModules = $resultList['uninstalled'];
         if ($invalidModules) {
             foreach ($invalidModules as $invalidModule) {
                 unset($module[array_search($invalidModule, $module)]);
                 $io->error(sprintf('Invalid module name: %s', $invalidModule));
             }
         }
         if (!$unInstalledModules) {
             $io->warning($this->trans('commands.module.install.messages.nothing'));
             return 0;
         }
     }
     try {
         $io->comment(sprintf($this->trans('commands.module.install.messages.installing'), implode(', ', $unInstalledModules)));
         drupal_static_reset('system_rebuild_module_data');
         $this->moduleInstaller->install($unInstalledModules, true);
         $io->success(sprintf($this->trans('commands.module.install.messages.success'), implode(', ', $unInstalledModules)));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $name = $input->getOption('name');
     $class = $input->getOption('class');
     $interface = $input->getOption('interface');
     $services = $input->getOption('services');
     $path_service = $input->getOption('path_service');
     $available_services = $this->container->getServiceIds();
     if (in_array($name, array_values($available_services))) {
         throw new \Exception(sprintf($this->trans('commands.generate.service.messages.service-already-taken'), $module));
     }
     // @see Drupal\Console\Command\Shared\ServicesTrait::buildServices
     $build_services = $this->buildServices($services);
     $this->generator->generate($module, $name, $class, $interface, $build_services, $path_service);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $mode = $input->getArgument('mode');
     $stateName = 'system.maintenance_mode';
     $modeMessage = null;
     $cacheRebuild = true;
     if ('ON' === strtoupper($mode)) {
         $this->state->set($stateName, true);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-on';
     }
     if ('OFF' === strtoupper($mode)) {
         $this->state->set($stateName, false);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-off';
     }
     if ($modeMessage === null) {
         $modeMessage = 'commands.site.maintenance.errors.invalid-mode';
         $cacheRebuild = false;
     }
     $io->info($this->trans($modeMessage));
     if ($cacheRebuild) {
         $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $name = $input->getOption('name');
     $class = $input->getOption('class');
     $services = $input->getOption('services');
     // Add renderer service as first parameter.
     array_unshift($services, 'renderer');
     // @see Drupal\Console\Command\Shared\ServicesTrait::buildServices
     $build_services = $this->buildServices($services);
     $this->generator->generate($module, $name, $class, $build_services);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
Example #21
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $module = $input->getOption('module');
     $services = $input->getOption('services');
     $path = $input->getOption('path');
     $class_name = $input->getOption('class');
     $form_id = $input->getOption('form-id');
     $form_type = $this->formType;
     $menu_link_gen = $input->getOption('menu_link_gen');
     $menu_parent = $input->getOption('menu_parent');
     $menu_link_title = $input->getOption('menu_link_title');
     $menu_link_desc = $input->getOption('menu_link_desc');
     // if exist form generate config file
     $inputs = $input->getOption('inputs');
     $build_services = $this->buildServices($services);
     $this->generator->generate($module, $class_name, $form_id, $form_type, $build_services, $inputs, $path, $menu_link_gen, $menu_link_title, $menu_parent, $menu_link_desc);
     $this->chainQueue->addCommand('router:rebuild', []);
 }
Example #22
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->module = $input->getArgument('module');
     $this->update_n = $input->getArgument('update-n');
     $this->site->loadLegacyFile('/core/includes/install.inc');
     $this->site->loadLegacyFile('/core/includes/update.inc');
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     $this->checkUpdates($io);
     $io->info($this->trans('commands.site.maintenance.description'));
     $this->state->set('system.maintenance_mode', true);
     $this->runUpdates($io, $updates);
     $this->runPostUpdates($io);
     $this->state->set('system.maintenance_mode', false);
     $io->info($this->trans('commands.site.maintenance.messages.maintenance-off'));
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $module = $input->getArgument('module');
     $unInstalledDependencies = $this->calculateDependencies((array) $module);
     if (!$unInstalledDependencies) {
         $io->warning($this->trans('commands.module.install.dependencies.messages.no-depencies'));
         return 0;
     }
     try {
         $io->comment(sprintf($this->trans('commands.module.install.dependencies.messages.installing'), implode(', ', $unInstalledDependencies)));
         drupal_static_reset('system_rebuild_module_data');
         $this->moduleInstaller->install($unInstalledDependencies, true);
         $io->success(sprintf($this->trans('commands.module.install.dependencies.messages.success'), implode(', ', $unInstalledDependencies)));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $module = $input->getOption('module');
     $entity_class = $input->getOption('entity-class');
     $entity_name = $input->getOption('entity-name');
     $label = $input->getOption('label');
     $has_bundles = $input->getOption('has-bundles');
     $base_path = $input->getOption('base-path');
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $bundle_entity_name = $has_bundles ? $entity_name . '_type' : null;
     $is_translatable = $input->hasOption('is-translatable') ? $input->getOption('is-translatable') : true;
     $io = new DrupalStyle($input, $output);
     $generator = $this->generator;
     $generator->setIo($io);
     //@TODO:
     //$generator->setLearning($learning);
     $generator->generate($module, $entity_name, $entity_class, $label, $base_path, $is_translatable, $bundle_entity_name);
     if ($has_bundles) {
         $this->chainQueue->addCommand('generate:entity:config', ['--module' => $module, '--entity-class' => $entity_class . 'Type', '--entity-name' => $entity_name . '_type', '--label' => $label . ' type', '--bundle-of' => $entity_name]);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io)) {
         return;
     }
     $module = $input->getOption('module');
     $formId = $input->getOption('form-id');
     $inputs = $input->getOption('inputs');
     $function = $module . '_form_' . $formId . '_alter';
     if ($this->extensionManager->validateModuleFunctionExist($module, $function)) {
         throw new \Exception(sprintf($this->trans('commands.generate.form.alter.messages.help-already-implemented'), $module));
     }
     //validate if input is an array
     if (!is_array($inputs[0])) {
         $inputs = $this->explodeInlineArray($inputs);
     }
     $this->generator->generate($module, $formId, $inputs, $this->metadata);
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $yes = $input->hasOption('yes') ? $input->getOption('yes') : false;
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io, $yes)) {
         return;
     }
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $module = $input->getOption('module');
     $class = $input->getOption('class');
     $routes = $input->getOption('routes');
     $test = $input->getOption('test');
     $services = $input->getOption('services');
     $routes = $this->inlineValueAsArray($routes);
     $input->setOption('routes', $routes);
     // @see use Drupal\Console\Command\Shared\ServicesTrait::buildServices
     $build_services = $this->buildServices($services);
     //$this->generator->setLearning($learning);
     $this->generator->generate($module, $class, $routes, $test, $build_services);
     // Run cache rebuild to see changes in Web UI
     $this->chainQueue->addCommand('router:rebuild', []);
 }
Example #27
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $interactive = false;
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $file = $input->getOption('file');
     if (!$file) {
         $io->error($this->trans('commands.chain.messages.missing_file'));
         return 1;
     }
     $fileSystem = new Filesystem();
     $file = calculateRealPath($file);
     if (!$fileSystem->exists($file)) {
         $io->error(sprintf($this->trans('commands.chain.messages.invalid_file'), $file));
         return 1;
     }
     $placeholder = $input->getOption('placeholder');
     if ($placeholder) {
         $placeholder = $this->inlineValueAsArray($placeholder);
     }
     $chainContent = $this->getFileContents($file);
     $environmentPlaceHolders = $this->extractEnvironmentPlaceHolders($chainContent);
     $envPlaceHolderMap = [];
     $missingEnvironmentPlaceHolders = [];
     foreach ($environmentPlaceHolders as $envPlaceHolder) {
         if (!getenv($envPlaceHolder)) {
             $missingEnvironmentPlaceHolders[$envPlaceHolder] = sprintf('export %s=%s_VALUE', $envPlaceHolder, strtoupper($envPlaceHolder));
             continue;
         }
         $envPlaceHolderMap[$envPlaceHolder] = getenv($envPlaceHolder);
     }
     if ($missingEnvironmentPlaceHolders) {
         $io->error(sprintf($this->trans('commands.chain.messages.missing-environment-placeholders'), implode(', ', array_keys($missingEnvironmentPlaceHolders))));
         $io->info($this->trans('commands.chain.messages.set-environment-placeholders'));
         $io->block(array_values($missingEnvironmentPlaceHolders));
         return 1;
     }
     $envPlaceHolderData = new ArrayDataSource($envPlaceHolderMap);
     $placeholderResolver = new RegexPlaceholderResolver($envPlaceHolderData, '${{', '}}');
     $chainContent = $placeholderResolver->resolvePlaceholder($chainContent);
     $inlinePlaceHolders = $this->extractInlinePlaceHolders($chainContent);
     $inlinePlaceHoldersReplacements = [];
     foreach ($inlinePlaceHolders as $key => $inlinePlaceHolder) {
         if (strpos($inlinePlaceHolder, '|') > 0) {
             $placeholderParts = explode('|', $inlinePlaceHolder);
             $inlinePlaceHoldersReplacements[] = $placeholderParts[0];
             continue;
         }
         $inlinePlaceHoldersReplacements[] = $inlinePlaceHolder;
     }
     $chainContent = str_replace($inlinePlaceHolders, $inlinePlaceHoldersReplacements, $chainContent);
     $inlinePlaceHolders = $inlinePlaceHoldersReplacements;
     $inlinePlaceHolderMap = [];
     foreach ($placeholder as $key => $placeholderItem) {
         $inlinePlaceHolderMap = array_merge($inlinePlaceHolderMap, $placeholderItem);
     }
     $missingInlinePlaceHolders = [];
     foreach ($inlinePlaceHolders as $inlinePlaceHolder) {
         if (!array_key_exists($inlinePlaceHolder, $inlinePlaceHolderMap)) {
             $missingInlinePlaceHolders[$inlinePlaceHolder] = sprintf('--placeholder="%s:%s_VALUE"', $inlinePlaceHolder, strtoupper($inlinePlaceHolder));
         }
     }
     if ($missingInlinePlaceHolders) {
         $io->error(sprintf($this->trans('commands.chain.messages.missing-inline-placeholders'), implode(', ', array_keys($missingInlinePlaceHolders))));
         $io->info($this->trans('commands.chain.messages.set-inline-placeholders'));
         $io->block(array_values($missingInlinePlaceHolders));
         return 1;
     }
     $inlinePlaceHolderData = new ArrayDataSource($inlinePlaceHolderMap);
     $placeholderResolver = new RegexPlaceholderResolver($inlinePlaceHolderData, '%{{', '}}');
     $chainContent = $placeholderResolver->resolvePlaceholder($chainContent);
     $parser = new Parser();
     $configData = $parser->parse($chainContent);
     $commands = [];
     if (array_key_exists('commands', $configData)) {
         $commands = $configData['commands'];
     }
     foreach ($commands as $command) {
         $moduleInputs = [];
         $arguments = !empty($command['arguments']) ? $command['arguments'] : [];
         $options = !empty($command['options']) ? $command['options'] : [];
         foreach ($arguments as $key => $value) {
             $moduleInputs[$key] = is_null($value) ? '' : $value;
         }
         foreach ($options as $key => $value) {
             $moduleInputs['--' . $key] = is_null($value) ? '' : $value;
         }
         $parameterOptions = $input->getOptions();
         unset($parameterOptions['file']);
         foreach ($parameterOptions as $key => $value) {
             if ($value === true) {
                 $moduleInputs['--' . $key] = true;
             }
         }
         $this->chainQueue->addCommand($command['command'], $moduleInputs, $interactive, $learning);
     }
     return 0;
 }