protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $language = $input->getArgument('language'); $tableHeader = [$this->trans('commands.locale.translation.status.messages.project'), $this->trans('commands.locale.translation.status.messages.version'), $this->trans('commands.locale.translation.status.messages.local-age'), $this->trans('commands.locale.translation.status.messages.remote-age'), $this->trans('commands.locale.translation.status.messages.info')]; $locale = $this->extensionManager->getModule('locale'); $this->site->loadLegacyFile($locale->getPath(true) . '/locale.compare.inc'); $languages = locale_translatable_language_list(); $status = locale_translation_get_status(); if (!$languages) { $io->info($this->trans('commands.locale.translation.status.messages.no-languages')); return; } elseif (empty($status)) { $io->info($this->trans('commands.locale.translation.status.messages.no-translations')); return; } if ($languages) { $projectsStatus = $this->projectsStatus(); foreach ($projectsStatus as $langcode => $rows) { $tableRows = []; if ($language != '' && !($language == $langcode || strtolower($language) == strtolower($languages[$langcode]->getName()))) { continue; } $io->info($languages[$langcode]->getName()); foreach ($rows as $row) { if ($row[0] == 'drupal') { $row[0] = $this->trans('commands.common.messages.drupal-core'); } $tableRows[] = $row; } $io->table($tableHeader, $tableRows, 'compact'); } } }
/** * Generator Plugin Block. * * @param $module * @param $class_name * @param $label * @param $plugin_id * @param $services */ public function generate($module, $class_name, $label, $plugin_id, $services, $inputs) { // Consider the type when determining a default value. Figure out what // the code looks like for the default value tht we need to generate. foreach ($inputs as &$input) { $default_code = '$this->t(\'\')'; if ($input['default_value'] == '') { switch ($input['type']) { case 'checkbox': case 'number': case 'weight': case 'radio': $default_code = 0; break; case 'radios': case 'checkboxes': $default_code = 'array()'; break; } } elseif (substr($input['default_value'], 0, 1) == '$') { // If they want to put in code, let them, they're programmers. $default_code = $input['default_value']; } elseif (is_numeric($input['default_value'])) { $default_code = $input['default_value']; } elseif (preg_match('/^(true|false)$/i', $input['default_value'])) { // Coding Standards $default_code = strtoupper($input['default_value']); } else { $default_code = '$this->t(\'' . $input['default_value'] . '\')'; } $input['default_code'] = $default_code; } $parameters = ['module' => $module, 'class_name' => $class_name, 'label' => $label, 'plugin_id' => $plugin_id, 'services' => $services, 'inputs' => $inputs]; $this->renderFile('module/src/Plugin/Block/block.php.twig', $this->extensionManager->getPluginPath($module, 'Block') . '/' . $class_name . '.php', $parameters); }
/** * Generator Plugin Block. * * @param $module * @param $class * @param $provider_id */ public function generate($module, $class, $provider_id) { $parameters = ['module' => $module, 'class' => $class]; $this->renderFile('module/src/Authentication/Provider/authentication-provider.php.twig', $this->extensionManager->getModule($module)->getAuthenticationPath('Provider') . '/' . $class . '.php', $parameters); $parameters = ['module' => $module, 'class' => $class, 'class_path' => sprintf('Drupal\\%s\\Authentication\\Provider\\%s', $module, $class), 'name' => 'authentication.' . $module, 'services' => [['name' => 'config.factory'], ['name' => 'entity_type.manager']], 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml'), 'tags' => ['name' => 'authentication_provider', 'provider_id' => $provider_id, 'priority' => '100']]; $this->renderFile('module/services.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml', $parameters, FILE_APPEND); }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $theme = $input->getArgument('theme'); $fullPath = $input->getOption('absolute'); $theme = $this->extensionManager->getTheme($theme); $io->info($theme->getPath($fullPath)); }
/** * Generate. * * @param string $module Module name * @param string $name Command name * @param string $class Class name * @param boolean $containerAware Container Aware command * @param array $services Services array */ public function generate($module, $name, $class, $containerAware, $services) { $command_key = str_replace(':', '.', $name); $parameters = ['module' => $module, 'name' => $name, 'class_name' => $class, 'container_aware' => $containerAware, 'command_key' => $command_key, 'services' => $services, 'tags' => ['name' => 'console.command'], 'class_path' => sprintf('Drupal\\%s\\Command\\%s', $module, $class), 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml')]; $this->renderFile('module/src/Command/command.php.twig', $this->extensionManager->getModule($module)->getCommandDirectory() . '/' . $class . '.php', $parameters); $parameters['name'] = $module . '.' . str_replace(':', '_', $name); $this->renderFile('module/services.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml', $parameters, FILE_APPEND); $this->renderFile('module/src/Command/console/translations/en/command.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/console/translations/en/' . $command_key . '.yml'); }
public function generate($module, $class, $routes, $test, $services) { $parameters = ['class_name' => $class, 'services' => $services, 'module' => $module, 'routes' => $routes]; $this->renderFile('module/src/Controller/controller.php.twig', $this->extensionManager->getModule($module)->getControllerPath() . '/' . $class . '.php', $parameters); $this->renderFile('module/routing-controller.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.routing.yml', $parameters, FILE_APPEND); if ($test) { $this->renderFile('module/Tests/Controller/controller.php.twig', $this->extensionManager->getModule($module)->getTestPath('Controller') . '/' . $class . 'Test.php', $parameters); } }
/** * @param $module * @param $permissions * @param $learning */ public function generate($module, $permissions, $learning) { $parameters = array('module_name' => $module, 'permissions' => $permissions); $this->renderFile('module/permission.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.permissions.yml', $parameters, FILE_APPEND); $content = $this->renderer->render('module/permission-routing.yml.twig', $parameters); if ($learning) { echo 'You can use this permission in the routing file like this:' . PHP_EOL; echo $content; } }
/** * @param $extension * @return bool */ protected function isExtensionInstalled($extension) { if (!$this->extensions) { $modules = $this->extensionManager->discoverModules()->showCore()->showNoCore()->showInstalled()->getList(TRUE); $themes = $this->extensionManager->discoverThemes()->showCore()->showNoCore()->showInstalled()->getList(TRUE); $profiles = $this->extensionManager->discoverProfiles()->showCore()->showNoCore()->showInstalled()->getList(TRUE); $this->extensions = array_merge($modules, $themes, $profiles); } return in_array($extension, $this->extensions); }
/** * {@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, $yes)) { return; } $machine_name = $input->getOption('module'); $file_path = $this->extensionManager->getModule($machine_name)->getPath(); $generator = $this->generator; $generator->generate($machine_name, $file_path); }
/** * Generator Entity. * * @param string $module Module name * @param string $entity_name Entity machine name * @param string $entity_class Entity class name * @param string $label Entity label * @param string $base_path Base path * @param string $bundle_of Entity machine name of the content entity this config entity acts as a bundle for. */ public function generate($module, $entity_name, $entity_class, $label, $base_path, $bundle_of = null) { $parameters = ['module' => $module, 'entity_name' => $entity_name, 'entity_class' => $entity_class, 'label' => $label, 'bundle_of' => $bundle_of, 'base_path' => $base_path]; $this->renderFile('module/config/schema/entity.schema.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/config/schema/' . $entity_name . '.schema.yml', $parameters); $this->renderFile('module/links.menu-entity-config.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.links.menu.yml', $parameters, FILE_APPEND); $this->renderFile('module/links.action-entity.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.links.action.yml', $parameters, FILE_APPEND); $this->renderFile('module/src/Entity/interface-entity.php.twig', $this->extensionManager->getModule($module)->getEntityPath() . '/' . $entity_class . 'Interface.php', $parameters); $this->renderFile('module/src/Entity/entity.php.twig', $this->extensionManager->getModule($module)->getEntityPath() . '/' . $entity_class . '.php', $parameters); $this->renderFile('module/src/entity-route-provider.php.twig', $this->extensionManager->getModule($module)->getSourcePath() . '/' . $entity_class . 'HtmlRouteProvider.php', $parameters); $this->renderFile('module/src/Form/entity.php.twig', $this->extensionManager->getModule($module)->getFormPath() . '/' . $entity_class . 'Form.php', $parameters); $this->renderFile('module/src/Form/entity-delete.php.twig', $this->extensionManager->getModule($module)->getFormPath() . '/' . $entity_class . 'DeleteForm.php', $parameters); $this->renderFile('module/src/entity-listbuilder.php.twig', $this->extensionManager->getModule($module)->getSourcePath() . '/' . $entity_class . 'ListBuilder.php', $parameters); }
/** * {@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']); }
/** * @param bool|TRUE $status * @return int */ private function getThemeCount($status = true) { if ($status) { return count($this->extensionManager->discoverThemes()->showCore()->showNoCore()->showInstalled()->getList()); } return count($this->extensionManager->discoverThemes()->showCore()->showNoCore()->showUninstalled()->getList()); }
protected function validatePostUpdateName($module, $postUpdateName) { if (!$this->validator->validateSpaces($postUpdateName)) { throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.post.update.messages.wrong-post-update-name'), $postUpdateName)); } if ($this->extensionManager->validateModuleFunctionExist($module, $module . '_post_update_' . $postUpdateName, $module . '.post_update.php')) { throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.post.update.messages.post-update-name-already-implemented'), $postUpdateName)); } }
/** * @param $module * @param $class_name * @param $services * @param $inputs * @param $form_id * @param $form_type * @param $path * @param $menu_link_gen * @param $menu_link_title * @param $menu_parent * @param $menu_link_desc */ public function generate($module, $class_name, $form_id, $form_type, $services, $inputs, $path, $menu_link_gen, $menu_link_title, $menu_parent, $menu_link_desc) { $class_name_short = strtolower($this->stringConverter->removeSuffix($class_name)); $parameters = array('class_name' => $class_name, 'services' => $services, 'inputs' => $inputs, 'module_name' => $module, 'form_id' => $form_id, 'path' => $path, 'route_name' => $class_name, 'menu_link_title' => $menu_link_title, 'menu_parent' => $menu_parent, 'menu_link_desc' => $menu_link_desc, 'class_name_short' => $class_name_short); if ($form_type == 'ConfigFormBase') { $template = 'module/src/Form/form-config.php.twig'; $parameters['config_form'] = true; } else { $template = 'module/src/Form/form.php.twig'; $parameters['config_form'] = false; } $this->renderFile('module/routing-form.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.routing.yml', $parameters, FILE_APPEND); $this->renderFile($template, $this->extensionManager->getModule($module)->getFormPath() . '/' . $class_name . '.php', $parameters); // Render defaults YML file. $this->renderFile('module/config/install/field.default.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/config/install/' . $module . '.' . $class_name_short . '.yml', $parameters); if ($menu_link_gen == true) { $this->renderFile('module/links.menu.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.links.menu.yml', $parameters, FILE_APPEND); } }
protected function setDirectory($target, $template, $module, $class) { $default_path = '/modules/custom/' . $module . '/src/'; $directory = ''; switch ($template) { case 'service.php.twig': $default_target = $this->extensionManager->getModule($module)->getPath() . '/src/' . $class . '.php'; $custom_target = $this->extensionManager->getModule($module)->getPath() . '/' . $target . '/' . $class . '.php'; $directory = strcmp($target, $default_path) == 0 ? $default_target : $custom_target; break; case 'interface.php.twig': $default_target = $this->extensionManager->getModule($module)->getPath() . '/src/' . $class . '.php'; $custom_target = $this->extensionManager->getModule($module)->getPath() . '/' . $target . '/' . $class . '.php'; $directory = strcmp($target, $default_path) == 0 ? $default_target : $custom_target; break; default: // code... break; } return $directory; }
/** * {@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']); }
/** * @param \Drupal\Console\Style\DrupalStyle $io * @param $updates */ private function runUpdates(DrupalStyle $io, $updates) { foreach ($updates as $module_name => $module_updates) { $this->site->loadLegacyFile($this->extensionManager->getModule($module_name)->getPath() . '/' . $module_name . '.install', false); foreach ($module_updates['pending'] as $update_number => $update) { if ($this->module != 'all' && $this->update_n !== null && $this->update_n != $update_number) { continue; } if ($this->update_n > $module_updates['start']) { $io->info($this->trans('commands.update.execute.messages.executing-required-previous-updates')); } for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) { $io->info(sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name)); try { $this->moduleHandler->invoke($module_name, 'update_' . $update_index); } catch (\Exception $e) { watchdog_exception('update', $e); $io->error($e->getMessage()); } drupal_set_installed_schema_version($module_name, $update_index); } } } }
public function generate($module, $bundleName, $bundleTitle) { $parameters = ['module' => $module, 'bundle_name' => $bundleName, 'bundle_title' => $bundleTitle]; /** * Generate core.entity_form_display.node.{ bundle_name }.default.yml */ $this->renderFile('module/src/Entity/Bundle/core.entity_form_display.node.default.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/config/install/core.entity_form_display.node.' . $bundleName . '.default.yml', $parameters); /** * Generate core.entity_view_display.node.{ bundle_name }.default.yml */ $this->renderFile('module/src/Entity/Bundle/core.entity_view_display.node.default.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/config/install/core.entity_view_display.node.' . $bundleName . '.default.yml', $parameters); /** * Generate core.entity_view_display.node.{ bundle_name }.teaser.yml */ $this->renderFile('module/src/Entity/Bundle/core.entity_view_display.node.teaser.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/config/install/core.entity_view_display.node.' . $bundleName . '.teaser.yml', $parameters); /** * Generate field.field.node.{ bundle_name }.body.yml */ $this->renderFile('module/src/Entity/Bundle/field.field.node.body.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/config/install/field.field.node.' . $bundleName . '.body.yml', $parameters); /** * Generate node.type.{ bundle_name }.yml */ $this->renderFile('module/src/Entity/Bundle/node.type.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/config/install/node.type.' . $bundleName . '.yml', $parameters); }
/** * Generator Post Update Name function. * * @param $module * @param $post_update_name */ public function generate($module, $post_update_name) { $module_path = $this->extensionManager->getModule($module)->getPath(); $parameters = ['module' => $module, 'post_update_name' => $post_update_name, 'file_exists' => file_exists($module_path . '/' . $module . '.post_update.php')]; $this->renderFile('module/src/post-update.php.twig', $module_path . '/' . $module . '.post_update.php', $parameters, FILE_APPEND); }
/** * Generator Plugin Field Formatter. * * @param string $module Module name * @param string $class_name Plugin condition Class name * @param string $label Plugin condition label * @param string $plugin_id Plugin condition id * @param string $context_definition_id Plugin condition context definition id * @param string $context_definition_label Plugin condition context definition label * @param bool $context_definition_required Plugin condition context definition required */ public function generate($module, $class_name, $label, $plugin_id, $context_definition_id, $context_definition_label, $context_definition_required) { $parameters = ['module' => $module, 'class_name' => $class_name, 'label' => $label, 'plugin_id' => $plugin_id, 'context_definition_id' => $context_definition_id, 'context_definition_label' => $context_definition_label, 'context_definition_required' => $context_definition_required, 'context_id' => str_replace('entity:', '', $context_definition_id)]; $this->renderFile('module/src/Plugin/Condition/condition.php.twig', $this->extensionManager->getPluginPath($module, 'Condition') . '/' . $class_name . '.php', $parameters); }
/** * Generator Plugin Field Formatter. * * @param string $module Module name * @param string $class_name Plugin Class name * @param string $label Plugin label * @param string $plugin_id Plugin id * @param string $field_type Field type this formatter supports */ public function generate($module, $class_machine_name, $class_name, $title, $description) { $parameters = ['module' => $module, 'class_machine_name' => $class_machine_name, 'class_name' => $class_name, 'title' => $title, 'description' => $description]; $this->renderFile('module/module.views.inc.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.views.inc', $parameters); $this->renderFile('module/src/Plugin/Views/field/field.php.twig', $this->extensionManager->getPluginPath($module, 'views/field') . '/' . $class_name . '.php', $parameters); }
/** * Generator Update N function. * * @param $module * @param $update_number */ public function generate($module, $update_number) { $parameters = ['module' => $module, 'update_number' => $update_number]; $module_path = $this->extensionManager->getModule($module)->getPath(); $this->renderFile('module/src/update.php.twig', $module_path . '/' . $module . '.module', $parameters, FILE_APPEND); }
/** * Generator Entity. * * @param string $module Module name * @param string $entity_name Entity machine name * @param string $entity_class Entity class name * @param string $label Entity label * @param string $base_path Base path * @param string $is_translatable Translation configuration * @param string $bundle_entity_type (Config) entity type acting as bundle */ public function generate($module, $entity_name, $entity_class, $label, $base_path, $is_translatable, $bundle_entity_type = null) { $parameters = ['module' => $module, 'entity_name' => $entity_name, 'entity_class' => $entity_class, 'label' => $label, 'bundle_entity_type' => $bundle_entity_type, 'base_path' => $base_path, 'is_translatable' => $is_translatable]; $this->renderFile('module/permissions-entity-content.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.permissions.yml', $parameters, FILE_APPEND); $this->renderFile('module/links.menu-entity-content.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.links.menu.yml', $parameters, FILE_APPEND); $this->renderFile('module/links.task-entity-content.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.links.task.yml', $parameters, FILE_APPEND); $this->renderFile('module/links.action-entity-content.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.links.action.yml', $parameters, FILE_APPEND); $this->renderFile('module/src/accesscontrolhandler-entity-content.php.twig', $this->extensionManager->getModule($module)->getSourcePath() . '/' . $entity_class . 'AccessControlHandler.php', $parameters); if ($is_translatable) { $this->renderFile('module/src/entity-translation-handler.php.twig', $this->extensionManager->getModule($module)->getSourcePath() . '/' . $entity_class . 'TranslationHandler.php', $parameters); } $this->renderFile('module/src/Entity/interface-entity-content.php.twig', $this->extensionManager->getModule($module)->getEntityPath() . '/' . $entity_class . 'Interface.php', $parameters); $this->renderFile('module/src/Entity/entity-content.php.twig', $this->extensionManager->getModule($module)->getEntityPath() . '/' . $entity_class . '.php', $parameters); $this->renderFile('module/src/entity-content-route-provider.php.twig', $this->extensionManager->getModule($module)->getSourcePath() . '/' . $entity_class . 'HtmlRouteProvider.php', $parameters); $this->renderFile('module/src/Entity/entity-content-views-data.php.twig', $this->extensionManager->getModule($module)->getEntityPath() . '/' . $entity_class . 'ViewsData.php', $parameters); $this->renderFile('module/src/listbuilder-entity-content.php.twig', $this->extensionManager->getModule($module)->getSourcePath() . '/' . $entity_class . 'ListBuilder.php', $parameters); $this->renderFile('module/src/Entity/Form/entity-settings.php.twig', $this->extensionManager->getModule($module)->getFormPath() . '/' . $entity_class . 'SettingsForm.php', $parameters); $this->renderFile('module/src/Entity/Form/entity-content.php.twig', $this->extensionManager->getModule($module)->getFormPath() . '/' . $entity_class . 'Form.php', $parameters); $this->renderFile('module/src/Entity/Form/entity-content-delete.php.twig', $this->extensionManager->getModule($module)->getFormPath() . '/' . $entity_class . 'DeleteForm.php', $parameters); $this->renderFile('module/entity-content-page.php.twig', $this->extensionManager->getModule($module)->getSourcePath() . '/' . $entity_name . '.page.inc', $parameters); $this->renderFile('module/templates/entity-html.twig', $this->extensionManager->getModule($module)->getTemplatePath() . '/' . $entity_name . '.html.twig', $parameters); if ($bundle_entity_type) { $this->renderFile('module/templates/entity-with-bundle-content-add-list-html.twig', $this->extensionManager->getModule($module)->getTemplatePath() . '/' . str_replace('_', '-', $entity_name) . '-content-add-list.html.twig', $parameters); // Check for hook_theme() in module file and warn ... $module_filename = $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.module'; // Check if the module file exists. if (!file_exists($module_filename)) { $this->renderFile('module/module.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.module', ['machine_name' => $module, 'description' => '']); } $module_file_contents = file_get_contents($module_filename); if (strpos($module_file_contents, 'function ' . $module . '_theme') !== false) { $this->io->warning(["It looks like you have a hook_theme already declared", "Please manually merge the two hook_theme() implementations in", $module_filename]); } $this->renderFile('module/src/Entity/entity-content-with-bundle.theme.php.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.module', $parameters, FILE_APPEND); if (strpos($module_file_contents, 'function ' . $module . '_theme_suggestions_' . $entity_name) !== false) { $this->io->warning(["It looks like you have a hook_theme_suggestions_HOOK already declared", "Please manually merge the two hook_theme_suggestions_HOOK() implementations in", $module_filename]); } $this->renderFile('module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.module', $parameters, FILE_APPEND); } $content = $this->twigrenderer->render('module/src/Entity/entity-content.theme.php.twig', $parameters); //@TODO: /** if ($this->isLearning()) { $this->io->commentBlock( [ 'Add this to your hook_theme:', $content ] ); } */ }
/** * Generator Plugin CKEditor Button. * * @param string $module Module name * @param string $class_name Plugin Class name * @param string $label Plugin label * @param string $plugin_id Plugin id * @param string $button_name Button name */ public function generate($module, $class_name, $label, $plugin_id, $button_name, $button_icon_path) { $parameters = ['module' => $module, 'class_name' => $class_name, 'label' => $label, 'plugin_id' => $plugin_id, 'button_name' => $button_name, 'button_icon_path' => $button_icon_path]; $this->renderFile('module/src/Plugin/CKEditorPlugin/ckeditorbutton.php.twig', $this->extensionManager->getPluginPath($module, 'CKEditorPlugin') . '/' . $class_name . '.php', $parameters); }
/** * Generator Plugin Block. * * @param $module * @param $form_id * @param $inputs * @param $metadata */ public function generate($module, $form_id, $inputs, $metadata) { $parameters = ['module' => $module, 'form_id' => $form_id, 'inputs' => $inputs, 'metadata' => $metadata]; $module_path = $this->extensionManager->getModule($module)->getPath(); $this->renderFile('module/src/Form/form-alter.php.twig', $module_path . '/' . $module . '.module', $parameters, FILE_APPEND); }
/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); // --profile option $profile = $input->getArgument('profile'); if (!$profile) { $profiles = $this->extensionManager->discoverProfiles()->showCore()->showNoCore()->showInstalled()->showUninstalled()->getList(true); $profiles = array_filter($profiles, function ($profile) { return strpos($profile, 'testing') !== 0; }); $profile = $io->choice($this->trans('commands.site.install.questions.profile'), $profiles); $input->setArgument('profile', $profile); } // // --langcode option $langcode = $input->getOption('langcode'); if (!$langcode) { $languages = $this->site->getStandardLanguages(); $defaultLanguage = $this->configurationManager->getConfiguration()->get('application.language'); $langcode = $io->choiceNoList($this->trans('commands.site.install.questions.langcode'), $languages, $languages[$defaultLanguage]); $input->setOption('langcode', $langcode); } // Use default database setting if is available $database = Database::getConnectionInfo(); if (empty($database['default'])) { // --db-type option $dbType = $input->getOption('db-type'); if (!$dbType) { $databases = $this->site->getDatabaseTypes(); $dbType = $io->choice($this->trans('commands.migrate.setup.questions.db-type'), array_column($databases, 'name')); foreach ($databases as $dbIndex => $database) { if ($database['name'] == $dbType) { $dbType = $dbIndex; } } $input->setOption('db-type', $dbType); } if ($dbType === 'sqlite') { // --db-file option $dbFile = $input->getOption('db-file'); if (!$dbFile) { $dbFile = $io->ask($this->trans('commands.migrate.execute.questions.db-file'), 'sites/default/files/.ht.sqlite'); $input->setOption('db-file', $dbFile); } } else { // --db-host option $dbHost = $input->getOption('db-host'); if (!$dbHost) { $dbHost = $this->dbHostQuestion($io); $input->setOption('db-host', $dbHost); } // --db-name option $dbName = $input->getOption('db-name'); if (!$dbName) { $dbName = $this->dbNameQuestion($io); $input->setOption('db-name', $dbName); } // --db-user option $dbUser = $input->getOption('db-user'); if (!$dbUser) { $dbUser = $this->dbUserQuestion($io); $input->setOption('db-user', $dbUser); } // --db-pass option $dbPass = $input->getOption('db-pass'); if (!$dbPass) { $dbPass = $this->dbPassQuestion($io); $input->setOption('db-pass', $dbPass); } // --db-port prefix $dbPort = $input->getOption('db-port'); if (!$dbPort) { $dbPort = $this->dbPortQuestion($io); $input->setOption('db-port', $dbPort); } } // --db-prefix $dbPrefix = $input->getOption('db-prefix'); if (!$dbPrefix) { $dbPrefix = $this->dbPrefixQuestion($io); $input->setOption('db-prefix', $dbPrefix); } } else { $input->setOption('db-type', $database['default']['driver']); $input->setOption('db-host', $database['default']['host']); $input->setOption('db-name', $database['default']['database']); $input->setOption('db-user', $database['default']['username']); $input->setOption('db-pass', $database['default']['password']); $input->setOption('db-port', $database['default']['port']); $input->setOption('db-prefix', $database['default']['prefix']['default']); $io->info(sprintf($this->trans('commands.site.install.messages.using-current-database'), $database['default']['driver'], $database['default']['database'], $database['default']['username'])); } // --site-name option $siteName = $input->getOption('site-name'); if (!$siteName) { $siteName = $io->ask($this->trans('commands.site.install.questions.site-name'), 'Drupal 8 Site Install'); $input->setOption('site-name', $siteName); } // --site-mail option $siteMail = $input->getOption('site-mail'); if (!$siteMail) { $siteMail = $io->ask($this->trans('commands.site.install.questions.site-mail'), '*****@*****.**'); $input->setOption('site-mail', $siteMail); } // --account-name option $accountName = $input->getOption('account-name'); if (!$accountName) { $accountName = $io->ask($this->trans('commands.site.install.questions.account-name'), 'admin'); $input->setOption('account-name', $accountName); } // --account-pass option $accountPass = $input->getOption('account-pass'); if (!$accountPass) { $accountPass = $io->askHidden($this->trans('commands.site.install.questions.account-pass')); $input->setOption('account-pass', $accountPass); } // --account-mail option $accountMail = $input->getOption('account-mail'); if (!$accountMail) { $accountMail = $io->ask($this->trans('commands.site.install.questions.account-mail'), $siteMail); $input->setOption('account-mail', $accountMail); } }
/** * Generator Plugin Block. * * @param $module * @param $class_name * @param $label * @param $plugin_id * @param $services */ public function generate($module, $class_name, $label, $plugin_id, $services, $inputs) { $parameters = ['module' => $module, 'class_name' => $class_name, 'label' => $label, 'plugin_id' => $plugin_id, 'services' => $services, 'inputs' => $inputs]; $this->renderFile('module/src/Plugin/Block/block.php.twig', $this->extensionManager->getPluginPath($module, 'Block') . '/' . $class_name . '.php', $parameters); }
/** * Generator Service. * * @param string $module Module name * @param string $name Service name * @param string $class Class name */ public function generate($module, $name, $class) { $parameters = ['module' => $module, 'name' => $name, 'class' => $class, 'class_path' => sprintf('Drupal\\%s\\Routing\\%s', $module, $class), 'tags' => array('name' => 'event_subscriber'), 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml')]; $this->renderFile('module/src/Routing/route-subscriber.php.twig', $this->extensionManager->getModule($module)->getRoutingPath() . '/' . $class . '.php', $parameters); $this->renderFile('module/services.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml', $parameters, FILE_APPEND); }
/** * Generator BreakPoint. * * @param $theme * @param $breakpoints * @param $machine_name */ public function generate($theme, $breakpoints, $machine_name) { $parameters = ['theme' => $theme, 'breakpoints' => $breakpoints, 'machine_name' => $machine_name]; $theme_path = $this->extensionManager->getTheme($theme)->getPath(); $this->renderFile('theme/breakpoints.yml.twig', $theme_path . '/' . $machine_name . '.breakpoints.yml', $parameters, FILE_APPEND); }
/** * Generator Service. * * @param string $module Module name * @param string $name Service name * @param string $class Class name * @param array $services List of services */ public function generate($module, $name, $class, $services) { $parameters = ['module' => $module, 'name' => $name, 'class' => $class, 'class_path' => sprintf('Drupal\\%s\\TwigExtension\\%s', $module, $class), 'services' => $services, 'tags' => ['name' => 'twig.extension'], 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml')]; $this->renderFile('module/services.yml.twig', $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml', $parameters, FILE_APPEND); $this->renderFile('module/src/TwigExtension/twig-extension.php.twig', $this->extensionManager->getModule($module)->getPath() . '/src/TwigExtension/' . $class . '.php', $parameters); }