From 1d4b1f0a21c7405889d82d60ab0f7a6b3d1e3ed9 Mon Sep 17 00:00:00 2001
From: Fureigh ' . t('The Configuration Update Base module provides functionality that other modules can use, related to updating and computing differences between configuration versions. This module does not provide any end-user functionality itself.') . ' ' . t('The Configuration Update Reports module provides a report that allows you to see the differences between the default configuration provided by the current versions of your installed modules, themes, and install profile, and the active configuration of your site. From this report, you can also import new configuration provided by updates, and revert your active configuration to the provided default values.') . ' ' . t('This report shows which default configuration items provided by the current versions of your installed modules, themes, and install profile differ from the active configuration of your site. You can generate the report for all configuration of a certain type; for a particular installed module, theme, or your install profile (only modules, themes, and install profiles that actually provide configuration are listed); or for all configuration.') . ' ' . t('Some configuration provided by modules has dependencies, and is only added to your system when all the dependencies are satisfied. This is known as optional configuration.') . ' ' . t('Differences, including missing and added configuration, can be due to either an updated module or theme providing different configuration from when you installed it, or to changes made by site administrators. This report does not differentiate between these two sources for differences, and note that an install profile can also silently override module/theme configuration. Overrides (such as those in your settings.php file) and translations are not considered when looking at differences.') . ' ' . t('Most configuration is organized into a hierarchy of settings; at a minimum, it is a one-level hierarchy where each setting has a name and a value, and the hierarchy comes in when some of the settings have multiple components.') . ' ' . t('Configuration items are normalized and formatted before computing differences. The normalization step alphabetizes the components at each level of the hierarchy, and removes a few components whose differences should be ignored, such as the UUID. The formatting step shows the full hierarchy of each configuration value with :: separators for the hierarchy levels, and a : separator between the lowest-level setting name and the value, so that in a line-by-line diff you can always see which values are actually different. Green lines with + signs have been added, and yellow lines with - signs have been removed.') . ' ' . t('Note that differences are considering the base configuration, without overrides from your settings.php file, or translations.') . ' ' . t('The Features module provides a user interface for exporting bundles of configuration into modules. For more information, see the online documentation for Features module', array(
- ':url' => 'http://drupal.org/node/2404427',
- )) . '' . t('Uses') . '
';
- $output .= '';
- $output .= '
';
- return $output;
-
- case 'config_update_ui.report':
- $output = '';
- $output .= '' . $this->t('Updates report') . '
'];
-
- // List items missing from site.
- $removed = array_diff($install_list, $active_list);
- $build['removed'] = [
- '#caption' => $this->t('Missing configuration items'),
- '#empty' => $this->t('None: all provided configuration items are in your active configuration.'),
- ] + $this->makeReportTable($removed, 'extension', ['import']);
-
- // List optional items that are not installed.
- $inactive = array_diff($optional_list, $active_list);
- $build['inactive'] = [
- '#caption' => $this->t('Inactive optional items'),
- '#empty' => $this->t('None: all optional configuration items are in your active configuration.'),
- ] + $this->makeReportTable($inactive, 'extension', ['import']);
-
- // List items added to site, which only makes sense in the report for a
- // config type.
- $added = array_diff($active_list, $install_list, $optional_list);
- if ($report_type == 'type') {
- $build['added'] = [
- '#caption' => $this->t('Added configuration items'),
- '#empty' => $this->t('None: all active configuration items of this type were provided by modules, themes, or install profile.'),
- ] + $this->makeReportTable($added, 'active', ['export', 'delete']);
- }
-
- // For differences, we need to go through the array of config in both
- // and see if each config item is the same or not.
- $both = array_diff($active_list, $added);
- $different = [];
- foreach ($both as $name) {
- if (!$this->configDiff->same(
- $this->configRevert->getFromExtension('', $name),
- $this->configRevert->getFromActive('', $name)
- )) {
- $different[] = $name;
- }
- }
- $build['different'] = [
- '#caption' => $this->t('Changed configuration items'),
- '#empty' => $this->t('None: no active configuration items differ from their current provided versions.'),
- ] + $this->makeReportTable($different, 'active',
- ['diff', 'export', 'revert']);
-
- return $build;
- }
-
- /**
- * Builds a table for the report.
- *
- * @param string[] $names
- * List of machine names of config items for the table.
- * @param string $storage
- * Config storage the items can be loaded from, either 'active' or
- * 'extension'.
- * @param string[] $actions
- * Action links to include, one or more of:
- * - diff
- * - revert
- * - export
- * - import
- * - delete.
- *
- * @return array
- * Render array for the table, not including the #empty and #prefix
- * properties.
- */
- protected function makeReportTable(array $names, $storage, array $actions) {
- $build = [];
-
- $build['#type'] = 'table';
-
- $build['#attributes'] = ['class' => ['config-update-report']];
-
- $build['#header'] = [
- 'name' => [
- 'data' => $this->t('Machine name'),
- ],
- 'label' => [
- 'data' => $this->t('Label (if any)'),
- 'class' => [RESPONSIVE_PRIORITY_LOW],
- ],
- 'type' => [
- 'data' => $this->t('Type'),
- 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
- ],
- 'provider' => [
- 'data' => $this->t('Provider'),
- 'class' => [RESPONSIVE_PRIORITY_LOW],
- ],
- 'operations' => [
- 'data' => $this->t('Operations'),
- ],
- ];
-
- $build['#rows'] = [];
-
- foreach ($names as $name) {
- $row = [];
- if ($storage == 'active') {
- $config = $this->configRevert->getFromActive('', $name);
- }
- else {
- $config = $this->configRevert->getFromExtension('', $name);
- }
-
- // Figure out what type of config it is, and get the ID.
- $entity_type = $this->configList->getTypeNameByConfigName($name);
-
- if (!$entity_type) {
- // This is simple config.
- $id = $name;
- $label = '';
- $type_label = $this->t('Simple configuration');
- $entity_type = 'system.simple';
- }
- else {
- $definition = $this->configList->getType($entity_type);
- $id_key = $definition->getKey('id');
- $id = $config[$id_key];
- // The label key is not required.
- if ($label_key = $definition->getKey('label')) {
- $label = $config[$label_key];
- }
- else {
- $label = '';
- }
-
- $type_label = $definition->getLabel();
- }
-
- $row[] = $name;
- $row[] = $label;
- $row[] = $type_label;
- $provider = $this->configList->getConfigProvider($name);
- $provider_name = '';
- if (!empty($provider)) {
- switch ($provider[0]) {
- case 'profile':
- $provider_name = $this->moduleHandler->getName($provider[1]);
- if ($provider_name) {
- $provider_name = $this->t('@name profile', ['@name' => $provider_name]);
- }
- else {
- $provider_name = '';
- }
- break;
-
- case 'module':
- $provider_name = $this->moduleHandler->getName($provider[1]);
- if ($provider_name) {
- $provider_name = $this->t('@name module', ['@name' => $provider_name]);
- }
- else {
- $provider_name = '';
- }
- break;
-
- case 'theme':
- $provider_name = $this->themeHandler->getName($provider[1]);
- if ($provider_name) {
- $provider_name = $this->t('@name theme', ['@name' => $provider_name]);
- }
- else {
- $provider_name = '';
- }
- break;
- }
- }
- $row[] = $provider_name;
-
- $links = [];
- $routes = [
- 'export' => 'config.export_single',
- 'import' => 'config_update_ui.import',
- 'diff' => 'config_update_ui.diff',
- 'revert' => 'config_update_ui.revert',
- 'delete' => 'config_update_ui.delete',
- ];
- $titles = [
- 'export' => $this->t('Export'),
- 'import' => $this->t('Import from source'),
- 'diff' => $this->t('Show differences'),
- 'revert' => $this->t('Revert to source'),
- 'delete' => $this->t('Delete'),
- ];
-
- foreach ($actions as $action) {
- $links[$action] = [
- 'url' => Url::fromRoute($routes[$action], ['config_type' => $entity_type, 'config_name' => $id]),
- 'title' => $titles[$action],
- ];
- }
-
- $row[] = [
- 'data' => [
- '#type' => 'operations',
- '#links' => $links,
- ],
- ];
-
- $build['#rows'][] = $row;
- }
-
- return $build;
- }
-
- /**
- * Compares links for uasort(), to sort by displayed link title.
- */
- protected static function sortLinks($link1, $link2) {
- $title1 = $link1['title'];
- $title2 = $link2['title'];
- if ($title1 == $title2) {
- return 0;
- }
- return ($title1 < $title2) ? -1 : 1;
- }
-
- /**
- * Returns the name of the install profile.
- *
- * For backwards compatibility with pre/post 8.3.x, tries to get it from
- * either configuration or settings.
- *
- * @return string
- * The name of the install profile.
- */
- protected function getProfileName() {
- // Code adapted from DrupalKernel::getInstalProfile() in Core.
- // In Core 8.3.x or later, read from config.
- $profile = $this->configFactory->get('core.extension')->get('profile');
- if (!empty($profile)) {
- return $profile;
- }
- else {
- // If system_update_8300() has not yet run, use settings.
- return Settings::get('install_profile');
- }
- }
-
-}
diff --git a/modules/contrib/config_update/config_update_ui/src/Form/ConfigDeleteConfirmForm.php b/modules/contrib/config_update/config_update_ui/src/Form/ConfigDeleteConfirmForm.php
deleted file mode 100644
index e8206b5..0000000
--- a/modules/contrib/config_update/config_update_ui/src/Form/ConfigDeleteConfirmForm.php
+++ /dev/null
@@ -1,144 +0,0 @@
-configList = $config_list;
- $this->configRevert = $config_update;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config_update.config_list'),
- $container->get('config_update.config_update')
- );
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'config_delete_confirm';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getQuestion() {
- if ($this->type == 'system.simple') {
- $type_label = $this->t('Simple configuration');
- }
- else {
- $definition = $this->configList->getType($this->type);
- if (!$definition) {
- // Make a 404 error if the type doesn't exist.
- throw new NotFoundHttpException();
- }
- $type_label = $definition->get('label');
- }
-
- // To delete, the configuration item must exist in active storage. Check
- // that and make a 404 error if not.
- $active = $this->configRevert->getFromActive($this->type, $this->name);
- if (!$active) {
- throw new NotFoundHttpException();
- }
-
- return $this->t('Are you sure you want to delete the %type config %item?', ['%type' => $type_label, '%item' => $this->name]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getCancelUrl() {
- return new Url('config_update_ui.report');
- }
-
- /**
- * {@inheritdoc}
- */
- public function getDescription() {
- return $this->t('This action cannot be undone. Manually deleting configuration from this page can cause problems on your site due to missing dependencies, and should only be done if there is no other way to delete a problematic piece of configuration.');
- }
-
- /**
- * {@inheritdoc}
- */
- public function getConfirmText() {
- return $this->t('Delete');
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state, $config_type = NULL, $config_name = NULL) {
- $this->type = $config_type;
- $this->name = $config_name;
-
- $form = parent::buildForm($form, $form_state);
- return $form;
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- $this->configRevert->delete($this->type, $this->name);
-
- drupal_set_message($this->t('The configuration was deleted.'));
- $form_state->setRedirectUrl($this->getCancelUrl());
- }
-
-}
diff --git a/modules/contrib/config_update/config_update_ui/src/Form/ConfigImportConfirmForm.php b/modules/contrib/config_update/config_update_ui/src/Form/ConfigImportConfirmForm.php
deleted file mode 100644
index 20790ed..0000000
--- a/modules/contrib/config_update/config_update_ui/src/Form/ConfigImportConfirmForm.php
+++ /dev/null
@@ -1,146 +0,0 @@
-configList = $config_list;
- $this->configRevert = $config_update;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config_update.config_list'),
- $container->get('config_update.config_update')
- );
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'config_import_confirm';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getQuestion() {
- if ($this->type == 'system.simple') {
- $type_label = $this->t('Simple configuration');
- }
- else {
- $definition = $this->configList->getType($this->type);
- if (!$definition) {
- // Make a 404 error if the type doesn't exist.
- throw new NotFoundHttpException();
- }
- $type_label = $definition->get('label');
- }
-
- // To import (as opposed to revert), the configuration item must exist in
- // extension storage but not active storage, so check that, and make a 404
- // error if not.
- $extension = $this->configRevert->getFromExtension($this->type, $this->name);
- $active = $this->configRevert->getFromActive($this->type, $this->name);
- if (!$extension || $active) {
- throw new NotFoundHttpException();
- }
-
- return $this->t('Are you sure you want to import the %type config %item from its source configuration?', ['%type' => $type_label, '%item' => $this->name]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getCancelUrl() {
- return new Url('config_update_ui.report');
- }
-
- /**
- * {@inheritdoc}
- */
- public function getDescription() {
- return $this->t('Configuration will be added to your site. This action cannot be undone.');
- }
-
- /**
- * {@inheritdoc}
- */
- public function getConfirmText() {
- return $this->t('Import');
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state, $config_type = NULL, $config_name = NULL) {
- $this->type = $config_type;
- $this->name = $config_name;
-
- $form = parent::buildForm($form, $form_state);
- return $form;
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- $this->configRevert->import($this->type, $this->name);
-
- drupal_set_message($this->t('The configuration was imported from its source.'));
- $form_state->setRedirectUrl($this->getCancelUrl());
- }
-
-}
diff --git a/modules/contrib/config_update/config_update_ui/src/Form/ConfigRevertConfirmForm.php b/modules/contrib/config_update/config_update_ui/src/Form/ConfigRevertConfirmForm.php
deleted file mode 100644
index 9699ba3..0000000
--- a/modules/contrib/config_update/config_update_ui/src/Form/ConfigRevertConfirmForm.php
+++ /dev/null
@@ -1,146 +0,0 @@
-configList = $config_list;
- $this->configRevert = $config_update;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config_update.config_list'),
- $container->get('config_update.config_update')
- );
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'config_update_confirm';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getQuestion() {
- if ($this->type == 'system.simple') {
- $type_label = $this->t('Simple configuration');
- }
- else {
- $definition = $this->configList->getType($this->type);
- if (!$definition) {
- // Make a 404 error if the type doesn't exist.
- throw new NotFoundHttpException();
- }
- $type_label = $definition->get('label');
- }
-
- // To revert (as opposed to import), the configuration item must exist in
- // both active storage and extension storage, so check that and make a 404
- // error if not.
- $extension = $this->configRevert->getFromExtension($this->type, $this->name);
- $active = $this->configRevert->getFromActive($this->type, $this->name);
- if (!$extension || !$active) {
- throw new NotFoundHttpException();
- }
-
- return $this->t('Are you sure you want to revert the %type config %item to its source configuration?', ['%type' => $type_label, '%item' => $this->name]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getCancelUrl() {
- return new Url('config_update_ui.report');
- }
-
- /**
- * {@inheritdoc}
- */
- public function getDescription() {
- return $this->t('Customizations will be lost. This action cannot be undone.');
- }
-
- /**
- * {@inheritdoc}
- */
- public function getConfirmText() {
- return $this->t('Revert');
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state, $config_type = NULL, $config_name = NULL) {
- $this->type = $config_type;
- $this->name = $config_name;
-
- $form = parent::buildForm($form, $form_state);
- return $form;
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- $this->configRevert->revert($this->type, $this->name);
-
- drupal_set_message($this->t('The configuration was reverted to its source.'));
- $form_state->setRedirectUrl($this->getCancelUrl());
- }
-
-}
diff --git a/modules/contrib/config_update/config_update_ui/src/Tests/ConfigProfileOverridesTest.php b/modules/contrib/config_update/config_update_ui/src/Tests/ConfigProfileOverridesTest.php
deleted file mode 100644
index 299ae9c..0000000
--- a/modules/contrib/config_update/config_update_ui/src/Tests/ConfigProfileOverridesTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-adminUser = $this->drupalCreateUser([
- 'access administration pages',
- 'administer themes',
- 'view config updates report',
- 'synchronize configuration',
- 'export configuration',
- 'import configuration',
- 'revert configuration',
- 'delete configuration',
- ]);
- $this->drupalLogin($this->adminUser);
- }
-
- /**
- * Tests that config overrides work as expected.
- */
- public function testConfigOverrides() {
-
- // The Standard install profile contains a system.theme.yml file that
- // sets up bartik/seven as the default/admin theme. The default config
- // from the System module has no admin theme and stark as the default
- // theme. So first, run the report on simple configuration and verify
- // that system.theme is not shown (it should not be missing, or added,
- // or overridden).
- $this->drupalGet('admin/config/development/configuration/report/type/system.simple');
- $this->assertNoRaw('system.theme');
-
- // Go to the Appearance page and change the theme to whatever is currently
- // disabled. Return to the report and verify that system.theme is there,
- // since it is now overridden.
- $this->drupalGet('admin/appearance');
- $this->clickLink('Install and set as default');
- $this->drupalGet('admin/config/development/configuration/report/type/system.simple');
- $this->assertText('system.theme');
-
- // Look at the differences for system.theme and verify it's against
- // the standard profile version, not default version. The line for
- // default should show bartik as the source; if it's against the system
- // version, the word bartik would not be there.
- $this->drupalGet('admin/config/development/configuration/report/diff/system.simple/system.theme');
- $this->assertText('bartik');
-
- // Revert and verify that it reverted to the profile version, not the
- // system module version.
- $this->drupalGet('admin/config/development/configuration/report/revert/system.simple/system.theme');
- $this->drupalPostForm(NULL, [], 'Revert');
- $this->drupalGet('admin/config/development/configuration/single/export/system.simple/system.theme');
- $this->assertText('admin: seven');
- $this->assertText('default: bartik');
- }
-
-}
diff --git a/modules/contrib/config_update/config_update_ui/src/Tests/ConfigUpdateTest.php b/modules/contrib/config_update/config_update_ui/src/Tests/ConfigUpdateTest.php
deleted file mode 100644
index 1ac7aef..0000000
--- a/modules/contrib/config_update/config_update_ui/src/Tests/ConfigUpdateTest.php
+++ /dev/null
@@ -1,521 +0,0 @@
-adminUser = $this->drupalCreateUser([
- 'access administration pages',
- 'administer search',
- 'view config updates report',
- 'synchronize configuration',
- 'export configuration',
- 'import configuration',
- 'revert configuration',
- 'delete configuration',
- 'administer filters',
- ]);
- $this->drupalLogin($this->adminUser);
-
- // Make sure local tasks and page title are showing.
- $this->drupalPlaceBlock('local_tasks_block');
- $this->drupalPlaceBlock('page_title_block');
-
- // Load the Drush include file so that its functions can be tested, plus
- // the Drush testing include file.
- module_load_include('inc', 'config_update_ui', 'config_update_ui.drush_testing');
- module_load_include('inc', 'config_update_ui', 'config_update_ui.drush');
- }
-
- /**
- * Tests the config report and its linked pages.
- */
- public function testConfigReport() {
- // Test links to report page.
- $this->drupalGet('admin/config/development/configuration');
- $this->clickLink('Updates report');
- $this->assertNoReport();
-
- // Verify the Drush list types command.
- $output = implode("\n", drush_config_update_ui_config_list_types());
- $this->assertTrue(strpos($output, 'search_page') !== FALSE);
- $this->assertTrue(strpos($output, 'node_type') !== FALSE);
- $this->assertTrue(strpos($output, 'user_role') !== FALSE);
- $this->assertTrue(strpos($output, 'block') !== FALSE);
-
- // Verify some empty reports.
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], []);
- $this->assertDrushReports('type', 'search_page', [], [], [], []);
-
- // Module, theme, and profile reports have no 'added' section.
- $this->drupalGet('admin/config/development/configuration/report/module/search');
- $this->assertReport('Search module', [], [], [], [], ['added']);
- $this->assertDrushReports('module', 'search', [], [], [], []);
- $this->drupalGet('admin/config/development/configuration/report/theme/classy');
- $this->assertReport('Classy theme', [], [], [], [], ['added']);
- $this->assertDrushReports('theme', 'classy', [], [], [], []);
-
- $inactive = ['locale.settings' => 'Simple configuration'];
- $this->drupalGet('admin/config/development/configuration/report/profile');
- $this->assertReport('Testing profile', [], [], [], $inactive, ['added']);
- // The locale.settings line should show that the Testing profile is the
- // provider.
- $this->assertText('Testing profile');
- $this->assertDrushReports('profile', '', [], [], [], array_keys($inactive));
-
- // Verify that the user search page cannot be imported (because it already
- // exists).
- $this->drupalGet('admin/config/development/configuration/report/import/search_page/user_search');
- $this->assertResponse(404);
-
- // Delete the user search page from the search UI and verify report for
- // both the search page config type and user module.
- $this->drupalGet('admin/config/search/pages');
- $this->clickLink('Delete');
- $this->drupalPostForm(NULL, [], 'Delete');
- $inactive = ['search.page.user_search' => 'Users'];
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], $inactive);
- // The search.page.user_search line should show that the User module is the
- // provider.
- $this->assertText('User module');
- $this->assertDrushReports('type', 'search_page', [], [], [], array_keys($inactive));
-
- $this->drupalGet('admin/config/development/configuration/report/module/user');
- $this->assertReport('User module', [], [], [], $inactive, ['added', 'changed']);
- $this->assertDrushReports('module', 'user', [], [], [],
- [
- 'rdf.mapping.user.user',
- 'search.page.user_search',
- 'views.view.user_admin_people',
- 'views.view.who_s_new',
- 'views.view.who_s_online',
- ], ['changed']);
-
- // Verify that the user search page cannot be reverted (because it does
- // not already exist).
- $this->drupalGet('admin/config/development/configuration/report/revert/search_page/user_search');
- $this->assertResponse(404);
- // Verify that the delete URL doesn't work either.
- $this->drupalGet('admin/config/development/configuration/report/delete/search_page/user_search');
- $this->assertResponse(404);
-
- // Use the import link to get it back. Do this from the search page
- // report to make sure we are importing the right config.
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->clickLink('Import from source');
- $this->drupalPostForm(NULL, [], 'Import');
- $this->assertText('The configuration was imported');
- $this->assertNoReport();
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], []);
- $this->assertDrushReports('type', 'search_page', [], [], [], []);
-
- // Verify that after import, there is no config hash generated.
- $this->drupalGet('admin/config/development/configuration/single/export/search_page/user_search');
- $this->assertText('id: user_search');
- $this->assertNoText('default_config_hash:');
-
- // Test importing again, this time using the Drush import command.
- $this->drupalGet('admin/config/search/pages');
- $this->clickLink('Delete');
- $this->drupalPostForm(NULL, [], 'Delete');
- $inactive = ['search.page.user_search' => 'Users'];
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], $inactive);
- drush_config_update_ui_config_import_missing('search.page.user_search');
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], []);
-
- // Edit the node search page from the search UI and verify report.
- $this->drupalGet('admin/config/search/pages');
- $this->clickLink('Edit');
- $this->drupalPostForm(NULL, [
- 'label' => 'New label',
- 'path' => 'new_path',
- ], 'Save search page');
- $changed = ['search.page.node_search' => 'New label'];
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], $changed, []);
- $this->assertDrushReports('type', 'search_page', [], [], array_keys($changed), []);
-
- // Test the show differences link.
- $this->clickLink('Show differences');
- $this->assertText('Content');
- $this->assertText('New label');
- $this->assertText('node');
- $this->assertText('new_path');
-
- // Test the show differences Drush command.
- $output = drush_config_update_ui_config_diff('search.page.node_search');
- $this->assertTrue(strpos($output, 'Content') !== FALSE);
- $this->assertTrue(strpos($output, 'New label') !== FALSE);
- $this->assertTrue(strpos($output, 'node') !== FALSE);
- $this->assertTrue(strpos($output, 'new_path') !== FALSE);
-
- // Test the Back link.
- $this->clickLink("Back to 'Updates report' page.");
- $this->assertNoReport();
-
- // Test the export link.
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->clickLink('Export');
- $this->assertText('Here is your configuration:');
- $this->assertText('id: node_search');
- $this->assertText('New label');
- $this->assertText('path: new_path');
- $this->assertText('search.page.node_search.yml');
-
- // Grab the uuid and hash lines for the next test.
- $text = $this->getTextContent();
- $matches = [];
- preg_match('|^.*uuid:.*$|m', $text, $matches);
- $uuid_line = $matches[0];
- preg_match('|^.*default_config_hash:.*$|m', $text, $matches);
- $hash_line = $matches[0];
-
- // Test reverting.
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->clickLink('Revert to source');
- $this->assertText('Are you sure you want to revert');
- $this->assertText('Search page');
- $this->assertText('node_search');
- $this->assertText('Customizations will be lost. This action cannot be undone');
- $this->drupalPostForm(NULL, [], 'Revert');
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], []);
-
- // Verify that the uuid and hash keys were retained in the revert.
- $this->drupalGet('admin/config/development/configuration/single/export/search_page/node_search');
- $this->assertText('id: node_search');
- $this->assertText($uuid_line);
- $this->assertText($hash_line);
-
- // Test reverting again, this time using Drush single revert command.
- $this->drupalGet('admin/config/search/pages');
- $this->clickLink('Edit');
- $this->drupalPostForm(NULL, [
- 'label' => 'New label',
- 'path' => 'new_path',
- ], 'Save search page');
- $changed = ['search.page.node_search' => 'New label'];
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], $changed, []);
- drush_config_update_ui_config_revert('search.page.node_search');
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], []);
-
- // Test reverting again, this time using Drush multiple revert command.
- $this->drupalGet('admin/config/search/pages');
- $this->clickLink('Edit');
- $this->drupalPostForm(NULL, [
- 'label' => 'New label',
- 'path' => 'new_path',
- ], 'Save search page');
- $changed = ['search.page.node_search' => 'New label'];
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], $changed, []);
- drush_config_update_ui_config_revert_multiple('type', 'search_page');
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], []);
-
- // Add a new search page from the search UI and verify report.
- $this->drupalPostForm('admin/config/search/pages', [
- 'search_type' => 'node_search',
- ], 'Add search page');
- $this->drupalPostForm(NULL, [
- 'label' => 'test',
- 'id' => 'test',
- 'path' => 'test',
- ], 'Save');
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $added = ['search.page.test' => 'test'];
- $this->assertReport('Search page', [], $added, [], []);
- $this->assertDrushReports('type', 'search_page', [], array_keys($added), [], []);
-
- // Test the export link.
- $this->clickLink('Export');
- $this->assertText('Here is your configuration:');
- $this->assertText('id: test');
- $this->assertText('label: test');
- $this->assertText('path: test');
- $this->assertText('search.page.test.yml');
-
- // Test the delete link.
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->clickLink('Delete');
- $this->assertText('Are you sure');
- $this->assertText('cannot be undone');
- $this->drupalPostForm(NULL, [], 'Delete');
- $this->assertText('The configuration was deleted');
-
- // And verify the report again.
- $this->drupalGet('admin/config/development/configuration/report/type/search_page');
- $this->assertReport('Search page', [], [], [], []);
-
- // Change the search module config and verify the actions work for
- // simple config.
- $this->drupalPostForm('admin/config/search/pages', [
- 'minimum_word_size' => 4,
- ], 'Save configuration');
- $changed = ['search.settings' => 'search.settings'];
- $this->drupalGet('admin/config/development/configuration/report/module/search');
- $this->assertReport('Search module', [], [], $changed, [], ['added']);
-
- $this->clickLink('Show differences');
- $this->assertText('Config difference for Simple configuration search.settings');
- $this->assertText('index::minimum_word_size');
- $this->assertText('4');
-
- $this->drupalGet('admin/config/development/configuration/report/module/search');
- $this->clickLink('Export');
- $this->assertText('minimum_word_size: 4');
- // Grab the hash line for the next test.
- $text = $this->getTextContent();
- $matches = [];
- preg_match('|^.*default_config_hash:.*$|m', $text, $matches);
- $hash_line = $matches[0];
-
- $this->drupalGet('admin/config/development/configuration/report/module/search');
- $this->clickLink('Revert to source');
- $this->drupalPostForm(NULL, [], 'Revert');
-
- // Verify that the hash was retained in the revert.
- $this->drupalGet('admin/config/development/configuration/single/export/system.simple/search.settings');
- $this->assertText($hash_line);
-
- $this->drupalGet('admin/config/development/configuration/report/module/search');
- $this->assertReport('Search module', [], [], [], [], ['added']);
-
- // Edit the plain_text filter from the filter UI and verify report.
- // The filter_format config type uses a label key other than 'label'.
- $this->drupalPostForm('admin/config/content/formats/manage/plain_text', [
- 'name' => 'New label',
- ], 'Save configuration');
- $changed = ['filter.format.plain_text' => 'New label'];
- $this->drupalGet('admin/config/development/configuration/report/type/filter_format');
- $this->assertReport('Text format', [], [], $changed, []);
- }
-
- /**
- * Asserts that the report page has the correct content.
- *
- * Assumes you are already on the report page.
- *
- * @param string $title
- * Report title to check for.
- * @param string[] $missing
- * Array of items that should be listed as missing, name => label.
- * @param string[] $added
- * Array of items that should be listed as added, name => label.
- * @param string[] $changed
- * Array of items that should be listed as changed, name => label.
- * @param string[] $inactive
- * Array of items that should be listed as inactive, name => label.
- * @param string[] $skip
- * Array of report sections to skip checking.
- */
- protected function assertReport($title, array $missing, array $added, array $changed, array $inactive, array $skip = []) {
- $this->assertText('Configuration updates report for ' . $title);
- $this->assertText('Generate new report');
-
- if (!in_array('missing', $skip)) {
- $this->assertText('Missing configuration items');
- if (count($missing)) {
- foreach ($missing as $name => $label) {
- $this->assertText($name);
- $this->assertText($label);
- }
- $this->assertNoText('None: all provided configuration items are in your active configuration.');
- }
- else {
- $this->assertText('None: all provided configuration items are in your active configuration.');
- }
- }
-
- if (!in_array('inactive', $skip)) {
- $this->assertText('Inactive optional items');
- if (count($inactive)) {
- foreach ($inactive as $name => $label) {
- $this->assertText($name);
- $this->assertText($label);
- }
- $this->assertNoText('None: all optional configuration items are in your active configuration.');
- }
- else {
- $this->assertText('None: all optional configuration items are in your active configuration.');
- }
- }
-
- if (!in_array('added', $skip)) {
- $this->assertText('Added configuration items');
- if (count($added)) {
- foreach ($added as $name => $label) {
- $this->assertText($name);
- $this->assertText($label);
- }
- $this->assertNoText('None: all active configuration items of this type were provided by modules, themes, or install profile.');
- }
- else {
- $this->assertText('None: all active configuration items of this type were provided by modules, themes, or install profile.');
- }
- }
-
- if (!in_array('changed', $skip)) {
- $this->assertText('Changed configuration items');
- if (count($changed)) {
- foreach ($changed as $name => $label) {
- $this->assertText($name);
- $this->assertText($label);
- }
- $this->assertNoText('None: no active configuration items differ from their current provided versions.');
- }
- else {
- $this->assertText('None: no active configuration items differ from their current provided versions.');
- }
- }
- }
-
- /**
- * Asserts that the Drush reports have the correct content.
- *
- * @param string $type
- * Type of report to run (type, module, theme, etc.).
- * @param string $name
- * Name of that type to run (e.g., module machine name).
- * @param string[] $missing
- * Array of config items that should be listed as missing.
- * @param string[] $added
- * Array of config items that should be listed as added.
- * @param string[] $changed
- * Array of config items that should be listed as changed.
- * @param string[] $inactive
- * Array of config items that should be listed as inactive.
- * @param string[] $skip
- * Array of report sections to skip checking.
- */
- protected function assertDrushReports($type, $name, array $missing, array $added, array $changed, array $inactive, array $skip = []) {
- if (!in_array('missing', $skip)) {
- $output = drush_config_update_ui_config_missing_report($type, $name);
- $this->assertEqual(count($output), count($missing), 'Drush missing report has correct number of items');
- if (count($missing)) {
- foreach ($missing as $item) {
- $this->assertTrue(in_array($item, $output), "Item $item is in the Drush missing report");
- }
- }
- }
-
- if (!in_array('added', $skip) && $type == 'type') {
- $output = drush_config_update_ui_config_added_report($name);
- $this->assertEqual(count($output), count($added), 'Drush added report has correct number of items');
- if (count($added)) {
- foreach ($added as $item) {
- $this->assertTrue(in_array($item, $output), "Item $item is in the Drush added report");
- }
- }
- }
-
- if (!in_array('changed', $skip)) {
- $output = drush_config_update_ui_config_different_report($type, $name);
- $this->assertEqual(count($output), count($changed), 'Drush changed report has correct number of items');
- if (count($changed)) {
- foreach ($changed as $item) {
- $this->assertTrue(in_array($item, $output), "Item $item is in the Drush changed report");
- }
- }
- }
-
- if (!in_array('inactive', $skip)) {
- $output = drush_config_update_ui_config_inactive_report($type, $name);
- $this->assertEqual(count($output), count($inactive), 'Drush inactive report has correct number of items');
- if (count($inactive)) {
- foreach ($inactive as $item) {
- $this->assertTrue(in_array($item, $output), "Item $item is in the Drush inactive report");
- }
- }
- }
- }
-
- /**
- * Asserts that the report is not shown.
- *
- * Assumes you are already on the report form page.
- */
- protected function assertNoReport() {
- $this->assertText('Report type');
- $this->assertText('Full report');
- $this->assertText('Single configuration type');
- $this->assertText('Single module');
- $this->assertText('Single theme');
- $this->assertText('Installation profile');
- $this->assertText('Updates report');
- $this->assertNoText('Missing configuration items');
- $this->assertNoText('Added configuration items');
- $this->assertNoText('Changed configuration items');
- $this->assertNoText('Unchanged configuration items');
-
- // Verify that certain report links are shown or not shown. For extensions,
- // only extensions that have configuration should be shown.
- // Modules.
- $this->assertLink('Search');
- $this->assertLink('Field');
- $this->assertNoLink('Configuration Update Base');
- $this->assertNoLink('Configuration Update Reports');
-
- // Themes.
- $this->assertNoLink('Stark');
- $this->assertNoLink('Classy');
-
- // Profiles.
- $this->assertLink('Testing');
-
- // Configuration types.
- $this->assertLink('Everything');
- $this->assertLink('Simple configuration');
- $this->assertLink('Search page');
- }
-
-}
diff --git a/modules/contrib/config_update/src/ConfigDeleteInterface.php b/modules/contrib/config_update/src/ConfigDeleteInterface.php
deleted file mode 100644
index 6708850..0000000
--- a/modules/contrib/config_update/src/ConfigDeleteInterface.php
+++ /dev/null
@@ -1,37 +0,0 @@
-stringTranslation = $translation;
- $this->hierarchyPrefix = $hierarchy_prefix;
- $this->valuePrefix = $value_prefix;
- $this->ignore = $ignore;
- }
-
- /**
- * Normalizes config for comparison.
- *
- * Recursively removes elements in the ignore list from configuration,
- * as well as empty array values, and sorts at each level by array key, so
- * that config from different storage can be compared meaningfully.
- *
- * @param array|null $config
- * Configuration array to normalize.
- *
- * @return array
- * Normalized configuration array.
- *
- * @see ConfigDiffer::format()
- * @see ConfigDiffer::$ignore
- */
- protected function normalize($config) {
- if (empty($config)) {
- return [];
- }
-
- // Remove "ignore" elements.
- foreach ($this->ignore as $element) {
- unset($config[$element]);
- }
-
- // Recursively normalize remaining elements, if they are arrays.
- foreach ($config as $key => $value) {
- if (is_array($value)) {
- $new = $this->normalize($value);
- if (count($new)) {
- $config[$key] = $new;
- }
- else {
- unset($config[$key]);
- }
- }
- }
-
- // Sort and return.
- ksort($config);
- return $config;
- }
-
- /**
- * {@inheritdoc}
- */
- public function same($source, $target) {
- $source = $this->normalize($source);
- $target = $this->normalize($target);
- return $source === $target;
- }
-
- /**
- * Formats config for showing differences.
- *
- * To compute differences, we need to separate the config into lines and use
- * line-by-line differencer. The obvious way to split into lines is:
- * @code
- * explode("\n", Yaml::encode($config))
- * @endcode
- * But this would highlight meaningless differences due to the often different
- * order of config files, and also loses the indentation and context of the
- * config hierarchy when differences are computed, making the difference
- * difficult to interpret.
- *
- * So, what we do instead is to take the YAML hierarchy and format it so that
- * the hierarchy is shown on each line. So, if you're in element
- * $config['foo']['bar'] and the value is 'value', you will see
- * 'foo::bar : value'.
- *
- * @param array $config
- * Config array to format. Normalize it first if you want to do diffs.
- * @param string $prefix
- * (optional) When called recursively, the prefix to put on each line. Omit
- * when initially calling this function.
- *
- * @return string[]
- * Array of config lines formatted so that a line-by-line diff will show the
- * context in each line, and meaningful differences will be computed.
- *
- * @see ConfigDiffer::normalize()
- * @see ConfigDiffer::$hierarchyPrefix
- * @see ConfigDiffer::$valuePrefix
- */
- protected function format(array $config, $prefix = '') {
- $lines = [];
-
- foreach ($config as $key => $value) {
- $section_prefix = ($prefix) ? $prefix . $this->hierarchyPrefix . $key : $key;
-
- if (is_array($value)) {
- $lines[] = $section_prefix;
- $newlines = $this->format($value, $section_prefix);
- foreach ($newlines as $line) {
- $lines[] = $line;
- }
- }
- elseif (is_null($value)) {
- $lines[] = $section_prefix . $this->valuePrefix . $this->t('(NULL)');
- }
- else {
- $lines[] = $section_prefix . $this->valuePrefix . $value;
- }
- }
-
- return $lines;
- }
-
- /**
- * {@inheritdoc}
- */
- public function diff($source, $target) {
- $source = $this->normalize($source);
- $target = $this->normalize($target);
-
- $source_lines = $this->format($source);
- $target_lines = $this->format($target);
-
- return new Diff($source_lines, $target_lines);
- }
-
-}
diff --git a/modules/contrib/config_update/src/ConfigListByProviderInterface.php b/modules/contrib/config_update/src/ConfigListByProviderInterface.php
deleted file mode 100644
index 42ff515..0000000
--- a/modules/contrib/config_update/src/ConfigListByProviderInterface.php
+++ /dev/null
@@ -1,37 +0,0 @@
-entityManager = $entity_manager;
- $this->activeConfigStorage = $active_config_storage;
- $this->extensionConfigStorage = $extension_config_storage;
- $this->extensionOptionalConfigStorage = $extension_optional_config_storage;
- }
-
- /**
- * Sets up and returns the entity definitions list.
- */
- public function listTypes() {
- // Return list if it has already been calculated.
- if (count($this->definitions)) {
- return $this->definitions;
- }
-
- // Calculate and return the list.
- foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
- if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
- $this->definitions[$entity_type] = $definition;
- $prefix = $definition->getConfigPrefix();
- $this->typesByPrefix[$prefix] = $entity_type;
- }
- }
-
- ksort($this->definitions);
-
- return $this->definitions;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getType($name) {
- $definitions = $this->listTypes();
- return isset($definitions[$name]) ? $definitions[$name] : NULL;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getTypeByPrefix($prefix) {
- $definitions = $this->listTypes();
- return isset($this->typesByPrefix[$prefix]) ? $definitions[$this->typesByPrefix[$prefix]] : NULL;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getTypeNameByConfigName($name) {
- $definitions = $this->listTypes();
- foreach ($this->typesByPrefix as $prefix => $entity_type) {
- if (strpos($name, $prefix . '.') === 0) {
- return $entity_type;
- }
- }
-
- return NULL;
- }
-
- /**
- * {@inheritdoc}
- */
- public function listConfig($list_type, $name) {
- $active_list = [];
- $install_list = [];
- $optional_list = [];
- $definitions = $this->listTypes();
-
- switch ($list_type) {
- case 'type':
- if ($name == 'system.all') {
- $active_list = $this->activeConfigStorage->listAll();
- $install_list = $this->extensionConfigStorage->listAll();
- $optional_list = $this->extensionOptionalConfigStorage->listAll();
- }
- elseif ($name == 'system.simple') {
- // Listing is done by prefixes, and simple config doesn't have one.
- // So list all and filter out all known prefixes.
- $active_list = $this->omitKnownPrefixes($this->activeConfigStorage->listAll());
- $install_list = $this->omitKnownPrefixes($this->extensionConfigStorage->listAll());
- $optional_list = $this->omitKnownPrefixes($this->extensionOptionalConfigStorage->listAll());
- }
- elseif (isset($this->definitions[$name])) {
- $definition = $this->definitions[$name];
- $prefix = $definition->getConfigPrefix();
- $active_list = $this->activeConfigStorage->listAll($prefix);
- $install_list = $this->extensionConfigStorage->listAll($prefix);
- $optional_list = $this->extensionOptionalConfigStorage->listAll($prefix);
- }
- break;
-
- case 'profile':
- $name = $this->getProfileName();
- // Intentional fall-through here to the 'module' or 'theme' case.
- case 'module':
- case 'theme':
- $active_list = $this->activeConfigStorage->listAll();
- $install_list = $this->listProvidedItems($list_type, $name);
- $optional_list = $this->listProvidedItems($list_type, $name, TRUE);
- break;
- }
-
- // This only seems to be a problem in unit tests, where a mock object
- // is returning NULL instead of an empy array for some reason.
- if (!is_array($optional_list)) {
- $optional_list = [];
- }
-
- return [$active_list, $install_list, $optional_list];
- }
-
- /**
- * Returns a list of the install storage items for an extension.
- *
- * @param string $type
- * Type of extension ('module', etc.).
- * @param string $name
- * Machine name of extension.
- * @param bool $do_optional
- * FALSE (default) to list config/install items, TRUE to list
- * config/optional items.
- *
- * @return string[]
- * List of config items provided by this extension.
- */
- protected function listProvidedItems($type, $name, $do_optional = FALSE) {
- $pathname = drupal_get_filename($type, $name);
- $component = new Extension(\Drupal::root(), $type, $pathname);
- if ($do_optional) {
- $names = $this->extensionOptionalConfigStorage->getComponentNames([$component]);
- }
- else {
- $names = $this->extensionConfigStorage->getComponentNames([$component]);
- }
- return array_keys($names);
- }
-
- /**
- * Omits config with known prefixes from a list of config names.
- */
- protected function omitKnownPrefixes($list) {
- $prefixes = array_keys($this->typesByPrefix);
- $list = array_combine($list, $list);
- foreach ($list as $name) {
- foreach ($prefixes as $prefix) {
- if (strpos($name, $prefix . '.') === 0) {
- unset($list[$name]);
- }
- }
- }
-
- return array_values($list);
- }
-
- /**
- * Returns the name of the install profile.
- *
- * For backwards compatibility with pre/post 8.3.x, tries to get it from
- * either configuration or settings.
- *
- * @return string
- * The name of the install profile.
- */
- protected function getProfileName() {
- // Code adapted from DrupalKernel::getInstalProfile() in Core.
- // In Core 8.3.x or later, read from config.
- $config = $this->activeConfigStorage->read('core.extension');
- if (!empty($config['profile'])) {
- return $config['profile'];
- }
- else {
- // If system_update_8300() has not yet run, use settings.
- return Settings::get('install_profile');
- }
- }
-
-}
diff --git a/modules/contrib/config_update/src/ConfigListerWithProviders.php b/modules/contrib/config_update/src/ConfigListerWithProviders.php
deleted file mode 100644
index 5c50c98..0000000
--- a/modules/contrib/config_update/src/ConfigListerWithProviders.php
+++ /dev/null
@@ -1,148 +0,0 @@
-entityManager = $entity_manager;
- $this->activeConfigStorage = $active_config_storage;
- $this->extensionConfigStorage = $extension_config_storage;
- $this->extensionOptionalConfigStorage = $extension_optional_config_storage;
- $this->moduleHandler = $module_handler;
- $this->themeHandler = $theme_handler;
- }
-
- /**
- * Sets up and returns the config providers list.
- */
- public function listProviders() {
- // Return the list if it has already been set up.
- if (count($this->providers)) {
- return $this->providers;
- }
-
- // Calculate if it hasn't been set up yet.
- // List all of the profile, modules, and themes.
- $extensionsToDo = [];
- $profile = $this->getProfileName();
- $extensionsToDo[] = ['profile', $profile];
- $modules = $this->moduleHandler->getModuleList();
- foreach ($modules as $machine_name => $module) {
- if ($machine_name != $profile) {
- $extensionsToDo[] = ['module', $machine_name];
- }
- }
-
- $themes = $this->themeHandler->listInfo();
- foreach ($themes as $machine_name => $theme) {
- $extensionsToDo[] = ['theme', $machine_name];
- }
-
- // For each extension, figure out if it has config, and make an index of
- // config item => provider.
- $this->extensionsWithConfig = [
- 'profile' => [],
- 'module' => [],
- 'theme' => [],
- ];
-
- foreach ($extensionsToDo as $item) {
- $type = $item[0];
- $name = $item[1];
- $configs = array_merge($this->listProvidedItems($type, $name),
- $this->listProvidedItems($type, $name, TRUE));
- if (!empty($configs)) {
- $this->extensionsWithConfig[$type][$name] = $name;
- foreach ($configs as $config) {
- $this->providers[$config] = [$type, $name];
- }
- }
- }
-
- return $this->providers;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getConfigProvider($name) {
- $providers = $this->listProviders();
-
- return (isset($providers[$name])) ? $providers[$name] : NULL;
- }
-
- /**
- * {@inheritdoc}
- */
- public function providerHasConfig($type, $name) {
- // Make sure the list of extensions with configuration has been generated.
- $this->listProviders();
-
- return isset($this->extensionsWithConfig[$type][$name]);
- }
-
-}
diff --git a/modules/contrib/config_update/src/ConfigRevertEvent.php b/modules/contrib/config_update/src/ConfigRevertEvent.php
deleted file mode 100644
index 90944a1..0000000
--- a/modules/contrib/config_update/src/ConfigRevertEvent.php
+++ /dev/null
@@ -1,66 +0,0 @@
-type = $type;
- $this->name = $name;
- }
-
- /**
- * Returns the type of configuration being imported or reverted.
- *
- * @return string
- * The type of configuration, either 'system.simple' or a config entity
- * type machine name.
- */
- public function getType() {
- return $this->type;
- }
-
- /**
- * Returns the name of the config item, without prefix.
- *
- * @return string
- * The name of the config item being imported/reverted/deleted, with the
- * prefix.
- */
- public function getName() {
- return $this->name;
- }
-
-}
diff --git a/modules/contrib/config_update/src/ConfigRevertInterface.php b/modules/contrib/config_update/src/ConfigRevertInterface.php
deleted file mode 100644
index 18e03fa..0000000
--- a/modules/contrib/config_update/src/ConfigRevertInterface.php
+++ /dev/null
@@ -1,96 +0,0 @@
-entityManager = $entity_manager;
- $this->activeConfigStorage = $active_config_storage;
- $this->extensionConfigStorage = $extension_config_storage;
- $this->extensionOptionalConfigStorage = $extension_optional_config_storage;
- $this->configFactory = $config_factory;
- $this->dispatcher = $dispatcher;
- }
-
- /**
- * {@inheritdoc}
- */
- public function import($type, $name) {
- // Read the config from the file.
- $full_name = $this->getFullName($type, $name);
- $value = $this->extensionConfigStorage->read($full_name);
- if (!$value) {
- $value = $this->extensionOptionalConfigStorage->read($full_name);
- }
- if (!$value) {
- return FALSE;
- }
-
- // Save it as a new config entity or simple config.
- if ($type == 'system.simple') {
- $this->configFactory->getEditable($full_name)->setData($value)->save();
- }
- else {
- $entity_storage = $this->entityManager->getStorage($type);
- $entity = $entity_storage->createFromStorageRecord($value);
- $entity->save();
- }
-
- // Trigger an event notifying of this change.
- $event = new ConfigRevertEvent($type, $name);
- $this->dispatcher->dispatch(ConfigRevertInterface::IMPORT, $event);
-
- return TRUE;
- }
-
- /**
- * {@inheritdoc}
- */
- public function revert($type, $name) {
- // Read the config from the file.
- $full_name = $this->getFullName($type, $name);
- $value = $this->extensionConfigStorage->read($full_name);
- if (!$value) {
- $value = $this->extensionOptionalConfigStorage->read($full_name);
- }
- if (!$value) {
- return FALSE;
- }
-
- if ($type == 'system.simple') {
- // Load the current config and replace the value, retaining the config
- // hash (which is part of the _core config key's value).
- $config = $this->configFactory->getEditable($full_name);
- $core = $config->get('_core');
- $config->setData($value);
- $config->set('_core', $core);
- $config->save();
- }
- else {
- // Load the current config entity and replace the value. Note that
- // the uuid and _core/hash values are retained for entity-based config,
- // since updateFromStorageRecord() only updates values that are part of
- // the passed-in array, and doesn't remove or alter other values.
- $definition = $this->entityManager->getDefinition($type);
- $id_key = $definition->getKey('id');
- $id = $value[$id_key];
- $entity_storage = $this->entityManager->getStorage($type);
- $entity = $entity_storage->load($id);
- $entity = $entity_storage->updateFromStorageRecord($entity, $value);
- $entity->save();
- }
-
- // Trigger an event notifying of this change.
- $event = new ConfigRevertEvent($type, $name);
- $this->dispatcher->dispatch(ConfigRevertInterface::REVERT, $event);
-
- return TRUE;
- }
-
- /**
- * {@inheritdoc}
- */
- public function delete($type, $name) {
- $full_name = $this->getFullName($type, $name);
- if (!$full_name) {
- return FALSE;
- }
- $config = $this->configFactory->getEditable($full_name);
- if (!$config) {
- return FALSE;
- }
- $config->delete();
-
- // Trigger an event notifying of this change.
- $event = new ConfigRevertEvent($type, $name);
- $this->dispatcher->dispatch(ConfigDeleteInterface::DELETE, $event);
- return TRUE;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFromActive($type, $name) {
- $full_name = $this->getFullName($type, $name);
- return $this->activeConfigStorage->read($full_name);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFromExtension($type, $name) {
- $full_name = $this->getFullName($type, $name);
- $value = $this->extensionConfigStorage->read($full_name);
- if (!$value) {
- $value = $this->extensionOptionalConfigStorage->read($full_name);
- }
- return $value;
- }
-
- /**
- * Returns the full name of a config item.
- *
- * @param string $type
- * The config type, or '' to indicate $name is already prefixed.
- * @param string $name
- * The config name, without prefix.
- *
- * @return string
- * The config item's full name.
- */
- protected function getFullName($type, $name) {
- if ($type == 'system.simple' || !$type) {
- return $name;
- }
-
- $definition = $this->entityManager->getDefinition($type);
- $prefix = $definition->getConfigPrefix() . '.';
- return $prefix . $name;
- }
-
-}
diff --git a/modules/contrib/config_update/tests/src/Unit/ConfigDifferTest.php b/modules/contrib/config_update/tests/src/Unit/ConfigDifferTest.php
deleted file mode 100644
index 9b2ad57..0000000
--- a/modules/contrib/config_update/tests/src/Unit/ConfigDifferTest.php
+++ /dev/null
@@ -1,308 +0,0 @@
-stringTranslation = $this->getMockBuilder('Drupal\Core\StringTranslation\TranslationInterface')->getMock();
- $this->stringTranslation
- ->method('t')
- ->will($this->returnArgument(0));
-
- $this->configDiffer = new ConfigDiffer($this->stringTranslation);
- }
-
- /**
- * @covers \Drupal\config_update\ConfigDiffer::same
- * @dataProvider sameProvider
- */
- public function testSame($a, $b, $expected) {
- $this->assertEquals($expected, $this->configDiffer->same($a, $b));
- }
-
- /**
- * Data provider for self:testSame().
- */
- public function sameProvider() {
- $base = [
- 'uuid' => 'bar',
- 'a' => 'a',
- 'b' => 0,
- 'c' => [
- 'd' => TRUE,
- 'e' => FALSE,
- ],
- ];
-
- return [
- [$base, $base, TRUE],
-
- // Add _core, omit uuid. Should match.
- [
- $base,
- [
- '_core' => 'foo',
- 'a' => 'a',
- 'b' => 0,
- 'c' => [
- 'd' => TRUE,
- 'e' => FALSE,
- ],
- ],
- TRUE,
- ],
-
- // Change order. Should match.
- [
- $base,
- [
- 'a' => 'a',
- 'uuid' => 'bar',
- 'b' => 0,
- 'c' => [
- 'd' => TRUE,
- 'e' => FALSE,
- ],
- ],
- TRUE,
- ],
-
- // Change order and add _core in deeper level. Should match.
- [
- $base,
- [
- 'uuid' => 'bar',
- 'a' => 'a',
- 'b' => 0,
- 'c' => [
- 'e' => FALSE,
- '_core' => 'foo',
- 'd' => TRUE,
- ],
- ],
- TRUE,
- ],
-
- // Omit a component. Should not match.
- [
- $base,
- [
- 'uuid' => 'bar',
- 'a' => 'a',
- 'c' => [
- 'd' => TRUE,
- 'e' => FALSE,
- ],
- ],
- FALSE,
- ],
-
- // Add a component. Should not match.
- [
- $base,
- [
- 'uuid' => 'bar',
- 'a' => 'a',
- 'b' => 0,
- 'c' => [
- 'd' => TRUE,
- 'e' => FALSE,
- ],
- 'f' => 'f',
- ],
- FALSE,
- ],
-
- // 0 should not match a string.
- [
- $base,
- [
- '_core' => 'foo',
- 'uuid' => 'bar',
- 'a' => 'a',
- 'b' => 'b',
- 'c' => [
- 'd' => TRUE,
- 'e' => FALSE,
- ],
- ],
- FALSE,
- ],
-
- // FALSE should not match a string.
- [
- $base,
- [
- '_core' => 'foo',
- 'uuid' => 'bar',
- 'a' => 'a',
- 'b' => 0,
- 'c' => [
- 'd' => TRUE,
- 'e' => 'e',
- ],
- ],
- FALSE,
- ],
-
- // TRUE should not match a string.
- [
- $base,
- [
- '_core' => 'foo',
- 'uuid' => 'bar',
- 'a' => 'a',
- 'b' => 0,
- 'c' => [
- 'd' => 'd',
- 'e' => FALSE,
- ],
- ],
- FALSE,
- ],
- ];
- }
-
- /**
- * @covers \Drupal\config_update\ConfigDiffer::diff
- */
- public function testDiff() {
- $configOne = [
- 'uuid' => '1234-5678-90',
- 'id' => 'test.config.id',
- 'id_to_remove' => 'test.remove.id',
- 'type' => 'old_type',
- 'true_value' => TRUE,
- 'nested_array' => [
- 'flat_array' => [
- 'value2',
- 'value1',
- 'value3',
- ],
- 'custom_key' => 'value',
- ],
- ];
-
- $configTwo = [
- 'uuid' => '09-8765-4321',
- 'id' => 'test.config.id',
- 'type' => 'new_type',
- 'true_value' => FALSE,
- 'nested_array' => [
- 'flat_array' => [
- 'value2',
- 'value3',
- ],
- 'custom_key' => 'value',
- 'custom_key_2' => 'value2',
- ],
- ];
-
- $edits = $this->configDiffer->diff($configOne, $configTwo)->getEdits();
-
- $expectedEdits = [
- [
- 'copy' => [
- 'orig' => [
- 'id : test.config.id',
- ],
- 'closing' => [
- 'id : test.config.id',
- ],
- ],
- ],
- [
- 'delete' => [
- 'orig' => [
- 'id_to_remove : test.remove.id',
- ],
- 'closing' => FALSE,
- ],
- ],
- [
- 'copy' => [
- 'orig' => [
- 'nested_array',
- 'nested_array::custom_key : value',
- ],
- 'closing' => [
- 'nested_array',
- 'nested_array::custom_key : value',
- ],
- ],
- ],
- [
- 'add' => [
- 'orig' => FALSE,
- 'closing' => [
- 'nested_array::custom_key_2 : value2',
- ],
- ],
- ],
- [
- 'copy' => [
- 'orig' => [
- 'nested_array::flat_array',
- 'nested_array::flat_array::0 : value2',
- ],
- 'closing' => [
- 'nested_array::flat_array',
- 'nested_array::flat_array::0 : value2',
- ],
- ],
- ],
- [
- 'change' => [
- 'orig' => [
- 'nested_array::flat_array::1 : value1',
- 'nested_array::flat_array::2 : value3',
- 'true_value : 1',
- 'type : old_type',
- ],
- 'closing' => [
- 'nested_array::flat_array::1 : value3',
- 'true_value : ',
- 'type : new_type',
- ],
- ],
- ],
- ];
-
- $this->assertEquals(count($expectedEdits), count($edits));
-
- /** @var \Drupal\Component\Diff\Engine\DiffOp $diffOp */
- foreach ($edits as $index => $diffOp) {
- $this->assertEquals($expectedEdits[$index][$diffOp->type]['orig'], $diffOp->orig);
- $this->assertEquals($expectedEdits[$index][$diffOp->type]['closing'], $diffOp->closing);
- }
- }
-
-}
diff --git a/modules/contrib/config_update/tests/src/Unit/ConfigListerTest.php b/modules/contrib/config_update/tests/src/Unit/ConfigListerTest.php
deleted file mode 100644
index b2a7493..0000000
--- a/modules/contrib/config_update/tests/src/Unit/ConfigListerTest.php
+++ /dev/null
@@ -1,265 +0,0 @@
-configLister = new ConfigLister($this->getEntityManagerMock(), $this->getConfigStorageMock('active'), $this->getConfigStorageMock('extension'), $this->getConfigStorageMock('optional'));
- }
-
- /**
- * Creates a mock entity manager for the test.
- */
- protected function getEntityManagerMock() {
- // Make a list of fake entity definitions. Make sure they are not sorted,
- // to test that the methods sort them. Also make sure there are a couple
- // with prefixes that are subsets of each other.
- $this->entityDefinitionInformation = [
- ['prefix' => 'foo.bar', 'type' => 'foo'],
- ['prefix' => 'foo.barbaz', 'type' => 'bar'],
- ['prefix' => 'baz.foo', 'type' => 'baz'],
- ];
-
- $definitions = [];
- foreach ($this->entityDefinitionInformation as $info) {
- $def = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigEntityTypeInterface')->getMock();
- $def
- ->expects($this->any())
- ->method('getConfigPrefix')
- ->willReturn($info['prefix']);
- $def
- ->expects($this->any())
- ->method('isSubclassOf')
- ->willReturn(TRUE);
-
- $def->getConfigPrefix();
-
- $definitions[$info['type']] = $def;
- }
-
- $manager = $this->getMockBuilder('Drupal\Core\Entity\EntityTypeManagerInterface')->getMock();
- $manager
- ->method('getDefinitions')
- ->willReturn($definitions);
-
- return($manager);
- }
-
- /**
- * Creates a mock config storage object for the test.
- *
- * @param string $type
- * Type of storage object to return: 'active', 'extension', or 'optional'.
- */
- protected function getConfigStorageMock($type) {
- if ($type == 'active') {
- $storage = $this->getMockBuilder('Drupal\Core\Config\StorageInterface')->getMock();
-
- // The only use of the read() method on active storage is
- // with the core.extension config, to get the profile name.
- $storage
- ->method('read')
- ->willReturn(['profile' => 'standard']);
-
- $map = [
- ['foo.bar', ['foo.bar.one', 'foo.bar.two', 'foo.bar.three']],
- ['foo.barbaz', ['foo.barbaz.four', 'foo.barbaz.five', 'foo.barbaz.six']],
- ['baz.foo'], [],
- ['',
- [
- 'foo.bar.one',
- 'foo.bar.two',
- 'foo.bar.three',
- 'foo.barbaz.four',
- 'foo.barbaz.five',
- 'foo.barbaz.six',
- 'something.else',
- 'another.one',
- ],
- ],
- ];
-
- $storage
- ->method('listAll')
- ->will($this->returnValueMap($map));
- }
- elseif ($type == 'extension') {
- $storage = $this->getMockBuilder('Drupal\Core\Config\ExtensionInstallStorage')->disableOriginalConstructor()->getMock();
- $storage
- ->method('getComponentNames')
- ->willReturn([
- 'foo.bar.one' => 'ignored',
- 'foo.bar.two' => 'ignored',
- 'foo.bar.seven' => 'ignored',
- 'foo.barnot.three' => 'ignored',
- 'something.else' => 'ignored',
- ]);
-
- $map = [
- ['foo.bar', ['foo.bar.one', 'foo.bar.two', 'foo.bar.seven']],
- ['baz.foo'], [],
- ['',
- [
- 'foo.bar.one',
- 'foo.bar.two',
- 'foo.bar.seven',
- 'foo.barbaz.four',
- 'foo.barnot.three',
- 'something.else',
- ],
- ],
- ];
-
- $storage
- ->method('listAll')
- ->will($this->returnValueMap($map));
- }
- else {
- $storage = $this->getMockBuilder('Drupal\Core\Config\ExtensionInstallStorage')->disableOriginalConstructor()->getMock();
- $storage
- ->method('getComponentNames')
- ->willReturn([
- 'foo.barbaz.four' => 'ignored',
- ]);
-
- $map = [
- ['foo.bar'], [],
- ['foo.barbaz', ['foo.barbaz.four']],
- ['', ['foo.barbaz.four']],
- ];
- $storage
- ->method('listAll')
- ->will($this->returnValueMap($map));
- }
- return $storage;
-
- }
-
- /**
- * @covers \Drupal\config_update\ConfigLister::listConfig
- * @dataProvider listConfigProvider
- */
- public function testListConfig($a, $b, $expected) {
- $this->assertEquals($expected, $this->configLister->listConfig($a, $b));
- }
-
- /**
- * Data provider for self:testListConfig().
- */
- public function listConfigProvider() {
- return [
- // Arguments are $list_type, $name.
- // We cannot really test the extension types here, because they rely
- // on the going out to the file system to find out what config objects
- // are there. This is too complex to mock. It is tested in the tests for
- // the report output in the config_update_ui module tests. Anyway, we
- // can test the other types.
- ['type', 'system.all',
- [
- [
- 'foo.bar.one',
- 'foo.bar.two',
- 'foo.bar.three',
- 'foo.barbaz.four',
- 'foo.barbaz.five',
- 'foo.barbaz.six',
- 'something.else',
- 'another.one',
- ],
- [
- 'foo.bar.one',
- 'foo.bar.two',
- 'foo.bar.seven',
- 'foo.barbaz.four',
- 'foo.barnot.three',
- 'something.else',
- ],
- ['foo.barbaz.four'],
- ],
- ],
- ['type', 'system.simple',
- [
- ['something.else', 'another.one'],
- ['foo.barnot.three', 'something.else'],
- [],
- ],
- ],
- ['type', 'foo',
- [
- ['foo.bar.one', 'foo.bar.two', 'foo.bar.three'],
- ['foo.bar.one', 'foo.bar.two', 'foo.bar.seven'],
- [],
- ],
- ],
- ['type', 'unknown.type', [[], [], []]],
- ];
- }
-
- /**
- * @covers \Drupal\config_update\ConfigLister::getType
- */
- public function testGetType() {
- $return = $this->configLister->getType('not_in_list');
- $this->assertNull($return);
-
- foreach ($this->entityDefinitionInformation as $info) {
- $return = $this->configLister->getType($info['type']);
- $this->assertEquals($return->getConfigPrefix(), $info['prefix']);
- }
- }
-
- /**
- * @covers \Drupal\config_update\ConfigLister::getTypeByPrefix
- */
- public function testGetTypeByPrefix() {
- $return = $this->configLister->getTypeByPrefix('not_in_list');
- $this->assertNull($return);
-
- foreach ($this->entityDefinitionInformation as $info) {
- $return = $this->configLister->getTypeByPrefix($info['prefix']);
- $this->assertEquals($return->getConfigPrefix(), $info['prefix']);
- }
- }
-
- /**
- * @covers \Drupal\config_update\ConfigLister::getTypeNameByConfigName
- */
- public function testGetTypeNameByConfigName() {
- $return = $this->configLister->getTypeNameByConfigName('not_in_list');
- $this->assertNull($return);
-
- foreach ($this->entityDefinitionInformation as $info) {
- $return = $this->configLister->getTypeNameByConfigName($info['prefix'] . '.something');
- $this->assertEquals($return, $info['type']);
- }
- }
-
-}
diff --git a/modules/contrib/features/LICENSE.txt b/modules/contrib/features/LICENSE.txt
deleted file mode 100644
index d159169..0000000
--- a/modules/contrib/features/LICENSE.txt
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- ';
- $output .= '
' . t('Use the form below to manage bundles. Each bundle comes with a set of assignment methods. By configuring and ordering the assignment methods, you can set the defaults for what does and doesn\'t get packaged into features for your bundle. Use the Bundle select to choose which bundle to edit, or chose --New-- to create a new bundle. The Default bundle does not include a namespace and cannot be deleted.') . '
'; - return $output; - - case 'features.export': - $output = ''; - $output .= '' . t('Export packages of configuration into modules.') . '
'; - return $output; - } -} - -/** - * Implements hook_theme(). - */ -function features_ui_theme() { - return array( - 'features_listing' => array( - 'render element' => 'form', - 'file' => 'features_ui.admin.inc', - 'function' => 'theme_features_listing', - ), - 'features_assignment_configure_form' => array( - 'render element' => 'form', - 'file' => 'features_ui.admin.inc', - 'function' => 'theme_assignment_form', - ), - 'features_items' => array( - 'variables' => array( - 'items' => array(), - ), - 'file' => 'features_ui.admin.inc', - 'function' => 'theme_features_items', - ), - ); -} diff --git a/modules/contrib/features/modules/features_ui/features_ui.routing.yml b/modules/contrib/features/modules/features_ui/features_ui.routing.yml deleted file mode 100644 index 9343aee..0000000 --- a/modules/contrib/features/modules/features_ui/features_ui.routing.yml +++ /dev/null @@ -1,104 +0,0 @@ -features.export: - path: '/admin/config/development/features' - defaults: - _form: '\Drupal\features_ui\Form\FeaturesExportForm' - _title: 'Features' - requirements: - _permission: 'export configuration' - -features.assignment: - path: '/admin/config/development/features/bundle/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentConfigureForm' - _title: 'Bundle assignment' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.assignment_alter: - path: '/admin/config/development/features/bundle/_alter/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentAlterForm' - _title: 'Configure package configuration altering' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.assignment_base: - path: '/admin/config/development/features/bundle/_base/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentBaseForm' - _title: 'Configure base package assignment' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.assignment_core: - path: '/admin/config/development/features/bundle/_core/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentCoreForm' - _title: 'Configure core package assignment' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.assignment_exclude: - path: '/admin/config/development/features/bundle/_exclude/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentExcludeForm' - _title: 'Configure package exclusion' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.assignment_optional: - path: '/admin/config/development/features/bundle/_optional/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentOptionalForm' - _title: 'Configure optional package assignment' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.assignment_profile: - path: '/admin/config/development/features/bundle/_profile/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentProfileForm' - _title: 'Configure profile package assignment' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.assignment_site: - path: '/admin/config/development/features/bundle/_site/{bundle_name}' - defaults: - _form: '\Drupal\features_ui\Form\AssignmentSiteForm' - _title: 'Configure site package assignment' - bundle_name: NULL - requirements: - _permission: 'administer site configuration' - -features.edit: - path: '/admin/config/development/features/edit/{featurename}' - defaults: - _form: '\Drupal\features_ui\Form\FeaturesEditForm' - _title: 'Edit' - featurename: '' - requirements: - _permission: 'administer site configuration' - -features.diff: - path: '/admin/config/development/features/diff/{featurename}' - defaults: - _form: '\Drupal\features_ui\Form\FeaturesDiffForm' - _title: 'Differences' - featurename: '' - requirements: - _permission: 'administer site configuration' - -features.detect: - path: '/features/api/detect/{name}' - defaults: - _controller: '\Drupal\features_ui\Controller\FeaturesUIController::detect' - requirements: - _permission: 'administer site configuration' diff --git a/modules/contrib/features/modules/features_ui/js/features_ui.admin.js b/modules/contrib/features/modules/features_ui/js/features_ui.admin.js deleted file mode 100644 index d401968..0000000 --- a/modules/contrib/features/modules/features_ui/js/features_ui.admin.js +++ /dev/null @@ -1,401 +0,0 @@ -/** - * jQuery.fn.sortElements - * -------------- - * @param Function comparator: - * Exactly the same behaviour as [1,2,3].sort(comparator) - * - * @param Function getSortable - * A function that should return the element that is - * to be sorted. The comparator will run on the - * current collection, but you may want the actual - * resulting sort to occur on a parent or another - * associated element. - * - * E.g. $('td').sortElements(comparator, function(){ - * return this.parentNode; - * }) - * - * The' . $this->t('Use an export method button below to generate the selected features.') . '
', - ); - - $form['actions'] = array('#type' => 'actions', '#tree' => TRUE); - foreach ($generation_info as $method_id => $method) { - $form['actions'][$method_id] = array( - '#type' => 'submit', - '#name' => $method_id, - '#value' => $this->t('@name', array('@name' => $method['name'])), - '#attributes' => array( - 'title' => Html::escape($method['description']), - ), - ); - } - } - - $form['#pre_render'][] = array(get_class($this), 'preRenderRemoveInvalidCheckboxes'); - - return $form; - } - - /** - * Handles switching the configuration type selector. - */ - public function updatePreview($form, FormStateInterface $form_state) { - // We should really be able to add this pre_render callback to the - // 'preview' element. However, since doing so leads to an error (no rows - // are displayed), we need to instead explicitly invoke it here for the - // processing to apply to the Ajax-rendered form element. - $form = $this->preRenderRemoveInvalidCheckboxes($form); - return $form['preview']; - } - - /** - * Builds the portion of the form showing a listing of features. - * - * @param \Drupal\features\Package[] $packages - * The packages. - * @param \Drupal\features\FeaturesBundleInterface $bundle - * The current bundle - * - * @return array - * A render array of a form element. - */ - protected function buildListing(array $packages, FeaturesBundleInterface $bundle) { - - $header = array( - 'name' => array('data' => $this->t('Feature')), - 'machine_name' => array('data' => $this->t('')), - 'details' => array('data' => $this->t('Description'), 'class' => array(RESPONSIVE_PRIORITY_LOW)), - 'version' => array('data' => $this->t('Version'), 'class' => array(RESPONSIVE_PRIORITY_LOW)), - 'status' => array('data' => $this->t('Status'), 'class' => array(RESPONSIVE_PRIORITY_LOW)), - 'state' => array('data' => $this->t('State'), 'class' => array(RESPONSIVE_PRIORITY_LOW)), - ); - - $options = array(); - $first = TRUE; - foreach ($packages as $package) { - if ($first && $package->getStatus() == FeaturesManagerInterface::STATUS_NO_EXPORT) { - // Don't offer new non-profile packages that are empty. - if ($package->getStatus() === FeaturesManagerInterface::STATUS_NO_EXPORT && - !$bundle->isProfilePackage($package->getMachineName()) && - empty($package->getConfig())) { - continue; - } - $first = FALSE; - $options[] = array( - 'name' => array( - 'data' => $this->t('The following packages are not exported.'), - 'class' => 'features-export-header-row', - 'colspan' => 6, - ), - ); - } - $options[$package->getMachineName()] = $this->buildPackageDetail($package, $bundle); - } - - $element = array( - '#type' => 'tableselect', - '#header' => $header, - '#options' => $options, - '#attributes' => array('class' => array('features-listing')), - '#prefix' => 'This step only shows if the entity is already existing!
', - ); - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - // Do nothing! - } - -} diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityExternalForm.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityExternalForm.php deleted file mode 100644 index 2ba871c..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityExternalForm.php +++ /dev/null @@ -1,66 +0,0 @@ -tempstore = $tempstore; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('user.shared_tempstore')); - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'ctools_wizard_test_example_config_entity_external_form'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state, $machine_name = '') { - $cached_values = $this->tempstore->get('ctools_wizard_test.config_entity')->get($machine_name); - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - $form['blah'] = [ - '#markup' => 'Value from one: ' . $config_entity->getOne(), - ]; - - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - // Don't do anything. - } - -} - diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityGeneralForm.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityGeneralForm.php deleted file mode 100644 index 6120342..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityGeneralForm.php +++ /dev/null @@ -1,46 +0,0 @@ -getTemporaryValue('wizard'); - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - // The label and id will be added by the EntityFormWizardBase. - - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - $config_entity->set('id', $form_state->getValue('id')); - $config_entity->set('label', $form_state->getValue('label')); - } - -} diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityOneForm.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityOneForm.php deleted file mode 100644 index 6d1cf6d..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityOneForm.php +++ /dev/null @@ -1,62 +0,0 @@ -getTemporaryValue('wizard'); - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - $form['one'] = [ - '#title' => $this->t('One'), - '#type' => 'textfield', - '#default_value' => $config_entity->getOne() ?: '', - ]; - - $form['external'] = [ - '#type' => 'link', - '#title' => $this->t('Show on dialog'), - '#url' => new Url('entity.ctools_wizard_test_config_entity.external_form', [ - 'machine_name' => $config_entity->id(), - ]), - '#attributes' => [ - 'class' => 'use-ajax', - 'data-dialog-type' => 'modal', - ], - ]; - - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - $config_entity->set('one', $form_state->getValue('one')); - } - -} diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityTwoForm.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityTwoForm.php deleted file mode 100644 index 6ea2f40..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityTwoForm.php +++ /dev/null @@ -1,47 +0,0 @@ -getTemporaryValue('wizard'); - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - $form['two'] = array( - '#title' => $this->t('Two'), - '#type' => 'textfield', - '#default_value' => $config_entity->getTwo() ?: '', - ); - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - $config_entity->set('two', $form_state->getValue('two')); - } - -} diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/OneForm.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Form/OneForm.php deleted file mode 100644 index 0375056..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/OneForm.php +++ /dev/null @@ -1,71 +0,0 @@ -getTemporaryValue('wizard'); - $form['one'] = [ - '#title' => $this->t('One'), - '#type' => 'textfield', - '#default_value' => !empty($cached_values['one']) ? $cached_values['one'] : '', - ]; - $form['dynamic'] = [ - '#title' => $this->t('Dynamic value'), - '#type' => 'item', - '#markup' => !empty($cached_values['dynamic']) ? $cached_values['dynamic'] : '', - ]; - return $form; - } - - /** - * Form submission handler. - * - * @param array $form - * An associative array containing the structure of the form. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $keys = array( - 'one', - ); - $cached_values = $form_state->getTemporaryValue('wizard'); - foreach ($keys as $key) { - $cached_values[$key] = $form_state->getValue($key); - } - $form_state->setTemporaryValue('wizard', $cached_values); - - drupal_set_message($this->t('Dynamic value submitted: @value', ['@value' => $cached_values['dynamic']]));; - } - -} diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/TwoForm.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Form/TwoForm.php deleted file mode 100644 index 01ae10a..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Form/TwoForm.php +++ /dev/null @@ -1,69 +0,0 @@ -getTemporaryValue('wizard'); - $form['two'] = [ - '#title' => $this->t('Two'), - '#type' => 'textfield', - '#default_value' => !empty($cached_values['two']) ? $cached_values['two'] : '', - ]; - $form['dynamic'] = [ - '#title' => $this->t('Dynamic value'), - '#type' => 'item', - '#markup' => !empty($cached_values['dynamic']) ? $cached_values['dynamic'] : '', - ]; - return $form; - } - - /** - * Form submission handler. - * - * @param array $form - * An associative array containing the structure of the form. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $keys = array( - 'two', - ); - $cached_values = $form_state->getTemporaryValue('wizard'); - foreach ($keys as $key) { - $cached_values[$key] = $form_state->getValue($key); - } - $form_state->setTemporaryValue('wizard', $cached_values); - } - -} diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Wizard/EntityAddWizardTest.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Wizard/EntityAddWizardTest.php deleted file mode 100644 index 77ab5d5..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Wizard/EntityAddWizardTest.php +++ /dev/null @@ -1,15 +0,0 @@ -t('Example entity'); - } - - /** - * {@inheritdoc} - */ - public function getMachineLabel() { - return $this->t('Label'); - } - - /** - * {@inheritdoc} - */ - public function getEntityType() { - return 'ctools_wizard_test_config_entity'; - } - - /** - * {@inheritdoc} - */ - public function exists() { - return '\Drupal\ctools_wizard_test\Entity\ExampleConfigEntity::load'; - } - - /** - * {@inheritdoc} - */ - public function getOperations($cached_values) { - /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */ - $config_entity = $cached_values['ctools_wizard_test_config_entity']; - - $steps = [ - 'general' => [ - 'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityGeneralForm', - 'title' => $this->t('General'), - ], - 'one' => [ - 'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityOneForm', - 'title' => $this->t('Form One'), - ], - 'two' => [ - 'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityTwoForm', - 'title' => $this->t('Form Two'), - ], - ]; - - // To test that we can get the config entity and add/remove steps - // based on it's values, we'll add a special step only when the entity - // is pre-existing. - if (!empty($config_entity) && !$config_entity->isNew()) { - $steps['existing'] = [ - 'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityExistingForm', - 'title' => $this->t('Existing entity'), - ]; - } - - return $steps; - } -} diff --git a/modules/ctools/tests/modules/ctools_wizard_test/src/Wizard/WizardTest.php b/modules/ctools/tests/modules/ctools_wizard_test/src/Wizard/WizardTest.php deleted file mode 100644 index 539df33..0000000 --- a/modules/ctools/tests/modules/ctools_wizard_test/src/Wizard/WizardTest.php +++ /dev/null @@ -1,82 +0,0 @@ -t('Wizard Information'); - } - - /** - * {@inheritdoc} - */ - public function getMachineLabel() { - return $this->t('Wizard Test Name'); - } - - /** - * {@inheritdoc} - */ - public function getOperations($cached_values) { - return array( - 'one' => [ - 'form' => 'Drupal\ctools_wizard_test\Form\OneForm', - 'title' => $this->t('Form One'), - 'values' => ['dynamic' => 'Xylophone'], - 'validate' => ['::stepOneValidate'], - 'submit' => ['::stepOneSubmit'], - ], - 'two' => [ - 'form' => 'Drupal\ctools_wizard_test\Form\TwoForm', - 'title' => $this->t('Form Two'), - 'values' => ['dynamic' => 'Zebra'], - ], - ); - } - - /** - * Validation callback for the first step. - */ - public function stepOneValidate($form, FormStateInterface $form_state) { - if ($form_state->getValue('one') == 'wrong') { - $form_state->setErrorByName('one', $this->t('Cannot set the value to "wrong".')); - } - } - - /** - * Submission callback for the first step. - */ - public function stepOneSubmit($form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - if ($form_state->getValue('one') == 'magic') { - $cached_values['one'] = 'Abraham'; - } - $form_state->setTemporaryValue('wizard', $cached_values); - } - - /** - * {@inheritdoc} - */ - public function getRouteName() { - return 'ctools.wizard.test.step'; - } - - /** - * {@inheritdoc} - */ - public function finish(array &$form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - drupal_set_message($this->t('Value One: @one', ['@one' => $cached_values['one']])); - drupal_set_message($this->t('Value Two: @two', ['@two' => $cached_values['two']])); - parent::finish($form, $form_state); - } - -} diff --git a/modules/ctools/tests/src/Kernel/RelationshipManagerTest.php b/modules/ctools/tests/src/Kernel/RelationshipManagerTest.php deleted file mode 100644 index 94ca6d9..0000000 --- a/modules/ctools/tests/src/Kernel/RelationshipManagerTest.php +++ /dev/null @@ -1,63 +0,0 @@ -relationshipManager->getDefinitions(); - $expected = [ - 'Bundle' => [ - 0 => "page", - 1 => "foo" - ] - ]; - $this->assertSame($expected, $definitions['typed_data_relationship:entity:node:body']['context']['base']->getConstraints()); - - // Check that typed data primitive labels are formatted properly. - $this->assertSame('Body from Page and Foo', (string) $definitions['typed_data_relationship:entity:node:body']['label']); - - // Check that entity relationship labels are formatted properly. - $this->assertSame('Authored by Entity from Content', (string) $definitions['typed_data_entity_relationship:entity:node:uid']['label']); - - // Check that language relationship labels are formatted properly. - $this->assertSame('Language Language from Content', (string) $definitions['typed_data_language_relationship:entity:node:langcode']['label']); - } - - /** - * @covers ::getDefinitionsForContexts - */ - public function testRelationshipPluginAvailability() { - $context_definition = new ContextDefinition('entity:node'); - $contexts = [ - 'node' => new Context($context_definition, $this->entities['node1']), - ]; - $definitions = $this->relationshipManager->getDefinitionsForContexts($contexts); - //$this->assertTrue(isset($definitions['typed_data_relationship:entity:node:body'])); - - $context_definition = new ContextDefinition('entity:node'); - $contexts = [ - 'node' => new Context($context_definition, $this->entities['node2']), - ]; - $definitions = $this->relationshipManager->getDefinitionsForContexts($contexts); - $this->assertFalse(isset($definitions['typed_data_relationship:entity:node:body'])); - - $context_definition = new ContextDefinition('entity:node'); - $contexts = [ - 'node' => new Context($context_definition, $this->entities['node3']), - ]; - $definitions = $this->relationshipManager->getDefinitionsForContexts($contexts); - //$this->assertTrue(isset($definitions['typed_data_relationship:entity:node:body'])); - } - -} diff --git a/modules/ctools/tests/src/Kernel/RelationshipsTestBase.php b/modules/ctools/tests/src/Kernel/RelationshipsTestBase.php deleted file mode 100644 index cd58379..0000000 --- a/modules/ctools/tests/src/Kernel/RelationshipsTestBase.php +++ /dev/null @@ -1,96 +0,0 @@ -installSchema('system', ['sequences', 'router']); - $this->installEntitySchema('user'); - $this->installEntitySchema('node_type'); - $this->installEntitySchema('node'); - $this->installConfig('node'); - $page = $this->createEntity('node_type', [ - 'type' => 'page', - 'name' => 'Page' - ]); - node_add_body_field($page); - $article = $this->createEntity('node_type', [ - 'type' => 'article', - 'name' => 'Article' - ]); - // Not adding the body field the articles so that we can perform a test. - $foo = $this->createEntity('node_type', [ - 'type' => 'foo', - 'name' => 'Foo' - ]); - node_add_body_field($foo); - $this->relationshipManager = $this->container->get('plugin.manager.ctools.relationship'); - - $user = $this->createEntity('user', [ - 'name' => 'test_user', - 'password' => 'password', - 'mail' => 'mail@test.com', - 'status' => 1, - ]); - $node1 = $this->createEntity('node', [ - 'title' => 'Node 1', - 'type' => 'page', - 'uid' => $user->id(), - 'body' => 'This is a test', - ]); - $node2 = $this->createEntity('node', [ - 'title' => 'Node 2', - 'type' => 'article', - 'uid' => $user->id() - ]); - $node3 = $this->createEntity('node', [ - 'title' => 'Node 3', - 'type' => 'foo', - 'uid' => $user->id() - ]); - - $this->entities = [ - 'user' => $user, - 'node1' => $node1, - 'node2' => $node2, - 'node3' => $node3, - ]; - } - -} diff --git a/modules/ctools/tests/src/Kernel/SerializableTempstoreTest.php b/modules/ctools/tests/src/Kernel/SerializableTempstoreTest.php deleted file mode 100644 index 16e0704..0000000 --- a/modules/ctools/tests/src/Kernel/SerializableTempstoreTest.php +++ /dev/null @@ -1,64 +0,0 @@ -installSchema('system', ['key_value_expire']); - } - - /** - * Tests serializing a serializable temp store object. - */ - public function testSerializableTempStore() { - $store = $this->container - ->get('ctools.serializable.tempstore.factory') - ->get('foobar'); - - // Add an unserializable request to the request stack. If the tempstore - // didn't use DependencySerializationTrait, the exception would be thrown - // when we try to serialize the tempstore. - $request = $this->prophesize(Request::class); - $request->willImplement('\Serializable'); - $request->serialize()->willThrow(new \LogicException('Not cool, bruh!')); - $this->container->get('request_stack')->push($request->reveal()); - - $this->assertInstanceOf(SerializableTempstore::class, $store); - /** @var SerializableTempstore $store */ - - $store = serialize($store); - $this->assertInternalType('string', $store); - $this->assertNotEmpty($store, 'The tempstore was serialized.'); - - $store = unserialize($store); - $this->assertInstanceOf(SerializableTempstore::class, $store, 'The tempstore was unserialized.'); - - $request_stack = $this->getObjectAttribute($store, 'requestStack'); - $this->assertSame( - $this->container->get('request_stack'), - $request_stack, - 'The request stack was pulled from the container during unserialization.' - ); - $this->assertSame($request->reveal(), $request_stack->pop()); - } - -} diff --git a/modules/ctools/tests/src/Kernel/TypedDataEntityRelationshipPluginTest.php b/modules/ctools/tests/src/Kernel/TypedDataEntityRelationshipPluginTest.php deleted file mode 100644 index 042eb7b..0000000 --- a/modules/ctools/tests/src/Kernel/TypedDataEntityRelationshipPluginTest.php +++ /dev/null @@ -1,46 +0,0 @@ -relationshipManager->createInstance('typed_data_entity_relationship:entity:node:type'); - $this->assertSame('type', $type_plugin->getName()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $uuid_plugin */ - $uid_plugin = $this->relationshipManager->createInstance('typed_data_entity_relationship:entity:node:uid'); - $this->assertSame('uid', $uid_plugin->getName()); - } - - /** - * @covers ::getRelationship - */ - public function testRelationship() { - /** @var \Drupal\ctools\Plugin\RelationshipInterface $type_plugin */ - $type_plugin = $this->relationshipManager->createInstance('typed_data_entity_relationship:entity:node:type'); - $type_plugin->setContextValue('base', $this->entities['node1']); - $relationship = $type_plugin->getRelationship(); - $this->assertTrue($relationship->getContextValue() instanceof NodeType); - $this->assertSame('entity:node_type', $relationship->getContextDefinition()->getDataType()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $uid_plugin */ - $uid_plugin = $this->relationshipManager->createInstance('typed_data_entity_relationship:entity:node:uid'); - $uid_plugin->setContextValue('base', $this->entities['node3']); - $relationship = $uid_plugin->getRelationship(); - $this->assertTrue($relationship->getContextValue() instanceof User); - $this->assertSame('entity:user', $relationship->getContextDefinition()->getDataType()); - } - -} diff --git a/modules/ctools/tests/src/Kernel/TypedDataLanguageRelationshipPluginTest.php b/modules/ctools/tests/src/Kernel/TypedDataLanguageRelationshipPluginTest.php deleted file mode 100644 index 3e94531..0000000 --- a/modules/ctools/tests/src/Kernel/TypedDataLanguageRelationshipPluginTest.php +++ /dev/null @@ -1,36 +0,0 @@ -relationshipManager->createInstance('typed_data_language_relationship:entity:node:langcode'); - $this->assertSame('langcode', $langcode_plugin->getName()); - } - - /** - * @covers ::getRelationship - * - * @todo expand to include a new language. - */ - public function testRelationship() { - /** @var \Drupal\ctools\Plugin\RelationshipInterface $langcode_plugin */ - $langcode_plugin = $this->relationshipManager->createInstance('typed_data_language_relationship:entity:node:langcode'); - $langcode_plugin->setContextValue('base', $this->entities['node1']); - $relationship = $langcode_plugin->getRelationship(); - $this->assertTrue($relationship->getContextValue() instanceof LanguageInterface); - $this->assertSame('en', $relationship->getContextValue()->getId()); - } - -} diff --git a/modules/ctools/tests/src/Kernel/TypedDataRelationshipPluginTest.php b/modules/ctools/tests/src/Kernel/TypedDataRelationshipPluginTest.php deleted file mode 100644 index f9a07cf..0000000 --- a/modules/ctools/tests/src/Kernel/TypedDataRelationshipPluginTest.php +++ /dev/null @@ -1,103 +0,0 @@ -relationshipManager->createInstance('typed_data_relationship:entity:node:nid'); - $this->assertSame('nid', $nid_plugin->getName()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $uuid_plugin */ - $uuid_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:uuid'); - $this->assertSame('uuid', $uuid_plugin->getName()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $title_plugin */ - $title_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:title'); - $this->assertSame('title', $title_plugin->getName()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $body_plugin */ - $body_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:body'); - $this->assertSame('body', $body_plugin->getName()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $uid_plugin */ - $uid_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:uid'); - $this->assertSame('uid', $uid_plugin->getName()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $mail_plugin */ - $mail_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:user:mail'); - $this->assertSame('mail', $mail_plugin->getName()); - } - - /** - * @covers ::getRelationship - */ - public function testRelationship() { - /** @var \Drupal\ctools\Plugin\RelationshipInterface $nid_plugin */ - $nid_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:nid'); - $nid_plugin->setContextValue('base', $this->entities['node1']); - $relationship = $nid_plugin->getRelationship(); - $this->assertTrue($relationship instanceof ContextInterface); - $this->assertTrue($relationship->getContextDefinition()->getDataType() == 'integer'); - $this->assertTrue($relationship->hasContextValue()); - $this->assertTrue($relationship->getContextValue() == $this->entities['node1']->id()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $uuid_plugin */ - $uuid_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:uuid'); - $uuid_plugin->setContextValue('base', $this->entities['node1']); - $relationship = $uuid_plugin->getRelationship(); - $this->assertTrue($relationship instanceof ContextInterface); - $this->assertTrue($relationship->getContextDefinition()->getDataType() == 'string'); - $this->assertTrue($relationship->hasContextValue()); - $this->assertTrue($relationship->getContextValue() == $this->entities['node1']->uuid()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $title_plugin */ - $title_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:title'); - $title_plugin->setContextValue('base', $this->entities['node1']); - $relationship = $title_plugin->getRelationship(); - $this->assertTrue($relationship instanceof ContextInterface); - $this->assertTrue($relationship->getContextDefinition()->getDataType() == 'string'); - $this->assertTrue($relationship->hasContextValue()); - $this->assertTrue($relationship->getContextValue() == $this->entities['node1']->label()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $body_plugin */ - $body_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:body'); - $body_plugin->setContextValue('base', $this->entities['node1']); - $relationship = $body_plugin->getRelationship(); - $this->assertTrue($relationship instanceof ContextInterface); - $this->assertTrue($relationship->getContextDefinition()->getDataType() == 'string'); - $this->assertTrue($relationship->hasContextValue()); - $this->assertTrue($relationship->getContextValue() == $this->entities['node1']->get('body')->first()->get('value')->getValue()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $uid_plugin */ - $uid_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:node:uid'); - $uid_plugin->setContextValue('base', $this->entities['node3']); - $relationship = $uid_plugin->getRelationship(); - $this->assertTrue($relationship instanceof ContextInterface); - $this->assertTrue($relationship->getContextDefinition()->getDataType() == 'integer'); - $this->assertTrue($relationship->hasContextValue()); - $this->assertTrue($relationship->getContextValue() == $this->entities['node3']->getOwnerId()); - - /** @var \Drupal\ctools\Plugin\RelationshipInterface $mail_plugin */ - $mail_plugin = $this->relationshipManager->createInstance('typed_data_relationship:entity:user:mail'); - $mail_plugin->setContextValue('base', $this->entities['user']); - $relationship = $mail_plugin->getRelationship(); - $this->assertTrue($relationship instanceof ContextInterface); - $this->assertTrue($relationship->getContextDefinition()->getDataType() == 'email'); - $this->assertTrue($relationship->hasContextValue()); - $this->assertTrue($relationship->getContextValue() == $this->entities['user']->getEmail()); - } - -} diff --git a/modules/ctools/tests/src/Kernel/TypedDataResolverTest.php b/modules/ctools/tests/src/Kernel/TypedDataResolverTest.php deleted file mode 100644 index c53c9c1..0000000 --- a/modules/ctools/tests/src/Kernel/TypedDataResolverTest.php +++ /dev/null @@ -1,105 +0,0 @@ -installSchema('system', 'sequences'); - $this->installEntitySchema('user'); - - $this->typedDataResolver = \Drupal::service('ctools.typed_data.resolver'); - } - - /** - * Tests context extraction from properties. - */ - public function testGetContextFromProperty() { - // Create a user and test entity to extract context from. - $user = User::create(['uid' => 2, 'name' => 'username', 'mail' => 'mail@example.org']); - $user->enforceIsNew(TRUE); - $user->save(); - $entity_test = EntityTest::create(['user_id' => $user->id(), 'name' => 'Test name']); - - // Test the language property. - $property_context = $this->assertPropertyPath($entity_test, 'langcode:language', 'language'); - $this->assertEquals('en', $property_context->getContextValue()->getId()); - - // Test the reference to the user. - $property_context = $this->assertPropertyPath($entity_test, 'user_id:entity', 'entity:user'); - $this->assertEquals($user->id(), $property_context->getContextValue()->id()); - - // Test the reference to the name. - $property_context = $this->assertPropertyPath($entity_test, 'name:value', 'string'); - $this->assertEquals('Test name', $property_context->getContextValue()); - - // Test explicitly specifying the delta. - $property_context = $this->assertPropertyPath($entity_test, 'name:0:value', 'string'); - $this->assertEquals('Test name', $property_context->getContextValue()); - - // Test following the reference. - $property_context = $this->assertPropertyPath($entity_test, 'user_id:entity:mail:value', 'email'); - $this->assertEquals('mail@example.org', $property_context->getContextValue()); - } - - /** - * Asserts that a context for the given property path can be derived. - * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity - * The entity to test with. - * @param $property_path - * The property path to look for. - * @param $expected_data_type - * The expected data type. - * - * @return \Drupal\Core\Plugin\Context\ContextInterface - * The context with a value. - */ - protected function assertPropertyPath(ContentEntityInterface $entity, $property_path, $expected_data_type) { - $typed_data_entity = $entity->getTypedData(); - $context_definition = new ContextDefinition($typed_data_entity->getDataDefinition()->getDataType()); - $context_with_value = new Context($context_definition, $typed_data_entity); - $context_without_value = new Context($context_definition); - - // Test the context without value. - $property_context = $this->typedDataResolver->getContextFromProperty($property_path, $context_without_value); - $this->assertEquals($expected_data_type, $property_context->getContextDefinition()->getDataType()); - - // Test the context with value. - $property_context = $this->typedDataResolver->getContextFromProperty($property_path, $context_with_value); - $this->assertEquals($expected_data_type, $property_context->getContextDefinition()->getDataType()); - - // Return the context with value so it can be asserted. - return $property_context; - } - -} diff --git a/modules/ctools/tests/src/Unit/BlockDisplayVariantTest.php b/modules/ctools/tests/src/Unit/BlockDisplayVariantTest.php deleted file mode 100644 index ed04f3d..0000000 --- a/modules/ctools/tests/src/Unit/BlockDisplayVariantTest.php +++ /dev/null @@ -1,90 +0,0 @@ -prophesize(AccountInterface::class); - $context_handler = $this->prophesize(ContextHandlerInterface::class); - $uuid_generator = $this->prophesize(UuidInterface::class); - $token = $this->prophesize(Token::class); - $block_manager = $this->prophesize(BlockManager::class); - $condition_manager = $this->prophesize(ConditionManager::class); - - $display_variant = new TestBlockDisplayVariant([], '', [], $context_handler->reveal(), $account->reveal(), $uuid_generator->reveal(), $token->reveal(), $block_manager->reveal(), $condition_manager->reveal()); - - $form = []; - $form_state = (new FormState())->setValues($values); - $display_variant->submitConfigurationForm($form, $form_state); - $this->assertSame($values['label'], $display_variant->label()); - } - - /** - * Provides data for testSubmitConfigurationForm(). - */ - public function providerTestSubmitConfigurationForm() { - $data = []; - $data[] = [ - [ - 'label' => 'test_label1', - ], - ]; - $data[] = [ - [ - 'label' => 'test_label2', - 'blocks' => ['foo1' => []], - ], - ]; - $data[] = [ - [ - 'label' => 'test_label3', - 'blocks' => ['foo1' => [], 'foo2' => []], - ], - ]; - return $data; - } - -} - -class TestBlockDisplayVariant extends BlockDisplayVariant { - - /** - * {@inheritdoc} - */ - public function build() { - return []; - } - - public function getRegionNames() { - return [ - 'top' => 'Top', - 'bottom' => 'Bottom', - ]; - } - -} diff --git a/modules/ctools/tests/src/Unit/BlockPluginCollectionTest.php b/modules/ctools/tests/src/Unit/BlockPluginCollectionTest.php deleted file mode 100644 index c928107..0000000 --- a/modules/ctools/tests/src/Unit/BlockPluginCollectionTest.php +++ /dev/null @@ -1,81 +0,0 @@ - [ - 'id' => 'foo', - 'label' => 'Foo', - 'plugin' => 'system_powered_by_block', - 'region' => 'bottom', - ], - 'bar' => [ - 'id' => 'bar', - 'label' => 'Bar', - 'plugin' => 'system_powered_by_block', - 'region' => 'top', - ], - 'bing' => [ - 'id' => 'bing', - 'label' => 'Bing', - 'plugin' => 'system_powered_by_block', - 'region' => 'bottom', - 'weight' => -10, - ], - 'baz' => [ - 'id' => 'baz', - 'label' => 'Baz', - 'plugin' => 'system_powered_by_block', - 'region' => 'bottom', - ], - ]; - $block_manager = $this->prophesize(BlockManagerInterface::class); - $plugins = []; - foreach ($blocks as $block_id => $block) { - $plugin = $this->prophesize(BlockPluginInterface::class); - $plugin->label()->willReturn($block['label']); - $plugin->getConfiguration()->willReturn($block); - $plugins[$block_id] = $plugin->reveal(); - - $block_manager->createInstance($block_id, $block) - ->willReturn($plugin->reveal()) - ->shouldBeCalled(); - } - - - $block_plugin_collection = new BlockPluginCollection($block_manager->reveal(), $blocks); - $expected = [ - 'bottom' => [ - 'bing' => $plugins['bing'], - 'baz' => $plugins['baz'], - 'foo' => $plugins['foo'], - ], - 'top' => [ - 'bar' => $plugins['bar'], - ], - ]; - $this->assertSame($expected, $block_plugin_collection->getAllByRegion()); - } - -} diff --git a/modules/ctools/tests/src/Unit/BlockVariantTraitTest.php b/modules/ctools/tests/src/Unit/BlockVariantTraitTest.php deleted file mode 100644 index 8926879..0000000 --- a/modules/ctools/tests/src/Unit/BlockVariantTraitTest.php +++ /dev/null @@ -1,149 +0,0 @@ -prophesize(BlockPluginCollection::class); - $block_collection->getAllByRegion() - ->willReturn($blocks) - ->shouldBeCalled(); - - $display_variant = new TestBlockVariantTrait(); - $display_variant->setBlockPluginCollection($block_collection->reveal()); - - $this->assertSame($expected, $display_variant->getRegionAssignments()); - } - - public function providerTestGetRegionAssignments() { - return [ - [ - [ - 'top' => [], - 'bottom' => [], - ], - ], - [ - [ - 'top' => ['foo'], - 'bottom' => [], - ], - [ - 'top' => ['foo'], - ], - ], - [ - [ - 'top' => [], - 'bottom' => [], - ], - [ - 'invalid' => ['foo'], - ], - ], - [ - [ - 'top' => [], - 'bottom' => ['foo'], - ], - [ - 'bottom' => ['foo'], - 'invalid' => ['bar'], - ], - ], - ]; - } - -} - -class TestBlockVariantTrait { - use BlockVariantTrait; - - /** - * @var array - */ - protected $blockConfig = []; - - /** - * @var \Drupal\Component\Uuid\UuidInterface - */ - protected $uuidGenerator; - - /** - * @param BlockPluginCollection $block_plugin_collection - * - * @return $this - */ - public function setBlockPluginCollection(BlockPluginCollection $block_plugin_collection) { - $this->blockPluginCollection = $block_plugin_collection; - return $this; - } - - /** - * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator - * - * @return $this - */ - public function setUuidGenerator(UuidInterface $uuid_generator) { - $this->uuidGenerator = $uuid_generator; - return $this; - } - - /** - * {@inheritdoc} - */ - protected function uuidGenerator() { - return $this->uuidGenerator; - } - - /** - * Sets the block configuration. - * - * @param array $config - * The block configuration. - * - * @return $this - */ - public function setBlockConfig(array $config) { - $this->blockConfig = $config; - return $this; - } - - /** - * {@inheritdoc} - */ - protected function getBlockConfig() { - return $this->blockConfig; - } - - /** - * {@inheritdoc} - */ - public function getRegionNames() { - return [ - 'top' => 'Top', - 'bottom' => 'Bottom', - ]; - } - -} diff --git a/modules/ctools/tests/src/Unit/ContextMapperTest.php b/modules/ctools/tests/src/Unit/ContextMapperTest.php deleted file mode 100644 index 24a85f2..0000000 --- a/modules/ctools/tests/src/Unit/ContextMapperTest.php +++ /dev/null @@ -1,104 +0,0 @@ -typedDataManager = $this->prophesize(TypedDataManager::class); - $this->entityRepository = $this->prophesize(EntityRepositoryInterface::class); - $this->staticContext = new ContextMapper($this->entityRepository->reveal()); - - $container = new ContainerBuilder(); - $container->set('typed_data_manager', $this->typedDataManager->reveal()); - \Drupal::setContainer($container); - } - - /** - * @covers ::getContextValues - */ - public function testGetContextValues() { - $input = []; - $actual = $this->staticContext->getContextValues($input); - $this->assertEquals([], $actual); - } - - /** - * @covers ::getContextValues - */ - public function testGetContextValuesContext() { - $data_definition = DataDefinition::createFromDataType('integer'); - $typed_data = IntegerData::createInstance($data_definition); - $this->typedDataManager->createDataDefinition('integer')->willReturn($data_definition); - $this->typedDataManager->getDefaultConstraints($data_definition)->willReturn([]); - $this->typedDataManager->create($data_definition, 5)->willReturn($typed_data); - - $input = [ - 'foo' => [ - 'label' => 'Foo', - 'description' => NULL, - 'type' => 'integer', - 'value' => 5, - ], - ]; - $expected = new Context(new ContextDefinition('integer', 'Foo'), 5); - $actual = $this->staticContext->getContextValues($input)['foo']; - $this->assertEquals($expected, $actual); - } - - /** - * @covers ::getContextValues - */ - public function testGetContextValuesEntityContext() { - $input = [ - 'foo' => [ - 'label' => 'Foo', - 'description' => NULL, - 'type' => 'entity:node', - 'value' => 'the_node_uuid', - ], - ]; - $expected = new EntityLazyLoadContext(new ContextDefinition('entity:node', 'Foo'), $this->entityRepository->reveal(), 'the_node_uuid'); - $actual = $this->staticContext->getContextValues($input)['foo']; - $this->assertEquals($expected, $actual); - } - -} diff --git a/modules/ctools/tests/src/Unit/VariantCollectionTraitTest.php b/modules/ctools/tests/src/Unit/VariantCollectionTraitTest.php deleted file mode 100644 index 4e93ea0..0000000 --- a/modules/ctools/tests/src/Unit/VariantCollectionTraitTest.php +++ /dev/null @@ -1,209 +0,0 @@ -manager = $this->prophesize(PluginManagerInterface::class); - $container->set('plugin.manager.display_variant', $this->manager->reveal()); - \Drupal::setContainer($container); - } - - /** - * @covers ::getVariants - */ - public function testGetVariantsEmpty() { - $trait_object = new TestVariantCollectionTrait(); - $this->manager->createInstance()->shouldNotBeCalled(); - - $variants = $trait_object->getVariants(); - $this->assertInstanceOf(VariantPluginCollection::class, $variants); - $this->assertSame(0, count($variants)); - } - - /** - * @covers ::getVariants - */ - public function testGetVariants() { - $trait_object = new TestVariantCollectionTrait(); - $config = [ - 'foo' => ['id' => 'foo_plugin'], - 'bar' => ['id' => 'bar_plugin'], - ]; - foreach ($config as $value) { - $plugin = $this->prophesize(VariantInterface::class); - $this->manager->createInstance($value['id'], $value)->willReturn($plugin->reveal()); - } - $trait_object->setVariantConfig($config); - - $variants = $trait_object->getVariants(); - $this->assertInstanceOf(VariantPluginCollection::class, $variants); - $this->assertSame(2, count($variants)); - return $variants; - } - - /** - * @covers ::getVariants - * - * @depends testGetVariants - */ - public function testGetVariantsSort(VariantPluginCollection $variants) { - $this->assertSame(['bar' => 'bar', 'foo' => 'foo'], $variants->getInstanceIds()); - } - - /** - * @covers ::addVariant - */ - public function testAddVariant() { - $config = ['id' => 'foo']; - $uuid = 'test-uuid'; - $expected_config = $config + ['uuid' => $uuid]; - - $uuid_generator = $this->prophesize(UuidInterface::class); - $uuid_generator->generate() - ->willReturn($uuid) - ->shouldBeCalledTimes(1); - $trait_object = new TestVariantCollectionTrait(); - $trait_object->setUuidGenerator($uuid_generator->reveal()); - - $plugin_prophecy = $this->prophesize(VariantInterface::class); - $plugin_prophecy->getConfiguration() - ->willReturn($expected_config) - ->shouldBeCalled(); - $plugin_prophecy->setConfiguration($expected_config) - ->willReturn($expected_config) - ->shouldBeCalled(); - - $this->manager->createInstance('foo', $expected_config) - ->willReturn($plugin_prophecy->reveal()); - - $resulting_uuid = $trait_object->addVariant($config); - $this->assertSame($uuid, $resulting_uuid); - - $variants = $trait_object->getVariants(); - $this->assertSame([$uuid => $uuid], $variants->getInstanceIds()); - $this->assertSame([$uuid => $expected_config], $variants->getConfiguration()); - $this->assertSame($plugin_prophecy->reveal(), $variants->get($uuid)); - return [$trait_object, $uuid, $plugin_prophecy->reveal()]; - } - - /** - * @covers ::getVariant - * - * @depends testAddVariant - */ - public function testGetVariant($data) { - list($trait_object, $uuid, $plugin) = $data; - $this->manager->createInstance()->shouldNotBeCalled(); - - $this->assertSame($plugin, $trait_object->getVariant($uuid)); - return [$trait_object, $uuid]; - } - - /** - * @covers ::removeVariant - * - * @depends testGetVariant - */ - public function testRemoveVariant($data) { - list($trait_object, $uuid) = $data; - - $this->assertSame($trait_object, $trait_object->removeVariant($uuid)); - $this->assertFalse($trait_object->getVariants()->has($uuid)); - return [$trait_object, $uuid]; - } - - /** - * @covers ::getVariant - * - * @depends testRemoveVariant - * - * @expectedException \Drupal\Component\Plugin\Exception\PluginNotFoundException - * @expectedExceptionMessage Plugin ID 'test-uuid' was not found. - */ - public function testGetVariantException($data) { - list($trait_object, $uuid) = $data; - // Attempt to retrieve a variant that has been removed. - $this->assertNull($trait_object->getVariant($uuid)); - } - -} - -class TestVariantCollectionTrait { - use VariantCollectionTrait; - - /** - * @var array - */ - protected $variantConfig = []; - - /** - * @var \Drupal\Component\Uuid\UuidInterface - */ - protected $uuidGenerator; - - /** - * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator - * - * @return $this - */ - public function setUuidGenerator(UuidInterface $uuid_generator) { - $this->uuidGenerator = $uuid_generator; - return $this; - } - - /** - * {@inheritdoc} - */ - protected function uuidGenerator() { - return $this->uuidGenerator; - } - - /** - * Sets the variant configuration. - * - * @param array $config - * The variant configuration. - * - * @return $this - */ - public function setVariantConfig(array $config) { - $this->variantConfig = $config; - return $this; - } - - /** - * {@inheritdoc} - */ - protected function getVariantConfig() { - return $this->variantConfig; - } - -} diff --git a/modules/devel/LICENSE.txt b/modules/devel/LICENSE.txt deleted file mode 100644 index d159169..0000000 --- a/modules/devel/LICENSE.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - -' . t('The Devel module provides a suite of modules containing fun for module developers and themers. For more information, see the online documentation for the Devel module.', [':url' => 'https://www.drupal.org/docs/8/modules/devel']) . '
'; - $output .= '' . t('Displays Services and Parameters registered in the Service Container. For more informations on the Service Container, see the Symfony online documentation.', [':url' => 'http://symfony.com/doc/current/service_container.html']) . '
'; - return $output; - - case 'devel.route_info': - $output = ''; - $output .= '' . t('Displays registered routes for the site. For a complete overview of the routing system, see the online documentation.', [':url' => 'https://www.drupal.org/docs/8/api/routing-system']) . '
'; - return $output; - - case 'devel.event_info': - $output = ''; - $output .= '' . t('Displays events and listeners registered in the event dispatcher. For a complete overview of the event system, see the Symfony online documentation.', [':url' => 'http://symfony.com/doc/current/components/event_dispatcher.html']) . '
'; - return $output; - - case 'devel.reinstall': - $output = '' . t('Warning - will delete your module tables and configuration.') . '
'; - $output .= '' . t('Uninstall and then install the selected modules. hook_uninstall()
and hook_install()
will be executed and the schema version number will be set to the most recent update number.') . '
' . t('Here are the contents of your $_SESSION
variable.') . '
' . t('This is a list of state variables and their values. For more information read online documentation of State API in Drupal 8.', array(':documentation' => "https://www.drupal.org/developing/api/8/state")) . '
'; - - case 'devel.layout_info': - $output = ''; - $output .= '' . t('Displays layouts available to the site. For a complete overview of the layout system, see the Layout API documentation.', [':url' => 'https://www.drupal.org/docs/8/api/layout-api']) . '
'; - return $output; - - } -} - -/** - * Implements hook_entity_type_alter(). - */ -function devel_entity_type_alter(array &$entity_types) { - return \Drupal::service('class_resolver') - ->getInstanceFromDefinition(EntityTypeInfo::class) - ->entityTypeAlter($entity_types); -} - -/** - * Implements hook_entity_operation(). - */ -function devel_entity_operation(EntityInterface $entity) { - return \Drupal::service('class_resolver') - ->getInstanceFromDefinition(EntityTypeInfo::class) - ->entityOperation($entity); -} - -/** - * Implements hook_toolbar(). - */ -function devel_toolbar() { - return \Drupal::service('class_resolver') - ->getInstanceFromDefinition(ToolbarHandler::class) - ->toolbar(); -} - -/** - * Implements hook_menu_links_discovered_alter(). - */ -function devel_menu_links_discovered_alter(&$links) { - // Conditionally add the Layouts info menu link. - if (\Drupal::moduleHandler()->moduleExists('layout_discovery')) { - $links['devel.layout_info'] = [ - 'title' => new TranslatableMarkup('Layouts Info'), - 'route_name' => 'devel.layout_info', - 'description' => new TranslatableMarkup('Overview of layouts available to the site.'), - 'menu_name' => 'devel', - ]; - } -} - -/** - * Implements hook_local_tasks_alter(). - */ -function devel_local_tasks_alter(&$local_tasks) { - if (\Drupal::moduleHandler()->moduleExists('toolbar')) { - $local_tasks['devel.toolbar.settings_form'] = [ - 'title' => 'Toolbar Settings', - 'base_route' => 'devel.admin_settings', - 'route_name' => 'devel.toolbar.settings_form', - 'class' => LocalTaskDefault::class, - 'options' => [], - ]; - } -} - -/** - * Sets message. - */ -function devel_set_message($msg, $type = NULL) { - if (function_exists('drush_log')) { - drush_log($msg, $type); - } - else { - drupal_set_message($msg, $type, TRUE); - } -} - -/** - * Gets error handlers. - */ -function devel_get_handlers() { - $error_handlers = \Drupal::config('devel.settings')->get('error_handlers'); - if (!empty($error_handlers)) { - unset($error_handlers[DEVEL_ERROR_HANDLER_NONE]); - } - return $error_handlers; -} - -/** - * Sets a new error handler or restores the prior one. - */ -function devel_set_handler($handlers) { - if (empty($handlers)) { - restore_error_handler(); - } - elseif (count($handlers) == 1 && isset($handlers[DEVEL_ERROR_HANDLER_STANDARD])) { - // Do nothing. - } - else { - set_error_handler('backtrace_error_handler'); - } -} - -/** - * Displays backtrace showing the route of calls to the current error. - * - * @param int $error_level - * The level of the error raised. - * @param string $message - * The error message. - * @param string $filename - * The filename that the error was raised in. - * @param int $line - * The line number the error was raised at. - * @param array $context - * An array that points to the active symbol table at the point the error - * occurred. - */ -function backtrace_error_handler($error_level, $message, $filename, $line, $context) { - // Hide stack trace and parameters from unqualified users. - if (!\Drupal::currentUser()->hasPermission('access devel information')) { - // Do what core does in bootstrap.inc and errors.inc. - // (We need to duplicate the core code here rather than calling it - // to avoid having the backtrace_error_handler() on top of the call stack.) - if ($error_level & error_reporting()) { - $types = drupal_error_levels(); - list($severity_msg, $severity_level) = $types[$error_level]; - $backtrace = debug_backtrace(); - $caller = Error::getLastCaller($backtrace); - - // We treat recoverable errors as fatal. - _drupal_log_error(array( - '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error', - '@message' => $message, - '%function' => $caller['function'], - '%file' => $caller['file'], - '%line' => $caller['line'], - 'severity_level' => $severity_level, - 'backtrace' => $backtrace, - ), $error_level == E_RECOVERABLE_ERROR); - } - - return; - } - - // Don't respond to the error if it was suppressed with a '@' - if (error_reporting() == 0) { - return; - } - - // Don't respond to warning caused by ourselves. - if (preg_match('#Cannot modify header information - headers already sent by \\([^\\)]*[/\\\\]devel[/\\\\]#', $message)) { - return; - } - - if ($error_level & error_reporting()) { - // Only write each distinct NOTICE message once, as repeats do not give any - // further information and can choke the page output. - if ($error_level == E_NOTICE) { - static $written = array(); - if (!empty($written[$line][$filename][$message])) { - return; - } - $written[$line][$filename][$message] = TRUE; - } - - $types = drupal_error_levels(); - list($severity_msg, $severity_level) = $types[$error_level]; - - $backtrace = debug_backtrace(); - $caller = Error::getLastCaller($backtrace); - $variables = array( - '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error', - '@message' => $message, - '%function' => $caller['function'], - '%file' => $caller['file'], - '%line' => $caller['line'], - ); - $msg = t('%type: @message in %function (line %line of %file).', $variables); - - // Show message if error_level is ERROR_REPORTING_DISPLAY_SOME or higher. - // (This is Drupal's error_level, which is different from $error_level, - // and we purposely ignore the difference between _SOME and _ALL, - // see #970688!) - if (\Drupal::config('system.logging')->get('error_level') != 'hide') { - $error_handlers = devel_get_handlers(); - if (!empty($error_handlers[DEVEL_ERROR_HANDLER_STANDARD])) { - drupal_set_message($msg, ($severity_level <= RfcLogLevel::NOTICE ? 'error' : 'warning'), TRUE); - } - if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_KINT])) { - print kpr(ddebug_backtrace(TRUE, 1), TRUE, $msg); - } - if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_DPM])) { - dpm(ddebug_backtrace(TRUE, 1), $msg, 'warning'); - } - } - - \Drupal::logger('php')->log($severity_level, $msg); - } -} - -/** - * Implements hook_page_attachments_alter(). - */ -function devel_page_attachments_alter(&$page) { - if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('page_alter')) { - dpm($page, 'page'); - } -} - -/** - * Wrapper for DevelDumperManager::dump(). - * - * Calls the http://www.firephp.org/ fb() function if it is found. - * - * @see \Drupal\devel\DevelDumperManager::dump() - */ -function dfb() { - $args = func_get_args(); - \Drupal::service('devel.dumper')->dump($args, NULL, 'firephp'); -} - -/** - * Wrapper for DevelDumperManager::dump(). - * - * Calls dfb() to output a backtrace. - * - * @see \Drupal\devel\DevelDumperManager::dump() - */ -function dfbt($label) { - \Drupal::service('devel.dumper')->dump(FirePHP::TRACE, $label, 'firephp'); -} - -/** - * Wrapper for DevelDumperManager::dump(). - * - * Wrapper for ChromePHP Class log method. - * - * @see \Drupal\devel\DevelDumperManager::dump() - */ -function dcp() { - $args = func_get_args(); - \Drupal::service('devel.dumper')->dump($args, NULL, 'chromephp'); -} - -if (!function_exists('dd')) { - /** - * Wrapper for DevelDumperManager::debug(). - * - * @see \Drupal\devel\DevelDumperManager::debug() - */ - function dd($data, $label = NULL) { - return \Drupal::service('devel.dumper')->debug($data, $label, 'default'); - } -} - -/** - * Wrapper for DevelDumperManager::message(). - * - * Prints a variable to the 'message' area of the page. - * - * Uses drupal_set_message(). - * - * @param $input - * An arbitrary value to output. - * @param string $name - * Optional name for identifying the output. - * @param string $type - * Optional message type for drupal_set_message(), defaults to 'status'. - * - * @return input - * The unaltered input value. - * - * @see \Drupal\devel\DevelDumperManager::message() - */ -function dpm($input, $name = NULL, $type = 'status') { - \Drupal::service('devel.dumper')->message($input, $name, $type); - return $input; -} - -/** - * Wrapper for DevelDumperManager::message(). - * - * Displays a Variable::export() variable to the 'message' area of the page. - * - * Uses drupal_set_message(). - * - * @param $input - * An arbitrary value to output. - * @param string $name - * Optional name for identifying the output. - * - * @return input - * The unaltered input value. - * - * @see \Drupal\devel\DevelDumperManager::message() - */ -function dvm($input, $name = NULL) { - \Drupal::service('devel.dumper')->message($input, $name, 'status', 'drupal_variable'); - return $input; -} - -/** - * An alias for dpm(), for historic reasons. - */ -function dsm($input, $name = NULL) { - return dpm($input, $name); -} - -/** - * Wrapper for DevelDumperManager::dumpOrExport(). - * - * An alias for the devel.dumper service. Saves carpal tunnel syndrome. - * - * @see \Drupal\devel\DevelDumperManager::dumpOrExport() - */ -function dpr($input, $export = FALSE, $name = NULL) { - return \Drupal::service('devel.dumper')->dumpOrExport($input, $name, $export, 'default'); -} - -/** - * Wrapper for DevelDumperManager::dumpOrExport(). - * - * An alias for devel_dump(). Saves carpal tunnel syndrome. - * - * @see \Drupal\devel\DevelDumperManager::dumpOrExport() - */ -function kpr($input, $export = FALSE, $name = NULL) { - return \Drupal::service('devel.dumper')->dumpOrExport($input, $name, $export); -} - -/** - * Wrapper for DevelDumperManager::dumpOrExport(). - * - * Like dpr(), but uses Variable::export() instead. - * - * @see \Drupal\devel\DevelDumperManager::dumpOrExport() - */ -function dvr($input, $export = FALSE, $name = NULL) { - return \Drupal::service('devel.dumper')->dumpOrExport($input, $name, $export, 'drupal_variable'); -} - -/** - * Prints the arguments passed into the current function. - */ -function dargs($always = TRUE) { - static $printed; - if ($always || !$printed) { - $bt = debug_backtrace(); - print kpr($bt[1]['args'], TRUE); - $printed = TRUE; - } -} - -/** - * Prints a SQL string from a DBTNG Select object. Includes quoted arguments. - * - * @param object $query - * An object that implements the SelectInterface interface. - * @param boolean $return - * Whether to return the string. Default is FALSE, meaning to print it - * and return $query instead. - * @param string $name - * Optional name for identifying the output. - * - * @return object|string - * The $query object, or the query string if $return was TRUE. - */ -function dpq($query, $return = FALSE, $name = NULL) { - if (\Drupal::currentUser()->hasPermission('access devel information')) { - if (method_exists($query, 'preExecute')) { - $query->preExecute(); - } - $sql = (string) $query; - $quoted = array(); - $connection = Database::getConnection(); - foreach ((array) $query->arguments() as $key => $val) { - $quoted[$key] = is_null($val) ? 'NULL' : $connection->quote($val); - } - $sql = strtr($sql, $quoted); - if ($return) { - return $sql; - } - dpm($sql, $name); - } - return ($return ? NULL : $query); -} - -/** - * Prints a renderable array element to the screen using kprint_r(). - * - * #pre_render and/or #post_render pass-through callback for kprint_r(). - * - * @todo Investigate appending to #suffix. - * @todo Investigate label derived from #id, #title, #name, and #theme. - */ -function devel_render() { - $args = func_get_args(); - // #pre_render and #post_render pass the rendered $element as last argument. - kpr(end($args)); - // #pre_render and #post_render expect the first argument to be returned. - return reset($args); -} - -/** - * Prints the function call stack. - * - * @param $return - * Pass TRUE to return the formatted backtrace rather than displaying it in - * the browser via kprint_r(). - * @param $pop - * How many items to pop from the top of the stack; useful when calling from - * an error handler. - * @param $options - * Options to pass on to PHP's debug_backtrace(). - * - * @return string|NULL - * The formatted backtrace, if requested, or NULL. - * - * @see http://php.net/manual/en/function.debug-backtrace.php - */ -function ddebug_backtrace($return = FALSE, $pop = 0, $options = DEBUG_BACKTRACE_PROVIDE_OBJECT) { - if (\Drupal::currentUser()->hasPermission('access devel information')) { - $backtrace = debug_backtrace($options); - while ($pop-- > 0) { - array_shift($backtrace); - } - $counter = count($backtrace); - $path = $backtrace[$counter - 1]['file']; - $path = substr($path, 0, strlen($path) - 10); - $paths[$path] = strlen($path) + 1; - $paths[DRUPAL_ROOT] = strlen(DRUPAL_ROOT) + 1; - $nbsp = "\xC2\xA0"; - - // Show message if error_level is ERROR_REPORTING_DISPLAY_SOME or higher. - // (This is Drupal's error_level, which is different from $error_level, - // and we purposely ignore the difference between _SOME and _ALL, - // see #970688!) - if (\Drupal::config('system.logging')->get('error_level') != 'hide') { - while (!empty($backtrace)) { - $call = array(); - if (isset($backtrace[0]['file'])) { - $call['file'] = $backtrace[0]['file']; - foreach ($paths as $path => $len) { - if (strpos($backtrace[0]['file'], $path) === 0) { - $call['file'] = substr($backtrace[0]['file'], $len); - } - } - $call['file'] .= ':' . $backtrace[0]['line']; - } - if (isset($backtrace[1])) { - if (isset($backtrace[1]['class'])) { - $function = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()'; - } - else { - $function = $backtrace[1]['function'] . '()'; - } - $backtrace[1] += array('args' => array()); - foreach ($backtrace[1]['args'] as $key => $value) { - $call['args'][$key] = $value; - } - } - else { - $function = 'main()'; - $call['args'] = $_GET; - } - $nicetrace[($counter <= 10 ? $nbsp : '') . --$counter . ': ' . $function] = $call; - array_shift($backtrace); - } - if ($return) { - return $nicetrace; - } - kpr($nicetrace); - } - } -} - -/** - * Implements hook_form_FORM_ID_alter(). - * - * Adds mouse-over hints on the Permissions page to display - * language-independent machine names and module base names. - * - * @see \Drupal\user\Form\UserPermissionsForm::buildForm() - */ -function devel_form_user_admin_permissions_alter(&$form, FormStateInterface $form_state) { - if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('raw_names')) { - foreach (Element::children($form['permissions']) as $key) { - if (isset($form['permissions'][$key][0])) { - $form['permissions'][$key][0]['#wrapper_attributes']['title'] = $key; - } - elseif(isset($form['permissions'][$key]['description'])) { - $form['permissions'][$key]['description']['#wrapper_attributes']['title'] = $key; - } - } - } -} - -/** - * Implements hook_form_FORM_ID_alter(). - * - * Adds mouse-over hints on the Modules page to display module base names. - * - * @see \Drupal\system\Form\ModulesListForm::buildForm() - * @see theme_system_modules_details() - */ -function devel_form_system_modules_alter(&$form, FormStateInterface $form_state) { - if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('raw_names', FALSE) && isset($form['modules']) && is_array($form['modules'])) { - foreach (Element::children($form['modules']) as $group) { - if (is_array($form['modules'][$group])) { - foreach (Element::children($form['modules'][$group]) as $key) { - if (isset($form['modules'][$group][$key]['name']['#markup'])) { - $form['modules'][$group][$key]['name']['#markup'] = '' . $form['modules'][$group][$key]['name']['#markup'] . ''; - } - } - } - } - } -} - -/** - * Implements hook_query_TAG_alter(). - * - * Makes debugging entity query much easier. - * - * Example usage: - * @code - * $query = \Drupal::entityQuery('node'); - * $query->condition('status', NODE_PUBLISHED); - * $query->addTag('debug'); - * $query->execute(); - * @endcode - */ -function devel_query_debug_alter(AlterableInterface $query) { - if (!$query->hasTag('debug-semaphore')) { - $query->addTag('debug-semaphore'); - dpq($query); - } -} diff --git a/modules/devel/devel.permissions.yml b/modules/devel/devel.permissions.yml deleted file mode 100644 index 256919d..0000000 --- a/modules/devel/devel.permissions.yml +++ /dev/null @@ -1,14 +0,0 @@ -access devel information: - description: 'View developer output like variable printouts, query log, etc.' - title: 'Access developer information' - restrict access: TRUE - -execute php code: - title: 'Execute PHP code' - description: 'Run arbitrary PHP from a block.' - restrict access: TRUE - -switch users: - title: 'Switch users' - description: 'Become any user on the site with just a click.' - restrict access: TRUE diff --git a/modules/devel/devel.routing.yml b/modules/devel/devel.routing.yml deleted file mode 100644 index 8d20e90..0000000 --- a/modules/devel/devel.routing.yml +++ /dev/null @@ -1,278 +0,0 @@ -devel.admin_settings: - path: '/admin/config/development/devel' - defaults: - _form: '\Drupal\devel\Form\SettingsForm' - _title: 'Devel settings' - requirements: - _permission: 'administer site configuration' - -devel.toolbar.settings_form: - path: '/admin/config/development/devel/toolbar' - defaults: - _form: '\Drupal\devel\Form\ToolbarSettingsForm' - _title: 'Devel Toolbar Settings' - requirements: - _permission: 'administer site configuration' - _module_dependencies: 'toolbar' - -devel.reinstall: - path: '/devel/reinstall' - defaults: - _form: '\Drupal\devel\Form\DevelReinstall' - _title: 'Reinstall modules' - options: - _admin_route: TRUE - requirements: - _permission: 'administer site configuration' - -devel.menu_rebuild: - path: '/devel/menu/reset' - defaults: - _form: '\Drupal\devel\Form\RouterRebuildConfirmForm' - _title: 'Rebuild router' - options: - _admin_route: TRUE - requirements: - _permission: 'administer site configuration' - -devel.configs_list: - path: '/devel/config/{filter}' - options: - _admin_route: TRUE - defaults: - _form: '\Drupal\devel\Form\ConfigsList' - _title: 'Config editor' - filter: '' - requirements: - _permission: 'administer site configuration' - -devel.config_edit: - path: '/devel/config/edit/{config_name}' - defaults: - _form: '\Drupal\devel\Form\ConfigEditor' - _title: 'Edit configuration object: @config_name' - options: - _admin_route: TRUE - requirements: - _permission: 'administer site configuration' - -devel.state_system_page: - path: '/devel/state' - defaults: - _controller: '\Drupal\devel\Controller\DevelController::stateSystemPage' - _title: 'State editor' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.system_state_edit: - path: '/devel/state/edit/{state_name}' - defaults: - _form: '\Drupal\devel\Form\SystemStateEdit' - _title: 'Edit state variable: @state_name' - options: - _admin_route: TRUE - requirements: - _permission: 'administer site configuration' - -devel.theme_registry: - path: '/devel/theme/registry' - defaults: - _controller: '\Drupal\devel\Controller\DevelController::themeRegistry' - _title: 'Theme registry' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.field_info_page: - path: '/devel/field/info' - defaults: - _controller: '\Drupal\devel\Controller\DevelController::fieldInfoPage' - _title: 'Field info' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.execute_php: - path: '/devel/php' - defaults: - _form: '\Drupal\devel\Form\ExecutePHP' - _title: 'Execute PHP code' - options: - _admin_route: TRUE - requirements: - _permission: 'execute php code' - -devel.session: - path: '/devel/session' - defaults: - _controller: '\Drupal\devel\Controller\DevelController::session' - _title: 'Session viewer' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.switch: - path: '/devel/switch/{name}' - defaults: - _controller: '\Drupal\devel\Controller\SwitchUserController::switchUser' - _title: 'Switch user' - name: '' - options: - _admin_route: TRUE - requirements: - _permission: 'switch users' - _csrf_token: 'TRUE' - -devel.cache_clear: - path: '/devel/cache/clear' - defaults: - _controller: '\Drupal\devel\Controller\DevelController::cacheClear' - _title: 'Clear cache' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - _csrf_token: 'TRUE' - -devel.run_cron: - path: '/devel/run-cron' - defaults: - _controller: '\Drupal\system\CronController::runManually' - _title: 'Run cron' - options: - _admin_route: TRUE - requirements: - _permission: 'administer site configuration' - _csrf_token: 'TRUE' - -# Container info -devel.container_info.service: - path: '/devel/container/service' - defaults: - _controller: '\Drupal\devel\Controller\ContainerInfoController::serviceList' - _title: 'Container services' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.container_info.service.detail: - path: '/devel/container/service/{service_id}' - defaults: - _controller: '\Drupal\devel\Controller\ContainerInfoController::serviceDetail' - _title: 'Service @service_id detail' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.container_info.parameter: - path: '/devel/container/parameter' - defaults: - _controller: '\Drupal\devel\Controller\ContainerInfoController::parameterList' - _title: 'Container parameters' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.container_info.parameter.detail: - path: '/devel/container/parameter/{parameter_name}' - defaults: - _controller: '\Drupal\devel\Controller\ContainerInfoController::parameterDetail' - _title: 'Parameter @parameter_name value' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -# Route info -devel.route_info: - path: '/devel/routes' - defaults: - _controller: '\Drupal\devel\Controller\RouteInfoController::routeList' - _title: 'Routes' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.route_info.item: - path: '/devel/routes/item' - defaults: - _controller: '\Drupal\devel\Controller\RouteInfoController::routeDetail' - _title: 'Route detail' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -# Event info -devel.event_info: - path: '/devel/events' - defaults: - _controller: '\Drupal\devel\Controller\EventInfoController::eventList' - _title: 'Events' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -# Layouts info -devel.layout_info: - path: '/devel/layouts' - defaults: - _controller: '\Drupal\devel\Controller\LayoutInfoController::layoutInfoPage' - _title: 'Layouts' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - _module_dependencies: 'layout_discovery' - -# Element info -devel.elements_page: - path: '/devel/elements' - defaults: - _controller: '\Drupal\devel\Controller\ElementInfoController::elementList' - _title: 'Element Info' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.elements_page.detail: - path: '/devel/elements/{element_name}' - defaults: - _controller: '\Drupal\devel\Controller\ElementInfoController::elementDetail' - _title: 'Element @element_name' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -# Entity type info -devel.entity_info_page: - path: '/devel/entity/info' - defaults: - _controller: '\Drupal\devel\Controller\EntityTypeInfoController::entityTypeList' - _title: 'Entity info' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' - -devel.entity_info_page.detail: - path: '/devel/entity/info/{entity_type_id}' - defaults: - _controller: '\Drupal\devel\Controller\EntityTypeInfoController::entityTypeDetail' - _title: 'Entity type @entity_type_id' - options: - _admin_route: TRUE - requirements: - _permission: 'access devel information' diff --git a/modules/devel/devel.services.yml b/modules/devel/devel.services.yml deleted file mode 100644 index 2e74e1a..0000000 --- a/modules/devel/devel.services.yml +++ /dev/null @@ -1,32 +0,0 @@ -services: - devel.error_subscriber: - class: Drupal\devel\EventSubscriber\ErrorHandlerSubscriber - arguments: ['@current_user'] - tags: - - { name: event_subscriber } - - devel.theme_rebuild_subscriber: - class: Drupal\devel\EventSubscriber\ThemeInfoRebuildSubscriber - arguments: ['@config.factory', '@current_user', '@theme_handler'] - tags: - - { name: event_subscriber } - - devel.route_subscriber: - class: Drupal\devel\Routing\RouteSubscriber - arguments: ['@entity_type.manager'] - tags: - - { name: event_subscriber } - - plugin.manager.devel_dumper: - class: Drupal\devel\DevelDumperPluginManager - parent: default_plugin_manager - - devel.dumper: - class: Drupal\devel\DevelDumperManager - arguments: ['@config.factory', '@current_user', '@plugin.manager.devel_dumper'] - - devel.twig.debug_extension: - class: Drupal\devel\Twig\Extension\Debug - arguments: ['@devel.dumper'] - tags: - - { name: twig.extension } diff --git a/modules/devel/devel_generate/README.txt b/modules/devel/devel_generate/README.txt deleted file mode 100644 index 2d73ba9..0000000 --- a/modules/devel/devel_generate/README.txt +++ /dev/null @@ -1,44 +0,0 @@ -This module creates the "DevelGenerate" plugin type. - -All you need to do to provide a new instance for "DevelGenerate" plugin type -is to create your class extending "DevelGenerateBase" and following the next steps. - -1 - Declaring your plugin with annotations: - -/** - * Provides a ExampleDevelGenerate plugin. - * - * @DevelGenerate( - * id = "example", - * label = @Translation("example"), - * description = @Translation("Generate a given number of example elements. Optionally delete current example elements."), - * url = "example", - * permission = "administer example", - * settings = { - * "num" = 50, - * "kill" = FALSE, - * "another_property" = "default_value" - * } - * ) - */ - -2 - Implement "settingsForm" method to create a form using the properties from annotations. - -3 - Implement "handleDrushParams" method. It should return an array of values. - -4 - Implement "generateElements" method. You can write here your business logic -using the array of values. - -Notes: - -You can alter existing properties for every plugin implementing hook_devel_generate_info_alter. - -DevelGenerateBaseInterface details base wrapping methods that most DevelGenerate implementations -will want to directly inherit from Drupal\devel_generate\DevelGenerateBase. - -To give support for a new field type the field type base class should properly -implements \Drupal\Core\Field\FieldItemInterface::generateSampleValue(). -Devel generate automatically use the values returned by this method during the -generate process for generate placeholder field values. For more information -see: -https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21FieldItemInterface.php/function/FieldItemInterface::generateSampleValue diff --git a/modules/devel/devel_generate/devel_generate.batch.inc b/modules/devel/devel_generate/devel_generate.batch.inc deleted file mode 100644 index 2bfa690..0000000 --- a/modules/devel/devel_generate/devel_generate.batch.inc +++ /dev/null @@ -1,25 +0,0 @@ -$method($vars, $context); -} - -/** - * Common finish batch function available for - * every DevelGeneratePlugin. - */ -function devel_generate_batch_finished($success, $results, $operations) { - - if ($success) { - $message = t('Finished @num elements created successfully.', array('@num' => $results['num'])); - } - else { - $message = t('Finished with an error.'); - } - drupal_set_message($message); -} diff --git a/modules/devel/devel_generate/devel_generate.info.yml b/modules/devel/devel_generate/devel_generate.info.yml deleted file mode 100644 index 890261d..0000000 --- a/modules/devel/devel_generate/devel_generate.info.yml +++ /dev/null @@ -1,13 +0,0 @@ -type: module -name: 'Devel generate' -description: 'Generate dummy users, nodes, menus, taxonomy terms...' -package: Development -# core: 8.x -tags: - - developer - -# Information added by Drupal.org packaging script on 2017-10-05 -version: '8.x-1.2' -core: '8.x' -project: 'devel' -datestamp: 1507197848 diff --git a/modules/devel/devel_generate/devel_generate.module b/modules/devel/devel_generate/devel_generate.module deleted file mode 100644 index 530a4fb..0000000 --- a/modules/devel/devel_generate/devel_generate.module +++ /dev/null @@ -1,145 +0,0 @@ -getDefinitions(); - foreach ($devel_generate_plugins as $id => $plugin) { - $label = $plugin['label']; - $links["devel_generate.$id"] = array( - 'title' => "Generate $label", - 'parent' => 'system.admin_config_development', - 'description' => $plugin['description'], - 'route_name' => "devel_generate.$id", - ); - } -} - -/** - * Implements hook_entity_insert(). - * - * Inserts nodes properly based on generation options. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The base node created on submit. Inspects $node->devel_generate. - */ -function devel_generate_entity_insert(EntityInterface $entity) { - if ($entity->getEntityTypeId() != 'node' || !isset($entity->devel_generate)) { - return; - } - /** @var \Drupal\node\NodeInterface $entity */ - $results = $entity->devel_generate; - - if (!empty($results['max_comments'])) { - foreach ($entity->getFieldDefinitions() as $field_name => $field_definition) { - if ($field_definition->getType() == 'comment' && $entity->get($field_name)->status == CommentItemInterface::OPEN) { - // Add comments for each comment field on entity. - devel_generate_add_comments($entity, $field_definition, $results['users'], $results['max_comments'], $results['title_length']); - } - } - } - - // Add an url alias. Cannot happen before save because we don't know the nid. - if (!empty($results['add_alias'])) { - $path = array( - 'source' => '/node/' . $entity->id(), - 'alias' => '/node-' . $entity->id() . '-' . $entity->bundle(), - ); - \Drupal::service('path.alias_storage')->save($path['source'], $path['alias']); - } - - // Add node statistics. - if (!empty($results['add_statistics']) && \Drupal::moduleHandler()->moduleExists('statistics')) { - devel_generate_add_statistics($entity); - } -} - -/** - * Create comments and add them to a node. - * - * @param \Drupal\node\NodeInterface $node - * Node to add comments to. - * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition - * The field storage definition. - * @param array $users - * Array of users to assign comment authors. - * @param int $max_comments - * Max number of comments to generate per node. - * @param int $title_length - * Max length of the title of the comments. - */ -function devel_generate_add_comments(NodeInterface $node, FieldDefinitionInterface $field_definition, $users, $max_comments, $title_length = 8) { - $parents = array(); - $field_name = $field_definition->getName(); - $num_comments = mt_rand(1, $max_comments); - for ($i = 1; $i <= $num_comments; $i++) { - switch ($i % 3) { - case 0: - // No parent. - case 1: - // Top level parent. - $parents = \Drupal::entityQuery('comment') - ->condition('pid', 0) - ->condition('entity_id', $node->id()) - ->condition('entity_type', 'node') - ->condition('field_name', $field_name) - ->range(0, 1) - ->execute(); - break; - case 2: - // Non top level parent. - $parents = \Drupal::entityQuery('comment') - ->condition('pid', 0, '>') - ->condition('entity_id', $node->id()) - ->condition('entity_type', 'node') - ->condition('field_name', $field_name) - ->range(0, 1) - ->execute(); - break; - } - $random = new Random(); - $stub = array( - 'entity_type' => $node->getEntityTypeId(), - 'entity_id' => $node->id(), - 'field_name' => $field_name, - 'name' => 'devel generate', - 'mail' => 'devel_generate@example.com', - 'timestamp' => mt_rand($node->getCreatedTime(), REQUEST_TIME), - 'subject' => substr($random->sentences(mt_rand(2, $title_length), TRUE), 0, 63), - 'uid' => $users[array_rand($users)], - 'langcode' => $node->language()->getId(), - ); - if ($parents) { - $stub['pid'] = current($parents); - } - $comment = entity_create('comment', $stub); - - //Populate all core fields on behalf of field.module - DevelGenerateBase::populateFields($comment); - $comment->save(); - } -} - -/** - * Generate statistics information for a node. - * - * @param \Drupal\node\NodeInterface $node - * A node object. - */ -function devel_generate_add_statistics(NodeInterface $node) { - $statistic = array( - 'nid' => $node->id(), - 'totalcount' => mt_rand(0, 500), - 'timestamp' => REQUEST_TIME - mt_rand(0, $node->getCreatedTime()), - ); - $statistic['daycount'] = mt_rand(0, $statistic['totalcount']); - db_insert('node_counter')->fields($statistic)->execute(); -} diff --git a/modules/devel/devel_generate/devel_generate.permissions.yml b/modules/devel/devel_generate/devel_generate.permissions.yml deleted file mode 100644 index 10f9479..0000000 --- a/modules/devel/devel_generate/devel_generate.permissions.yml +++ /dev/null @@ -1,5 +0,0 @@ -administer devel_generate: - title: 'Administer devel_generate' - -permission_callbacks: - - \Drupal\devel_generate\DevelGeneratePermissions::permissions diff --git a/modules/devel/devel_generate/devel_generate.routing.yml b/modules/devel/devel_generate/devel_generate.routing.yml deleted file mode 100644 index eeea668..0000000 --- a/modules/devel/devel_generate/devel_generate.routing.yml +++ /dev/null @@ -1,2 +0,0 @@ -route_callbacks: - - '\Drupal\devel_generate\Routing\DevelGenerateRoutes::routes' \ No newline at end of file diff --git a/modules/devel/devel_generate/devel_generate.services.yml b/modules/devel/devel_generate/devel_generate.services.yml deleted file mode 100644 index 16025e1..0000000 --- a/modules/devel/devel_generate/devel_generate.services.yml +++ /dev/null @@ -1,4 +0,0 @@ -services: - plugin.manager.develgenerate: - class: Drupal\devel_generate\DevelGeneratePluginManager - parent: default_plugin_manager diff --git a/modules/devel/devel_generate/drush.services.yml b/modules/devel/devel_generate/drush.services.yml deleted file mode 100644 index e008b6c..0000000 --- a/modules/devel/devel_generate/drush.services.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - develgenerate.command: - class: Drupal\devel_generate\Commands\DevelGenerateCommands - arguments: ['@plugin.manager.develgenerate'] - tags: - - { name: drush.command } - diff --git a/modules/devel/devel_generate/drush/devel_generate.drush8.inc b/modules/devel/devel_generate/drush/devel_generate.drush8.inc deleted file mode 100644 index e28226d..0000000 --- a/modules/devel/devel_generate/drush/devel_generate.drush8.inc +++ /dev/null @@ -1,196 +0,0 @@ - 'drush_devel_generate', - 'callback arguments' => array( - 'plugin_id' => 'user', - ), - 'description' => 'Create users.', - 'arguments' => array( - 'num' => 'Number of users to generate.', - ), - 'options' => array( - 'kill' => 'Delete all users before generating new ones.', - 'roles' => 'A comma delimited list of role IDs which should be granted to the new users. No need to specify authenticated user role.', - 'pass' => 'Specify a password to be set for all generated users.', - ), - 'aliases' => array('genu'), - ); - $items['generate-terms'] = array( - 'callback' => 'drush_devel_generate', - 'callback arguments' => array( - 'plugin_id' => 'term', - ), - 'description' => 'Create terms in specified vocabulary.', - 'arguments' => array( - 'machine_name' => 'Vocabulary machine name into which new terms will be inserted.', - 'num' => 'Number of terms to insert. Defaults to 10.', - ), - 'options' => array( - 'kill' => 'Delete all terms in specified vocabulary before generating.', - 'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 1000', - 'pipe' => 'Returns the list of generated terms, one per line.', - ), - 'aliases' => array('gent'), - - ); - $items['generate-vocabs'] = array( - 'callback' => 'drush_devel_generate', - 'callback arguments' => array( - 'plugin_id' => 'vocabulary', - ), - 'description' => 'Create vocabularies.', - 'arguments' => array( - 'num' => 'Number of vocabularies to create. Defaults to 1.', - ), - 'options' => array( - 'kill' => 'Delete all vocabularies before generating.', - 'pipe' => 'Returns the list of generated vocabularies, one per line.', - ), - 'aliases' => array('genv'), - ); - $items['generate-content'] = array( - 'callback' => 'drush_devel_generate', - 'callback arguments' => array( - 'plugin_id' => 'content', - ), - 'description' => 'Create content.', - 'drupal dependencies' => array('devel_generate'), - 'arguments' => array( - 'num' => 'Number of nodes to generate.', - 'max_comments' => 'Maximum number of comments to generate.', - ), - 'options' => array( - 'kill' => 'Delete all content before generating new content.', - 'types' => 'A comma delimited list of content types to create. Defaults to page,article.', - 'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 1000', - 'skip-fields' => 'A comma delimited list of fields to omit when generating random values', - 'languages' => 'A comma-separated list of language codes', - ), - 'aliases' => array('genc'), - ); - $items['generate-menus'] = array( - 'callback' => 'drush_devel_generate', - 'callback arguments' => array( - 'plugin_id' => 'menu', - ), - 'description' => 'Create menus and menu items.', - 'drupal dependencies' => array('devel_generate'), // Remove these once devel.module is moved down a directory. http://drupal.org/node/925246 - 'arguments' => array( - 'number_menus' => 'Number of menus to generate. Defaults to 2.', - 'number_links' => 'Number of links to generate. Defaults to 50.', - 'max_depth' => 'Max link depth. Defaults to 3', - 'max_width' => 'Max width of first level of links. Defaults to 8.', - ), - 'options' => array( - 'kill' => 'Delete all previously generated menus and links before generating new menus and links.', - 'pipe' => 'Returns the list of generated menus, one per line.', - ), - 'aliases' => array('genm'), - ); - return $items; -} - -/** - * Implements drush_hook_COMMAND_validate(). - */ -function drush_devel_generate_generate_users_validate() { - - //Array of "Callback arguments" and "command line args". - $params = func_get_args(); - _drush_plugin_validate($params); -} - -/** - * Implements drush_hook_COMMAND_validate(). - */ -function drush_devel_generate_generate_terms_validate() { - - //Array of "Callback arguments" and "command line args". - $params = func_get_args(); - _drush_plugin_validate($params); -} - -/** - * Implements drush_hook_COMMAND_validate(). - */ -function drush_devel_generate_generate_vocabs_validate() { - - //Array of "Callback arguments" and "command line args". - $params = func_get_args(); - _drush_plugin_validate($params); -} - -/** - * Implements drush_hook_COMMAND_validate(). - */ -function drush_devel_generate_generate_content_validate() { - - //Array of "Callback arguments" and "command line args". - $params = func_get_args(); - _drush_plugin_validate($params); -} - -/** - * Implements drush_hook_COMMAND_validate(). - */ -function drush_devel_generate_generate_menus_validate() { - - //Array of "Callback arguments" and "command line args". - $params = func_get_args(); - _drush_plugin_validate($params); -} - -/** - * Helper function which returns an array with a plugin instance - * for a given id and the validated values ready to be used by - * the generate() function of the plugin. - */ -function _drush_plugin_validate($params) { - - $instance_and_values = &drupal_static('drush_devel_generate_generate_validate'); - //Getting plugin_id and leaving the command line args - $plugin_id = array_shift($params); - - if (!isset($instance_and_values[$plugin_id])) { - - /** @var DevelGeneratePluginManager $manager */ - $manager = \Drupal::service('plugin.manager.develgenerate'); - - /** @var DevelGenerateBaseInterface $instance */ - $instance = $manager->createInstance($plugin_id, array()); - - //Plugin instance suit params in order to fit for generateElements - $values = $instance->validateDrushParams($params); - $instance_and_values[$plugin_id]['instance'] = $instance; - $instance_and_values[$plugin_id]['values'] = $values; - } - - return $instance_and_values[$plugin_id]; -} - -/** - * Command callback. Generate a number of elements. - */ -function drush_devel_generate() { - $params = func_get_args(); - $plugin_id = array_shift($params); - $instance_and_values = drupal_static('drush_devel_generate_generate_validate'); - - /** @var DevelGenerateBaseInterface $instance */ - $instance = $instance_and_values[$plugin_id]['instance']; - $values = $instance_and_values[$plugin_id]['values']; - $instance->generate($values); - -} diff --git a/modules/devel/devel_generate/src/Annotation/DevelGenerate.php b/modules/devel/devel_generate/src/Annotation/DevelGenerate.php deleted file mode 100644 index 9a0ce25..0000000 --- a/modules/devel/devel_generate/src/Annotation/DevelGenerate.php +++ /dev/null @@ -1,86 +0,0 @@ -setManager($manager); - } - - /** - * @return \Drupal\devel_generate\DevelGenerateBaseInterface - */ - public function getManager() { - return $this->manager; - } - - /** - * @param \Drupal\devel_generate\DevelGenerateBaseInterface $manager - */ - public function setManager($manager) { - $this->manager = $manager; - } - - /** - * @return mixed - */ - public function getPluginInstance() { - return $this->pluginInstance; - } - - /** - * @param mixed $pluginInstance - */ - public function setPluginInstance($pluginInstance) { - $this->pluginInstance = $pluginInstance; - } - - /** - * @return array - */ - public function getParameters() { - return $this->parameters; - } - - /** - * @param array $parameters - */ - public function setParameters($parameters) { - $this->parameters = $parameters; - } - - /** - * Create users. - * - * @command devel-generate-users - * @pluginId user - * @param $num Number of users to generate. - * @option kill Delete all users before generating new ones. - * @option roles A comma delimited list of role IDs for new users. Don't specify 'authenticated'. - * @option pass Specify a password to be set for all generated users. - * @aliases genu - */ - public function users($num = 50, $options = ['kill' => FALSE, 'roles' => '']) { - // @todo pass $options to the plugins. - $this->generate(); - } - - /** - * Create terms in specified vocabulary. - * - * @command devel-generate-terms - * @pluginId term - * @param $machine_name Vocabulary machine name into which new terms will be inserted. - * @param $num Number of terms to generate. - * @option kill Delete all terms before generating new ones. - * @option feedback An integer representing interval for insertion rate logging. - * @validate-entity-load taxonomy_vocabulary machine_name - * @aliases gent - */ - public function terms($machine_name, $num = 50, $options = ['feedback' => 1000]) { - $this->generate(); - } - - /** - * Create vocabularies. - * - * @command devel-generate-vocabs - * @pluginId vocabulary - * @param $num Number of vocabularies to generate. - * @option kill Delete all vocabs before generating new ones. - * @aliases genv - * @validate-module-enabled taxonomy - */ - public function vocabs($num = 1, $options = ['kill' => FALSE]) { - $this->generate(); - } - - /** - * Create menus. - * - * @command devel-generate-menus - * @pluginId menu - * @param $number_menus Number of menus to generate. - * @param $number_links Number of links to generate. - * @param $max_depth Max link depth. - * @param $max_width Max width of first level of links. - * @option kill Delete all content before generating new content. - * @aliases genm - * @validate-module-enabled menu_link_content - */ - public function menus($number_menus = 2, $number_links = 50, $max_depth = 3, $max_width = 8, $options = ['kill' => FALSE]) { - $this->generate(); - } - - /** - * Create content. - * - * @command devel-generate-content - * @pluginId content - * @param $num Number of nodes to generate. - * @param $max_comments Maximum number of comments to generate. - * @option kill Delete all content before generating new content. - * @option types A comma delimited list of content types to create. Defaults to page,article. - * @option feedback An integer representing interval for insertion rate logging. - * @option skip-fields A comma delimited list of fields to omit when generating random values - * @option languages A comma-separated list of language codes - * @aliases genc - * @validate-module-enabled node - */ - public function content($num = 50, $max_comments = 0, $options = ['kill' => FALSE, 'types' => 'page,article', 'feedback' => 1000]) { - $this->generate(); - drush_backend_batch_process(); - } - - - /** - * @hook validate - * @param \Consolidation\AnnotatedCommand\CommandData $commandData - * @return \Consolidation\AnnotatedCommand\CommandError|null - */ - public function validate(CommandData $commandData) { - $manager = $this->getManager(); - $args = $commandData->input()->getArguments(); - $commandName = array_shift($args); - /** @var DevelGenerateBaseInterface $instance */ - $instance = $manager->createInstance($commandData->annotationData()->get('pluginId'), array()); - $this->setPluginInstance($instance); - $parameters = $instance->validateDrushParams($args, $commandData->input()->getOptions()); - $this->setParameters($parameters); - } - - public function generate() { - $instance = $this->getPluginInstance(); - $instance->generate($this->getParameters()); - } -} diff --git a/modules/devel/devel_generate/src/DevelGenerateBase.php b/modules/devel/devel_generate/src/DevelGenerateBase.php deleted file mode 100644 index 1d38a35..0000000 --- a/modules/devel/devel_generate/src/DevelGenerateBase.php +++ /dev/null @@ -1,172 +0,0 @@ -settings)) { - $this->settings = $this->getDefaultSettings(); - } - return isset($this->settings[$key]) ? $this->settings[$key] : NULL; - } - - /** - * {@inheritdoc} - */ - public function getDefaultSettings() { - $definition = $this->getPluginDefinition(); - return $definition['settings']; - } - - /** - * {@inheritdoc} - */ - public function getSettings() { - return $this->settings; - } - - /** - * {@inheritdoc} - */ - public function settingsForm(array $form, FormStateInterface $form_state) { - return array(); - } - - /** - * {@inheritdoc} - */ - function settingsFormValidate(array $form, FormStateInterface $form_state) { - // Validation is optional. - } - - /** - * {@inheritdoc} - */ - public function generate(array $values) { - $this->generateElements($values); - $this->setMessage('Generate process complete.'); - } - - /** - * Business logic relating with each DevelGenerate plugin - * - * @param array $values - * The input values from the settings form. - */ - protected function generateElements(array $values) { - - } - - /** - * Populate the fields on a given entity with sample values. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity to be enriched with sample field values. - */ - public static function populateFields(EntityInterface $entity) { - /** @var \Drupal\field\FieldConfigInterface[] $instances */ - $instances = entity_load_multiple_by_properties('field_config', array('entity_type' => $entity->getEntityType()->id(), 'bundle' => $entity->bundle())); - - if ($skips = function_exists('drush_get_option') ? drush_get_option('skip-fields', '') : @$_REQUEST['skip-fields']) { - foreach (explode(',', $skips) as $skip) { - unset($instances[$skip]); - } - } - - foreach ($instances as $instance) { - $field_storage = $instance->getFieldStorageDefinition(); - $max = $cardinality = $field_storage->getCardinality(); - if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { - // Just an arbitrary number for 'unlimited' - $max = rand(1, 3); - } - $field_name = $field_storage->getName(); - $entity->$field_name->generateSampleItems($max); - } - } - - /** - * {@inheritdoc} - */ - public function handleDrushParams($args) { - - } - - /** - * Set a message for either drush or the web interface. - * - * @param string $msg - * The message to display. - * @param string $type - * (optional) The message type, as defined by drupal_set_message(). Defaults - * to 'status' - */ - protected function setMessage($msg, $type = 'status') { - $function = 'drupal_set_message'; - if (function_exists('drush_log')) { - $function = 'drush_log'; - $msg = strip_tags($msg); - } - $function($msg, $type); - } - - /** - * Check if a given param is a number. - * - * @param mixed $number - * The parameter to check. - * - * @return bool - * TRUE if the parameter is a number, FALSE otherwise. - */ - public static function isNumber($number) { - if ($number == NULL) return FALSE; - if (!is_numeric($number)) return FALSE; - return TRUE; - } - - /** - * Returns the random data generator. - * - * @return \Drupal\Component\Utility\Random - * The random data generator. - */ - protected function getRandom() { - if (!$this->random) { - $this->random = new Random(); - } - return $this->random; - } - - protected function isDrush8() { - return function_exists('drush_drupal_load_autoloader'); - } -} diff --git a/modules/devel/devel_generate/src/DevelGenerateBaseInterface.php b/modules/devel/devel_generate/src/DevelGenerateBaseInterface.php deleted file mode 100644 index c2b814a..0000000 --- a/modules/devel/devel_generate/src/DevelGenerateBaseInterface.php +++ /dev/null @@ -1,77 +0,0 @@ -develGeneratePluginManager = $develGeneratePluginManager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('plugin.manager.develgenerate')); - } - - /* - * A permissions callback. - * - * @see devel_generate.permissions.yml. - * - * @return array - */ - function permissions() { - $devel_generate_plugins = $this->develGeneratePluginManager->getDefinitions(); - foreach ($devel_generate_plugins as $plugin) { - - $permission = $plugin['permission']; - $permissions[$permission] = array( - 'title' => t($permission), - ); - } - -// $permissions = array( -// 'administer devel_generate' => array( -// 'title' => t('Administer devel generate'), -// ), -// ); - return $permissions; - } - -} diff --git a/modules/devel/devel_generate/src/DevelGeneratePluginManager.php b/modules/devel/devel_generate/src/DevelGeneratePluginManager.php deleted file mode 100644 index 626e6dc..0000000 --- a/modules/devel/devel_generate/src/DevelGeneratePluginManager.php +++ /dev/null @@ -1,31 +0,0 @@ -alterInfo('devel_generate_info'); - $this->setCacheBackend($cache_backend, 'devel_generate_plugins'); - } - -} diff --git a/modules/devel/devel_generate/src/Form/DevelGenerateForm.php b/modules/devel/devel_generate/src/Form/DevelGenerateForm.php deleted file mode 100644 index 63c708b..0000000 --- a/modules/devel/devel_generate/src/Form/DevelGenerateForm.php +++ /dev/null @@ -1,114 +0,0 @@ -develGenerateManager = $devel_generate_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.develgenerate') - ); - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'devel_generate_form_' . $this->getPluginIdFromRequest(); - } - - /** - * Returns the value of the param _plugin_id for the current request. - * - * @see \Drupal\devel_generate\Routing\DevelGenerateRouteSubscriber - */ - protected function getPluginIdFromRequest() { - $request = $this->getRequest(); - return $request->get('_plugin_id'); - } - - /** - * Returns a DevelGenerate plugin instance for a given plugin id. - * - * @param string $plugin_id - * The plugin_id for the plugin instance. - * - * @return \Drupal\devel_generate\DevelGenerateBaseInterface - * A DevelGenerate plugin instance. - */ - public function getPluginInstance($plugin_id) { - $instance = $this->develGenerateManager->createInstance($plugin_id, array()); - return $instance; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state) { - $plugin_id = $this->getPluginIdFromRequest(); - $instance = $this->getPluginInstance($plugin_id); - $form = $instance->settingsForm($form, $form_state); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => $this->t('Generate'), - '#button_type' => 'primary', - ); - - return $form; - } - - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - $plugin_id = $this->getPluginIdFromRequest(); - $instance = $this->getPluginInstance($plugin_id); - $instance->settingsFormValidate($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - try { - $plugin_id = $this->getPluginIdFromRequest(); - $instance = $this->getPluginInstance($plugin_id); - $instance->generate($form_state->getValues()); - } - catch (DevelGenerateException $e) { - $this->logger('DevelGenerate', $this->t('Failed to generate elements due to "%error".', array('%error' => $e->getMessage()))); - drupal_set_message($this->t('Failed to generate elements due to "%error".', array('%error' => $e->getMessage()))); - } - } - -} diff --git a/modules/devel/devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php b/modules/devel/devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php deleted file mode 100644 index 34e3e71..0000000 --- a/modules/devel/devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php +++ /dev/null @@ -1,506 +0,0 @@ -moduleHandler = $module_handler; - $this->nodeStorage = $node_storage; - $this->nodeTypeStorage = $node_type_storage; - $this->commentManager = $comment_manager; - $this->languageManager = $language_manager; - $this->urlGenerator = $url_generator; - $this->dateFormatter = $date_formatter; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - $entity_manager = $container->get('entity.manager'); - return new static( - $configuration, $plugin_id, $plugin_definition, - $entity_manager->getStorage('node'), - $entity_manager->getStorage('node_type'), - $container->get('module_handler'), - $container->has('comment.manager') ? $container->get('comment.manager') : NULL, - $container->get('language_manager'), - $container->get('url_generator'), - $container->get('date.formatter') - ); - } - - /** - * {@inheritdoc} - */ - public function settingsForm(array $form, FormStateInterface $form_state) { - $types = $this->nodeTypeStorage->loadMultiple(); - - if (empty($types)) { - $create_url = $this->urlGenerator->generateFromRoute('node.type_add'); - $this->setMessage($this->t('You do not have any content types that can be generated. Go create a new content type', array(':create-type' => $create_url)), 'error', FALSE); - return; - } - - $options = array(); - - foreach ($types as $type) { - $options[$type->id()] = array( - 'type' => array('#markup' => $type->label()), - ); - if ($this->commentManager) { - $comment_fields = $this->commentManager->getFields('node'); - $map = array($this->t('Hidden'), $this->t('Closed'), $this->t('Open')); - - $fields = array(); - foreach ($comment_fields as $field_name => $info) { - // Find all comment fields for the bundle. - if (in_array($type->id(), $info['bundles'])) { - $instance = FieldConfig::loadByName('node', $type->id(), $field_name); - $default_value = $instance->getDefaultValueLiteral(); - $default_mode = reset($default_value); - $fields[] = new FormattableMarkup('@field: @state', array( - '@field' => $instance->label(), - '@state' => $map[$default_mode['status']], - )); - } - } - // @todo Refactor display of comment fields. - if (!empty($fields)) { - $options[$type->id()]['comments'] = array( - 'data' => array( - '#theme' => 'item_list', - '#items' => $fields, - ), - ); - } - else { - $options[$type->id()]['comments'] = $this->t('No comment fields'); - } - } - } - - $header = array( - 'type' => $this->t('Content type'), - ); - if ($this->commentManager) { - $header['comments'] = array( - 'data' => $this->t('Comments'), - 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), - ); - } - - $form['node_types'] = array( - '#type' => 'tableselect', - '#header' => $header, - '#options' => $options, - ); - - $form['kill'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Delete all content in these content types before generating new content.'), - '#default_value' => $this->getSetting('kill'), - ); - $form['num'] = array( - '#type' => 'number', - '#title' => $this->t('How many nodes would you like to generate?'), - '#default_value' => $this->getSetting('num'), - '#required' => TRUE, - '#min' => 0, - ); - - $options = array(1 => $this->t('Now')); - foreach (array(3600, 86400, 604800, 2592000, 31536000) as $interval) { - $options[$interval] = $this->dateFormatter->formatInterval($interval, 1) . ' ' . $this->t('ago'); - } - $form['time_range'] = array( - '#type' => 'select', - '#title' => $this->t('How far back in time should the nodes be dated?'), - '#description' => $this->t('Node creation dates will be distributed randomly from the current time, back to the selected time.'), - '#options' => $options, - '#default_value' => 604800, - ); - - $form['max_comments'] = array( - '#type' => $this->moduleHandler->moduleExists('comment') ? 'number' : 'value', - '#title' => $this->t('Maximum number of comments per node.'), - '#description' => $this->t('You must also enable comments for the content types you are generating. Note that some nodes will randomly receive zero comments. Some will receive the max.'), - '#default_value' => $this->getSetting('max_comments'), - '#min' => 0, - '#access' => $this->moduleHandler->moduleExists('comment'), - ); - $form['title_length'] = array( - '#type' => 'number', - '#title' => $this->t('Maximum number of words in titles'), - '#default_value' => $this->getSetting('title_length'), - '#required' => TRUE, - '#min' => 1, - '#max' => 255, - ); - $form['add_alias'] = array( - '#type' => 'checkbox', - '#disabled' => !$this->moduleHandler->moduleExists('path'), - '#description' => $this->t('Requires path.module'), - '#title' => $this->t('Add an url alias for each node.'), - '#default_value' => FALSE, - ); - $form['add_statistics'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Add statistics for each node (node_counter table).'), - '#default_value' => TRUE, - '#access' => $this->moduleHandler->moduleExists('statistics'), - ); - - $options = array(); - // We always need a language. - $languages = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL); - foreach ($languages as $langcode => $language) { - $options[$langcode] = $language->getName(); - } - - $form['add_language'] = array( - '#type' => 'select', - '#title' => $this->t('Set language on nodes'), - '#multiple' => TRUE, - '#description' => $this->t('Requires locale.module'), - '#options' => $options, - '#default_value' => array( - $this->languageManager->getDefaultLanguage()->getId(), - ), - ); - - $form['#redirect'] = FALSE; - - return $form; - } - - /** - * {@inheritdoc} - */ - function settingsFormValidate(array $form, FormStateInterface $form_state) { - if (!array_filter($form_state->getValue('node_types'))) { - $form_state->setErrorByName('node_types', $this->t('Please select at least one content type')); - } - } - - /** - * {@inheritdoc} - */ - protected function generateElements(array $values) { - if ($values['num'] <= 50 && $values['max_comments'] <= 10) { - $this->generateContent($values); - } - else { - $this->generateBatchContent($values); - } - } - - /** - * Method responsible for creating content when - * the number of elements is less than 50. - */ - private function generateContent($values) { - $values['node_types'] = array_filter($values['node_types']); - if (!empty($values['kill']) && $values['node_types']) { - $this->contentKill($values); - } - - if (!empty($values['node_types'])) { - // Generate nodes. - $this->develGenerateContentPreNode($values); - $start = time(); - for ($i = 1; $i <= $values['num']; $i++) { - $this->develGenerateContentAddNode($values); - if ($this->isDrush8() && function_exists('drush_log') && $i % drush_get_option('feedback', 1000) == 0) { - $now = time(); - drush_log(dt('Completed @feedback nodes (@rate nodes/min)', array('@feedback' => drush_get_option('feedback', 1000), '@rate' => (drush_get_option('feedback', 1000) * 60) / ($now - $start))), 'ok'); - $start = $now; - } - } - } - $this->setMessage($this->formatPlural($values['num'], '1 node created.', 'Finished creating @count nodes')); - } - - /** - * Method responsible for creating content when - * the number of elements is greater than 50. - */ - private function generateBatchContent($values) { - // Setup the batch operations and save the variables. - $operations[] = array('devel_generate_operation', array($this, 'batchContentPreNode', $values)); - - // Add the kill operation. - if ($values['kill']) { - $operations[] = array('devel_generate_operation', array($this, 'batchContentKill', $values)); - } - - // Add the operations to create the nodes. - for ($num = 0; $num < $values['num']; $num ++) { - $operations[] = array('devel_generate_operation', array($this, 'batchContentAddNode', $values)); - } - - // Set the batch. - $batch = array( - 'title' => $this->t('Generating Content'), - 'operations' => $operations, - 'finished' => 'devel_generate_batch_finished', - 'file' => drupal_get_path('module', 'devel_generate') . '/devel_generate.batch.inc', - ); - batch_set($batch); - } - - public function batchContentPreNode($vars, &$context) { - $context['results'] = $vars; - $context['results']['num'] = 0; - $this->develGenerateContentPreNode($context['results']); - } - - public function batchContentAddNode($vars, &$context) { - $this->develGenerateContentAddNode($context['results']); - $context['results']['num']++; - } - - public function batchContentKill($vars, &$context) { - $this->contentKill($context['results']); - } - - /** - * {@inheritdoc} - */ - public function validateDrushParams($args, $options = []) { - $add_language = $this->isDrush8() ? drush_get_option('languages') : $options['languages']; - if (!empty($add_language)) { - $add_language = explode(',', str_replace(' ', '', $add_language)); - // Intersect with the enabled languages to make sure the language args - // passed are actually enabled. - $values['values']['add_language'] = array_intersect($add_language, array_keys($this->languageManager->getLanguages(LanguageInterface::STATE_ALL))); - } - - $values['kill'] = $this->isDrush8() ? drush_get_option('kill') : $options['kill']; - $values['title_length'] = 6; - $values['num'] = array_shift($args); - $values['max_comments'] = array_shift($args); - $all_types = array_keys(node_type_get_names()); - $default_types = array_intersect(array('page', 'article'), $all_types); - if ($this->isDrush8()) { - $selected_types = _convert_csv_to_array(drush_get_option('types', $default_types)); - } - else { - $selected_types = StringUtils::csvToArray($options['types'] ?: $default_types); - } - - if (empty($selected_types)) { - throw new \Exception(dt('No content types available')); - } - - $values['node_types'] = array_combine($selected_types, $selected_types); - $node_types = array_filter($values['node_types']); - - if (!empty($values['kill']) && empty($node_types)) { - throw new \Exception(dt('Please provide content type (--types) in which you want to delete the content.')); - } - - // Checks for any missing content types before generating nodes. - if (array_diff($node_types, $all_types)) { - throw new \Exception(dt('One or more content types have been entered that don\'t exist on this site')); - } - - return $values; - } - - /** - * Deletes all nodes of given node types. - * - * @param array $values - * The input values from the settings form. - */ - protected function contentKill($values) { - $nids = $this->nodeStorage->getQuery() - ->condition('type', $values['node_types'], 'IN') - ->execute(); - - if (!empty($nids)) { - $nodes = $this->nodeStorage->loadMultiple($nids); - $this->nodeStorage->delete($nodes); - $this->setMessage($this->t('Deleted %count nodes.', array('%count' => count($nids)))); - } - } - - /** - * Return the same array passed as parameter - * but with an array of uids for the key 'users'. - */ - protected function develGenerateContentPreNode(&$results) { - // Get user id. - $users = $this->getUsers(); - $results['users'] = $users; - } - - /** - * Create one node. Used by both batch and non-batch code branches. - */ - protected function develGenerateContentAddNode(&$results) { - if (!isset($results['time_range'])) { - $results['time_range'] = 0; - } - $users = $results['users']; - - $node_type = array_rand(array_filter($results['node_types'])); - $uid = $users[array_rand($users)]; - - $node = $this->nodeStorage->create(array( - 'nid' => NULL, - 'type' => $node_type, - 'title' => $this->getRandom()->sentences(mt_rand(1, $results['title_length']), TRUE), - 'uid' => $uid, - 'revision' => mt_rand(0, 1), - 'status' => TRUE, - 'promote' => mt_rand(0, 1), - 'created' => REQUEST_TIME - mt_rand(0, $results['time_range']), - 'langcode' => $this->getLangcode($results), - )); - - // A flag to let hook_node_insert() implementations know that this is a - // generated node. - $node->devel_generate = $results; - - // Populate all fields with sample values. - $this->populateFields($node); - - // See devel_generate_node_insert() for actions that happen before and after - // this save. - $node->save(); - } - - /** - * Determine language based on $results. - */ - protected function getLangcode($results) { - if (isset($results['add_language'])) { - $langcodes = $results['add_language']; - $langcode = $langcodes[array_rand($langcodes)]; - } - else { - $langcode = $this->languageManager->getDefaultLanguage()->getId(); - } - return $langcode; - } - - /** - * Retrieve 50 uids from the database. - */ - protected function getUsers() { - $users = array(); - $result = db_query_range("SELECT uid FROM {users}", 0, 50); - foreach ($result as $record) { - $users[] = $record->uid; - } - return $users; - } - -} diff --git a/modules/devel/devel_generate/src/Plugin/DevelGenerate/MenuDevelGenerate.php b/modules/devel/devel_generate/src/Plugin/DevelGenerate/MenuDevelGenerate.php deleted file mode 100644 index 6ccacc2..0000000 --- a/modules/devel/devel_generate/src/Plugin/DevelGenerate/MenuDevelGenerate.php +++ /dev/null @@ -1,405 +0,0 @@ -menuLinkTree = $menu_tree; - $this->menuStorage = $menu_storage; - $this->menuLinkContentStorage = $menu_link_storage; - $this->moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - $entity_manager = $container->get('entity.manager'); - return new static( - $configuration, $plugin_id, $plugin_definition, - $container->get('menu.link_tree'), - $entity_manager->getStorage('menu'), - $entity_manager->getStorage('menu_link_content'), - $container->get('module_handler') - ); - } - - /** - * {@inheritdoc} - */ - public function settingsForm(array $form, FormStateInterface $form_state) { - $menu_enabled = $this->moduleHandler->moduleExists('menu_ui'); - if ($menu_enabled) { - $menus = array('__new-menu__' => $this->t('Create new menu(s)')) + menu_ui_get_menus(); - } - else { - $menus = menu_list_system_menus(); - } - $form['existing_menus'] = array( - '#type' => 'checkboxes', - '#title' => $this->t('Generate links for these menus'), - '#options' => $menus, - '#default_value' => array('__new-menu__'), - '#required' => TRUE, - ); - if ($menu_enabled) { - $form['num_menus'] = array( - '#type' => 'number', - '#title' => $this->t('Number of new menus to create'), - '#default_value' => $this->getSetting('num_menus'), - '#min' => 0, - '#states' => array( - 'visible' => array( - ':input[name="existing_menus[__new-menu__]"]' => array('checked' => TRUE), - ), - ), - ); - } - $form['num_links'] = array( - '#type' => 'number', - '#title' => $this->t('Number of links to generate'), - '#default_value' => $this->getSetting('num_links'), - '#required' => TRUE, - '#min' => 0, - ); - $form['title_length'] = array( - '#type' => 'number', - '#title' => $this->t('Maximum number of characters in menu and menu link names'), - '#description' => $this->t('The minimum length is 2.'), - '#default_value' => $this->getSetting('title_length'), - '#required' => TRUE, - '#min' => 2, - '#max' => 128, - ); - $form['link_types'] = array( - '#type' => 'checkboxes', - '#title' => $this->t('Types of links to generate'), - '#options' => array( - 'node' => $this->t('Nodes'), - 'front' => $this->t('Front page'), - 'external' => $this->t('External'), - ), - '#default_value' => array('node', 'front', 'external'), - '#required' => TRUE, - ); - $form['max_depth'] = array( - '#type' => 'select', - '#title' => $this->t('Maximum link depth'), - '#options' => range(0, $this->menuLinkTree->maxDepth()), - '#default_value' => floor($this->menuLinkTree->maxDepth() / 2), - '#required' => TRUE, - ); - unset($form['max_depth']['#options'][0]); - $form['max_width'] = array( - '#type' => 'number', - '#title' => $this->t('Maximum menu width'), - '#default_value' => $this->getSetting('max_width'), - '#description' => $this->t('Limit the width of the generated menu\'s first level of links to a certain number of items.'), - '#required' => TRUE, - '#min' => 0, - ); - $form['kill'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Delete existing custom generated menus and menu links before generating new ones.'), - '#default_value' => $this->getSetting('kill'), - ); - - return $form; - } - - /** - * {@inheritdoc} - */ - public function generateElements(array $values) { - // If the create new menus checkbox is off, set the number of new menus to 0. - if (!isset($values['existing_menus']['__new-menu__']) || !$values['existing_menus']['__new-menu__']) { - $values['num_menus'] = 0; - } - else { - // Unset the aux menu to avoid attach menu new items. - unset($values['existing_menus']['__new-menu__']); - } - - // Delete custom menus. - if ($values['kill']) { - $this->deleteMenus(); - $this->setMessage($this->t('Deleted existing menus and links.')); - } - - // Generate new menus. - $new_menus = $this->generateMenus($values['num_menus'], $values['title_length']); - if (!empty($new_menus)) { - $this->setMessage($this->t('Created the following new menus: @menus', array('@menus' => implode(', ', $new_menus)))); - } - - // Generate new menu links. - $menus = $new_menus; - if (isset($values['existing_menus'])) { - $menus = $menus + $values['existing_menus']; - } - $new_links = $this->generateLinks($values['num_links'], $menus, $values['title_length'], $values['link_types'], $values['max_depth'], $values['max_width']); - $this->setMessage($this->t('Created @count new menu links.', array('@count' => count($new_links)))); - } - - /** - * {@inheritdoc} - */ - public function validateDrushParams($args, $options = []) { - - $link_types = array('node', 'front', 'external'); - $values = array( - 'num_menus' => array_shift($args), - 'num_links' => array_shift($args), - 'kill' => $this->isDrush8() ? drush_get_option('kill') : $options['kill'], - 'pipe' => $this->isDrush8() ? drush_get_option('pipe') : $options['pipe'], - 'link_types' => array_combine($link_types, $link_types), - ); - - $max_depth = array_shift($args); - $max_width = array_shift($args); - $values['max_depth'] = $max_depth ? $max_depth : 3; - $values['max_width'] = $max_width ? $max_width : 8; - $values['title_length'] = $this->getSetting('title_length'); - $values['existing_menus']['__new-menu__'] = TRUE; - - if ($this->isNumber($values['num_menus']) == FALSE) { - throw new \Exception(dt('Invalid number of menus')); - } - if ($this->isNumber($values['num_links']) == FALSE) { - throw new \Exception(dt('Invalid number of links')); - } - if ($this->isNumber($values['max_depth']) == FALSE || $values['max_depth'] > 9 || $values['max_depth'] < 1) { - throw new \Exception(dt('Invalid maximum link depth. Use a value between 1 and 9')); - } - if ($this->isNumber($values['max_width']) == FALSE || $values['max_width'] < 1) { - throw new \Exception(dt('Invalid maximum menu width. Use a positive numeric value.')); - } - - return $values; - } - - /** - * Deletes custom generated menus. - */ - protected function deleteMenus() { - if ($this->moduleHandler->moduleExists('menu_ui')) { - $menu_ids = array(); - foreach (menu_ui_get_menus(FALSE) as $menu => $menu_title) { - if (strpos($menu, 'devel-') === 0) { - $menu_ids[] = $menu; - } - } - - if ($menu_ids) { - $menus = $this->menuStorage->loadMultiple($menu_ids); - $this->menuStorage->delete($menus); - } - } - - // Delete menu links generated by devel. - $link_ids = $this->menuLinkContentStorage->getQuery() - ->condition('menu_name', 'devel', '<>') - ->condition('link__options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE') - ->execute(); - - if ($link_ids) { - $links = $this->menuLinkContentStorage->loadMultiple($link_ids); - $this->menuLinkContentStorage->delete($links); - } - - } - - /** - * Generates new menus. - * - * @param int $num_menus - * Number of menus to create. - * @param int $title_length - * (optional) Maximum length per menu name. - * - * @return array - * Array containing the generated vocabularies id. - */ - protected function generateMenus($num_menus, $title_length = 12) { - $menus = array(); - - for ($i = 1; $i <= $num_menus; $i++) { - $name = $this->getRandom()->word(mt_rand(2, max(2, $title_length))); - - $menu = $this->menuStorage->create(array( - 'label' => $name, - 'id' => 'devel-' . Unicode::strtolower($name), - 'description' => $this->t('Description of @name', array('@name' => $name)), - )); - - $menu->save(); - $menus[$menu->id()] = $menu->label(); - } - - return $menus; - } - - /** - * Generates menu links in a tree structure. - */ - protected function generateLinks($num_links, $menus, $title_length, $link_types, $max_depth, $max_width) { - $links = array(); - $menus = array_keys(array_filter($menus)); - $link_types = array_keys(array_filter($link_types)); - - $nids = array(); - for ($i = 1; $i <= $num_links; $i++) { - // Pick a random menu. - $menu_name = $menus[array_rand($menus)]; - // Build up our link. - $link_title = $this->getRandom()->word(mt_rand(2, max(2, $title_length))); - $link = $this->menuLinkContentStorage->create(array( - 'menu_name' => $menu_name, - 'weight' => mt_rand(-50, 50), - 'title' => $link_title, - 'bundle' => 'menu_link_content', - 'description' => $this->t('Description of @title.', array('@title' => $link_title)), - )); - $link->link->options = array('devel' => TRUE); - - // For the first $max_width items, make first level links. - if ($i <= $max_width) { - $depth = 0; - } - else { - // Otherwise, get a random parent menu depth. - $depth = mt_rand(1, max(1, $max_depth - 1)); - } - // Get a random parent link from the proper depth. - do { - $parameters = new MenuTreeParameters(); - $parameters->setMinDepth($depth); - $parameters->setMaxDepth($depth); - $tree = $this->menuLinkTree->load($menu_name, $parameters); - - if ($tree) { - $link->parent = array_rand($tree); - } - $depth--; - } while (!$link->parent && $depth > 0); - - $link_type = array_rand($link_types); - switch ($link_types[$link_type]) { - case 'node': - // Grab a random node ID. - $select = db_select('node_field_data', 'n') - ->fields('n', array('nid', 'title')) - ->condition('n.status', 1) - ->range(0, 1) - ->orderRandom(); - // Don't put a node into the menu twice. - if (!empty($nids[$menu_name])) { - $select->condition('n.nid', $nids[$menu_name], 'NOT IN'); - } - $node = $select->execute()->fetchAssoc(); - if (isset($node['nid'])) { - $nids[$menu_name][] = $node['nid']; - $link->link->uri = 'entity:node/' . $node['nid']; - $link->title = $node['title']; - break; - } - - case 'external': - $link->link->uri = 'http://www.example.com/'; - break; - - case 'front': - $link->link->uri = 'internal:/Kint: dd() is being deprecated, please use ddd() instead\n"; - $_ = func_get_args(); - call_user_func_array( array( 'Kint', 'dump' ), $_ ); - die; - } -} - -if ( !function_exists( 'ddd' ) ) { - /** - * Alias of Kint::dump() - * [!!!] IMPORTANT: execution will halt after call to this function - * - * @return string - */ - function ddd() - { - if ( !Kint::enabled() ) return ''; - $_ = func_get_args(); - call_user_func_array( array( 'Kint', 'dump' ), $_ ); - die; - } -} - -if ( !function_exists( 's' ) ) { - /** - * Alias of Kint::dump(), however the output is in plain htmlescaped text and some minor visibility enhancements - * added. If run in CLI mode, output is pure whitespace. - * - * To force rendering mode without autodetecting anything: - * - * Kint::enabled( Kint::MODE_PLAIN ); - * Kint::dump( $variable ); - * - * [!!!] IMPORTANT: execution will halt after call to this function - * - * @return string - */ - function s() - { - $enabled = Kint::enabled(); - if ( !$enabled ) return ''; - - if ( $enabled === Kint::MODE_WHITESPACE ) { # if already in whitespace, don't elevate to plain - $restoreMode = Kint::MODE_WHITESPACE; - } else { - $restoreMode = Kint::enabled( # remove cli colors in cli mode; remove rich interface in HTML mode - PHP_SAPI === 'cli' ? Kint::MODE_WHITESPACE : Kint::MODE_PLAIN - ); - } - - $params = func_get_args(); - $dump = call_user_func_array( array( 'Kint', 'dump' ), $params ); - Kint::enabled( $restoreMode ); - return $dump; - } -} - -if ( !function_exists( 'sd' ) ) { - /** - * @see s() - * - * [!!!] IMPORTANT: execution will halt after call to this function - * - * @return string - */ - function sd() - { - $enabled = Kint::enabled(); - if ( !$enabled ) return ''; - - if ( $enabled !== Kint::MODE_WHITESPACE ) { - Kint::enabled( - PHP_SAPI === 'cli' ? Kint::MODE_WHITESPACE : Kint::MODE_PLAIN - ); - } - - $params = func_get_args(); - call_user_func_array( array( 'Kint', 'dump' ), $params ); - die; - } -} diff --git a/modules/devel/kint/kint/LICENCE b/modules/devel/kint/kint/LICENCE deleted file mode 100644 index 936fe1f..0000000 --- a/modules/devel/kint/kint/LICENCE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013 Rokas Šleinius (raveren@gmail.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/modules/devel/kint/kint/README.md b/modules/devel/kint/kint/README.md deleted file mode 100644 index 74edcba..0000000 --- a/modules/devel/kint/kint/README.md +++ /dev/null @@ -1,141 +0,0 @@ -# Kint - debugging helper for PHP developers - -[![Total Downloads](https://poser.pugx.org/raveren/kint/downloads.png)](https://packagist.org/packages/raveren/kint) - -> **New version** v1.0.0 is released with more than two years of active development - changes are too numerous to list, but there's CLI output and literally hundreds of improvements and additions. - -![Screenshot](http://raveren.github.com/kint/img/preview.png) - -## What am I looking at? - -At first glance Kint is just a pretty replacement for **[var_dump()](http://php.net/manual/en/function.var-dump.php)**, **[print_r()](http://php.net/manual/en/function.print-r.php)** and **[debug_backtrace()](http://php.net/manual/en/function.debug-backtrace.php)**. - -However, it's much, *much* more than that. Even the excellent `xdebug` var_dump improvements don't come close - you will eventually wonder how you developed without it. - -Just to list some of the most useful features: - - * The **variable name and place in code** where Kint was called from is displayed; - * You can **disable all Kint output easily and on the fly** - so you can even debug live systems without anyone knowing (even though you know you shouldn't be doing that!:). - * **CLI is detected** and formatted for automatically (but everything can be overridden on the fly) - if your setup supports it, the output is colored too: - ![Kint CLI output](http://i.imgur.com/6B9MCLw.png) - * **Debug backtraces** are finally fully readable, actually informative and a pleasure to the eye. - * Kint has been **in active development for more than six years** and is shipped with [Drupal 8](https://www.drupal.org/) by default as part of its devel suite. You can trust it not being abandoned or getting left behind in features. - * Variable content is **displayed in the most informative way** - and you *never, ever* miss anything! Kint guarantees you see every piece of physically available information about everything you are dumping*; - * in some cases, the content is truncated where it would otherwise be too large to view anyway - but the user is always made aware of that; - * Some variable content types have an alternative display - for example you will be able see `JSON` in its raw form - but also as an associative array: - ![Kint displays data intelligently](http://i.imgur.com/9P57Ror.png) - There are more than ten custom variable type displays inbuilt and more are added periodically. - - -## Installation and Usage - -One of the main goals of Kint is to be **zero setup**. - -[Download the archive](https://github.com/raveren/kint/releases/download/1.0.2/kint.zip) and simply -```php -');`) - so even if you accidentally leave a dump in production, no one will know. - * `sd()` and `ddd()` are shorthands for `s();die;` and `d();die;` respectively. - * **Important:** The older shorthand `dd()` is deprecated due to compatibility issues and will eventually be removed. Use the analogous `ddd()` instead. - * When looking at Kint output, press D on the keyboard and you will be able to traverse the tree with arrows and tab keys - and expand/collapse nodes with space or enter. - * Double clicking the `[+]` sign in the output will expand/collapse ALL nodes; triple clicking big blocks of text will select it all. - * Clicking the tiny arrows on the right of the output open it in a separate window where you can keep it for comparison. - * To catch output from Kint just assign it to a variablebeta -```php -$o = Kint::dump($GLOBALS); -// yes, the assignment is automatically detected, and $o -// now holds whatever was going to be printed otherwise. - -// it also supports modifiers (read on) for the variable: -~$o = Kint::dump($GLOBALS); // this output will be in whitespace -``` - * There are a couple of real-time modifiers you can use: - * `~d($var)` this call will output in plain text format. - * `+d($var)` will disregard depth level limits and output everything (careful, this can hang your browser on huge objects) - * `!d($var)` will show expanded rich output. - * `-d($var)` will attempt to `ob_clean` the previous output so if you're dumping something inside a HTML page, you will still see Kint output. - You can combine modifiers too: `~+d($var)` - * To force a specific dump output type just pass it to the `Kint::enabled()` method. Available options are: `Kint::MODE_RICH` (default), `Kint::MODE_PLAIN`, `Kint::MODE_WHITESPACE` and `Kint::MODE_CLI`: -```php -Kint::enabled(Kint::MODE_WHITESPACE); -$kintOutput = Kint::dump($GLOBALS); -// now $kintOutput can be written to a text log file and -// be perfectly readable from there -``` - * To change display theme, use `Kint::$theme = '
'; - } - return ''; - } - - public static function wrapEnd( $callee, $miniTrace, $prevCaller ) - { - $lastLine = self::_colorize( self::_char( "═", 80 ), 'title' ); - $lastChar = Kint::enabled() === Kint::MODE_PLAIN ? '' : ''; - - - if ( !Kint::$displayCalledFrom ) return $lastLine . $lastChar; - - - return $lastLine . self::_colorize( 'Called from ' . self::_buildCalleeString( $callee ), 'title' ) . $lastChar; - } - - - private static function _drawHeader( kintVariableData $kintVar ) - { - $output = ''; - - if ( $kintVar->access ) { - $output .= ' ' . $kintVar->access; - } - - if ( $kintVar->name !== null && $kintVar->name !== '' ) { - $output .= ' ' . kintParser::escape( $kintVar->name ); - } - - if ( $kintVar->operator ) { - $output .= ' ' . $kintVar->operator; - } - - $output .= ' ' . self::_colorize( $kintVar->type, 'type', false ); - - if ( $kintVar->size !== null ) { - $output .= ' (' . $kintVar->size . ')'; - } - - - if ( $kintVar->value !== null && $kintVar->value !== '' ) { - $output .= ' ' . self::_colorize( - $kintVar->value, # escape shell - 'value', - false - ); - } - - return ltrim( $output ); - } - - private static function _buildCalleeString( $callee ) - { - if ( Kint::enabled() === Kint::MODE_CLI ) { // todo win/nix - return "+{$callee['line']} {$callee['file']}"; - } - - $url = Kint::getIdeLink( $callee['file'], $callee['line'] ); - $shortenedName = Kint::shortenPath( $callee['file'] ) . ':' . $callee['line']; - - if ( Kint::enabled() === Kint::MODE_PLAIN ) { - if ( strpos( $url, 'http://' ) === 0 ) { - $calleeInfo = "{$shortenedName}"; - } else { - $calleeInfo = "{$shortenedName}"; - } - } else { - $calleeInfo = $shortenedName; - } - - return $calleeInfo; - } - - public static function init() - { - self::$_enableColors = - Kint::$cliColors - && ( DIRECTORY_SEPARATOR === '/' || getenv( 'ANSICON' ) !== false || getenv( 'ConEmuANSI' ) === 'ON' ); - - return Kint::enabled() === Kint::MODE_PLAIN - ? '' - : ''; - } -} \ No newline at end of file diff --git a/modules/devel/kint/kint/decorators/rich.php b/modules/devel/kint/kint/decorators/rich.php deleted file mode 100644 index bb6c978..0000000 --- a/modules/devel/kint/kint/decorators/rich.php +++ /dev/null @@ -1,319 +0,0 @@ -'; - - $extendedPresent = $kintVar->extendedValue !== null || $kintVar->_alternatives !== null; - - if ( $extendedPresent ) { - $class = 'kint-parent'; - if ( Kint::$expandedByDefault ) { - $class .= ' kint-show'; - } - $output .= '
' . $kintVar->extendedValue . ''; - } else { - $output .= self::decorate( $kintVar->extendedValue ); //it's kint's container - } - - } elseif ( isset( $kintVar->_alternatives ) ) { - $output .= "
' . $v . '' - : self::decorate( $v ); - } - } elseif ( is_string( $var ) ) { - $output .= '
' . $var . ''; - } elseif ( isset( $var ) ) { - throw new Exception( - 'Kint has encountered an error, ' - . 'please paste this report to https://github.com/raveren/kint/issues
{$step['source']}
' . '#' . ( $rowIndex + 1 ) . ' | '; - } else { - $output = self::_decorateCell( kintParser::factory( $rowIndex ) ); - } - if ( $firstRow ) { - $extendedValue .= ''; - } - - # we iterate the known full set of keys from all rows in case some appeared at later rows, - # as we only check the first two to assume - foreach ( $arrayKeys as $key ) { - if ( $firstRow ) { - $extendedValue .= ' | ' . self::escape( $key ) . ' | '; - } - - if ( !array_key_exists( $key, $row ) ) { - $output .= ''; - continue; - } - - $var = kintParser::factory( $row[ $key ] ); - - if ( $var->value === self::$_marker ) { - $variableData->value = '*RECURSION*'; - return false; - } elseif ( $var->value === '*RECURSION*' ) { - $output .= ' | *RECURSION* | '; - } else { - $output .= self::_decorateCell( $var ); - } - unset( $var ); - } - - if ( $firstRow ) { - $extendedValue .= '
---|---|---|---|---|
when array("\n") is dumped - if ( parent && kint.hasClass(parent, 'kint-parent') ) { - kint.toggle(parent, hide) - } - } - }, - - toggleChildren : function( element, hide ) { - var parent = kint.next(element) - , nodes = parent.getElementsByClassName('kint-parent') - , i = nodes.length; - - if ( typeof hide === 'undefined' ) { - hide = kint.hasClass(element); - } - - while ( i-- ) { - kint.toggle(nodes[i], hide); - } - kint.toggle(element, hide); - }, - - toggleAll : function( caret ) { - var elements = document.getElementsByClassName('kint-parent') - , i = elements.length - , visible = kint.hasClass(caret.parentNode); - - while ( i-- ) { - kint.toggle(elements[i], visible); - } - }, - - switchTab : function( target ) { - var lis, el = target, index = 0; - - target.parentNode.getElementsByClassName('kint-active-tab')[0].className = ''; - target.className = 'kint-active-tab'; - - // take the index of clicked title tab and make the same n-th content tab visible - while ( el = el.previousSibling ) el.nodeType === 1 && index++; - lis = target.parentNode.nextSibling.childNodes; - for ( var i = 0; i < lis.length; i++ ) { - if ( i === index ) { - lis[i].style.display = 'block'; - - if ( lis[i].childNodes.length === 1 ) { - el = lis[i].childNodes[0].childNodes[0]; - - if ( kint.hasClass(el, 'kint-parent') ) { - kint.toggle(el, false) - } - } - } else { - lis[i].style.display = 'none'; - } - } - }, - - isSibling : function( el ) { - for ( ; ; ) { - el = el.parentNode; - if ( !el || kint.hasClass(el, 'kint') ) break; - } - - return !!el; - }, - - fetchVisiblePluses : function() { - kint.visiblePluses = []; - kint.each('.kint nav, .kint-tabs>li:not(.kint-active-tab)', function( el ) { - if ( el.offsetWidth !== 0 || el.offsetHeight !== 0 ) { - kint.visiblePluses.push(el) - } - }); - }, - - openInNewWindow : function( kintContainer ) { - var newWindow; - - if ( newWindow = window.open() ) { - newWindow.document.open(); - newWindow.document.write( - '' - + '' - + 'Kint (' + new Date().toISOString() + ') ' - + '' - + document.getElementsByClassName('-kint-js')[0].outerHTML - + document.getElementsByClassName('-kint-css')[0].outerHTML - + '' - + '' - + '' - + '' - + kintContainer.parentNode.outerHTML - + '' - ); - newWindow.document.close(); - } - }, - - sortTable : function( table, column ) { - var tbody = table.tBodies[0]; - - var format = function( s ) { - var n = column === 1 ? s.replace(/^#/, '') : s; - if ( isNaN(n) ) { - return s.trim().toLocaleLowerCase(); - } else { - n = parseFloat(n); - return isNaN(n) ? s.trim() : n; - } - }; - - - [].slice.call(table.tBodies[0].rows) - .sort(function( a, b ) { - a = format(a.cells[column].textContent); - b = format(b.cells[column].textContent); - if ( a < b ) return -1; - if ( a > b ) return 1; - - return 0; - }) - .forEach(function( el ) { - tbody.appendChild(el); - }); - }, - - keyCallBacks : { - cleanup : function( i ) { - var focusedClass = 'kint-focused'; - var prevElement = document.querySelector('.' + focusedClass); - prevElement && kint.removeClass(prevElement, focusedClass); - - if ( i !== -1 ) { - var el = kint.visiblePluses[i]; - kint.addClass(el, focusedClass); - - - var offsetTop = function( el ) { - return el.offsetTop + ( el.offsetParent ? offsetTop(el.offsetParent) : 0 ); - }; - - var top = offsetTop(el) - (window.innerHeight / 2 ); - window.scrollTo(0, top); - } - - kint.currentPlus = i; - }, - - moveCursor : function( up, i ) { - // todo make the first VISIBLE plus active - if ( up ) { - if ( --i < 0 ) { - i = kint.visiblePluses.length - 1; - } - } else { - if ( ++i >= kint.visiblePluses.length ) { - i = 0; - } - } - - kint.keyCallBacks.cleanup(i); - return false; - } - } - }; - - window.addEventListener("click", function( e ) { - var target = e.target - , nodeName = target.nodeName.toLowerCase(); - - if ( !kint.isSibling(target) ) return; - - // auto-select name of variable - if ( nodeName === 'dfn' ) { - kint.selectText(target); - target = target.parentNode; - } else if ( nodeName === 'var' ) { // stupid workaround for misc elements - target = target.parentNode; // to not stop event from further propagating - nodeName = target.nodeName.toLowerCase() - } else if ( nodeName === 'th' ) { - if ( !e.ctrlKey ) { - kint.sortTable(target.parentNode.parentNode.parentNode, target.cellIndex) - } - return false; - } - - // switch tabs - if ( nodeName === 'li' && target.parentNode.className === 'kint-tabs' ) { - if ( target.className !== 'kint-active-tab' ) { - kint.switchTab(target); - if ( kint.currentPlus !== -1 ) kint.fetchVisiblePluses(); - } - return false; - } - - // handle clicks on the navigation caret - if ( nodeName === 'nav' ) { - // special case for nav in footer - if ( target.parentNode.nodeName.toLowerCase() === 'footer' ) { - target = target.parentNode; - if ( kint.hasClass(target) ) { - kint.removeClass(target) - } else { - kint.addClass(target) - } - } else { - // ensure doubleclick has different behaviour, see below - setTimeout(function() { - var timer = parseInt(target.kintTimer, 10); - if ( timer > 0 ) { - target.kintTimer--; - } else { - kint.toggleChildren(target.parentNode); //
' . $this->t('Here are the contents of your $_SESSION variable.') . '
', - ); - $output['session'] = array( - '#type' => 'table', - '#header' => array($this->t('Session name'), $this->t('Session ID')), - '#rows' => array(array(session_name(), session_id())), - '#empty' => $this->t('No session available.'), - ); - $output['data'] = $this->dumper->exportAsRenderable($_SESSION); - - return $output; - } - -} diff --git a/modules/devel/src/Controller/ElementInfoController.php b/modules/devel/src/Controller/ElementInfoController.php deleted file mode 100644 index a0440c3..0000000 --- a/modules/devel/src/Controller/ElementInfoController.php +++ /dev/null @@ -1,162 +0,0 @@ -elementInfo = $element_info; - $this->dumper = $dumper; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('element_info'), - $container->get('devel.dumper') - ); - } - - /** - * Builds the element overview page. - * - * @return array - * A render array as expected by the renderer. - */ - public function elementList() { - $headers = [ - $this->t('Name'), - $this->t('Provider'), - $this->t('Class'), - $this->t('Operations'), - ]; - - $rows = []; - - foreach ($this->elementInfo->getDefinitions() as $element_type => $definition) { - $row['name'] = [ - 'data' => $element_type, - 'class' => 'table-filter-text-source', - ]; - $row['provider'] = [ - 'data' => $definition['provider'], - 'class' => 'table-filter-text-source', - ]; - $row['class'] = [ - 'data' => $definition['class'], - 'class' => 'table-filter-text-source', - ]; - $row['operations']['data'] = [ - '#type' => 'operations', - '#links' => [ - 'devel' => [ - 'title' => $this->t('Devel'), - 'url' => Url::fromRoute('devel.elements_page.detail', ['element_name' => $element_type]), - 'attributes' => [ - 'class' => ['use-ajax'], - 'data-dialog-type' => 'modal', - 'data-dialog-options' => Json::encode([ - 'width' => 700, - 'minHeight' => 500, - ]), - ], - ], - ], - ]; - - $rows[$element_type] = $row; - } - - ksort($rows); - - $output['#attached']['library'][] = 'system/drupal.system.modules'; - - $output['filters'] = [ - '#type' => 'container', - '#attributes' => [ - 'class' => ['table-filter', 'js-show'], - ], - ]; - $output['filters']['text'] = [ - '#type' => 'search', - '#title' => $this->t('Search'), - '#size' => 30, - '#placeholder' => $this->t('Enter element id, provider or class'), - '#attributes' => [ - 'class' => ['table-filter-text'], - 'data-table' => '.devel-filter-text', - 'autocomplete' => 'off', - 'title' => $this->t('Enter a part of the element id, provider or class to filter by.'), - ], - ]; - $output['elements'] = [ - '#type' => 'table', - '#header' => $headers, - '#rows' => $rows, - '#empty' => $this->t('No elements found.'), - '#sticky' => TRUE, - '#attributes' => [ - 'class' => ['devel-element-list', 'devel-filter-text'], - ], - ]; - - return $output; - } - - /** - * Returns a render array representation of the element. - * - * @param string $element_name - * The name of the element to retrieve. - * - * @return array - * A render array containing the element. - * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - * If the requested element is not defined. - */ - public function elementDetail($element_name) { - if (!$element = $this->elementInfo->getDefinition($element_name, FALSE)) { - throw new NotFoundHttpException(); - } - - $element += $this->elementInfo->getInfo($element_name); - return $this->dumper->exportAsRenderable($element, $element_name); - } - -} diff --git a/modules/devel/src/Controller/EntityDebugController.php b/modules/devel/src/Controller/EntityDebugController.php deleted file mode 100644 index 515a9fc..0000000 --- a/modules/devel/src/Controller/EntityDebugController.php +++ /dev/null @@ -1,143 +0,0 @@ -dumper = $dumper; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('devel.dumper')); - } - - /** - * Returns the entity type definition of the current entity. - * - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * A RouteMatch object. - * - * @return array - * Array of page elements to render. - */ - public function entityTypeDefinition(RouteMatchInterface $route_match) { - $output = []; - - $entity = $this->getEntityFromRouteMatch($route_match); - - if ($entity instanceof EntityInterface) { - $output = $this->dumper->exportAsRenderable($entity->getEntityType()); - } - - return $output; - } - - /** - * Returns the loaded structure of the current entity. - * - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * A RouteMatch object. - * - * @return array - * Array of page elements to render. - */ - public function entityLoad(RouteMatchInterface $route_match) { - $output = []; - - $entity = $this->getEntityFromRouteMatch($route_match); - - if ($entity instanceof EntityInterface) { - // Field definitions are lazy loaded and are populated only when needed. - // By calling ::getFieldDefinitions() we are sure that field definitions - // are populated and available in the dump output. - // @see https://www.drupal.org/node/2311557 - if($entity instanceof FieldableEntityInterface) { - $entity->getFieldDefinitions(); - } - - $output = $this->dumper->exportAsRenderable($entity); - } - - return $output; - } - - /** - * Returns the render structure of the current entity. - * - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * A RouteMatch object. - * - * @return array - * Array of page elements to render. - */ - public function entityRender(RouteMatchInterface $route_match) { - $output = []; - - $entity = $this->getEntityFromRouteMatch($route_match); - - if ($entity instanceof EntityInterface) { - $entity_type_id = $entity->getEntityTypeId(); - $view_hook = $entity_type_id . '_view'; - - $build = []; - // If module implements own {entity_type}_view() hook use it, otherwise - // fallback to the entity view builder if available. - if (function_exists($view_hook)) { - $build = $view_hook($entity); - } - elseif ($this->entityTypeManager()->hasHandler($entity_type_id, 'view_builder')) { - $build = $this->entityTypeManager()->getViewBuilder($entity_type_id)->view($entity); - } - - $output = $this->dumper->exportAsRenderable($build); - } - - return $output; - } - - /** - * Retrieves entity from route match. - * - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The route match. - * - * @return \Drupal\Core\Entity\EntityInterface|null - * The entity object as determined from the passed-in route match. - */ - protected function getEntityFromRouteMatch(RouteMatchInterface $route_match) { - $parameter_name = $route_match->getRouteObject()->getOption('_devel_entity_type_id'); - $entity = $route_match->getParameter($parameter_name); - return $entity; - } - -} diff --git a/modules/devel/src/Controller/EntityTypeInfoController.php b/modules/devel/src/Controller/EntityTypeInfoController.php deleted file mode 100644 index f8bac6d..0000000 --- a/modules/devel/src/Controller/EntityTypeInfoController.php +++ /dev/null @@ -1,154 +0,0 @@ -dumper = $dumper; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('devel.dumper') - ); - } - - /** - * Builds the entity types overview page. - * - * @return array - * A render array as expected by the renderer. - */ - public function entityTypeList() { - $headers = [ - $this->t('ID'), - $this->t('Name'), - $this->t('Provider'), - $this->t('Class'), - $this->t('Operations'), - ]; - - $rows = []; - - foreach ($this->entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) { - $row['id'] = [ - 'data' => $entity_type->id(), - 'class' => 'table-filter-text-source', - ]; - $row['name'] = [ - 'data' => $entity_type->getLabel(), - 'class' => 'table-filter-text-source', - ]; - $row['provider'] = [ - 'data' => $entity_type->getProvider(), - 'class' => 'table-filter-text-source', - ]; - $row['class'] = [ - 'data' => $entity_type->getClass(), - 'class' => 'table-filter-text-source', - ]; - $row['operations']['data'] = [ - '#type' => 'operations', - '#links' => [ - 'devel' => [ - 'title' => $this->t('Devel'), - 'url' => Url::fromRoute('devel.entity_info_page.detail', ['entity_type_id' => $entity_type_id]), - 'attributes' => [ - 'class' => ['use-ajax'], - 'data-dialog-type' => 'modal', - 'data-dialog-options' => Json::encode([ - 'width' => 700, - 'minHeight' => 500, - ]), - ], - ], - ], - ]; - - $rows[$entity_type_id] = $row; - } - - ksort($rows); - - $output['#attached']['library'][] = 'system/drupal.system.modules'; - - $output['filters'] = [ - '#type' => 'container', - '#attributes' => [ - 'class' => ['table-filter', 'js-show'], - ], - ]; - $output['filters']['text'] = [ - '#type' => 'search', - '#title' => $this->t('Search'), - '#size' => 30, - '#placeholder' => $this->t('Enter entity type id, provider or class'), - '#attributes' => [ - 'class' => ['table-filter-text'], - 'data-table' => '.devel-filter-text', - 'autocomplete' => 'off', - 'title' => $this->t('Enter a part of the entity type id, provider or class to filter by.'), - ], - ]; - $output['entities'] = [ - '#type' => 'table', - '#header' => $headers, - '#rows' => $rows, - '#empty' => $this->t('No entity types found.'), - '#sticky' => TRUE, - '#attributes' => [ - 'class' => ['devel-entity-type-list', 'devel-filter-text'], - ], - ]; - - return $output; - } - - /** - * Returns a render array representation of the entity type. - * - * @param string $entity_type_id - * The name of the entity type to retrieve. - * - * @return array - * A render array containing the entity type. - * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - * If the requested entity type is not defined. - */ - public function entityTypeDetail($entity_type_id) { - if (!$entity_type = $this->entityTypeManager()->getDefinition($entity_type_id, FALSE)) { - throw new NotFoundHttpException(); - } - - return $this->dumper->exportAsRenderable($entity_type, $entity_type_id); - } - -} diff --git a/modules/devel/src/Controller/EventInfoController.php b/modules/devel/src/Controller/EventInfoController.php deleted file mode 100644 index e8ea0cd..0000000 --- a/modules/devel/src/Controller/EventInfoController.php +++ /dev/null @@ -1,136 +0,0 @@ -eventDispatcher = $event_dispatcher; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('event_dispatcher') - ); - } - - /** - * Builds the events overview page. - * - * @return array - * A render array as expected by the renderer. - */ - public function eventList() { - $headers = [ - 'name' => [ - 'data' => $this->t('Event Name'), - 'class' => 'visually-hidden', - ], - 'callable' => $this->t('Callable'), - 'priority' => $this->t('Priority'), - ]; - - $event_listeners = $this->eventDispatcher->getListeners(); - ksort($event_listeners); - - $rows = []; - - foreach ($event_listeners as $event_name => $listeners) { - - $rows[][] = [ - 'data' => $event_name, - 'class' => 'table-filter-text-source devel-event-name-header', - 'colspan' => '3', - 'header' => TRUE, - ]; - - foreach ($listeners as $priority => $listener) { - $row['name'] = [ - 'data' => $event_name, - 'class' => 'table-filter-text-source visually-hidden', - ]; - $row['class'] = [ - 'data' => $this->resolveCallableName($listener), - ]; - $row['priority'] = [ - 'data' => $priority, - ]; - $rows[] = $row; - } - } - - $output['#attached']['library'][] = 'system/drupal.system.modules'; - - $output['filters'] = [ - '#type' => 'container', - '#attributes' => [ - 'class' => ['table-filter', 'js-show'], - ], - ]; - $output['filters']['name'] = [ - '#type' => 'search', - '#title' => $this->t('Search'), - '#size' => 30, - '#placeholder' => $this->t('Enter event name'), - '#attributes' => [ - 'class' => ['table-filter-text'], - 'data-table' => '.devel-filter-text', - 'autocomplete' => 'off', - 'title' => $this->t('Enter a part of the event name to filter by.'), - ], - ]; - $output['events'] = [ - '#type' => 'table', - '#header' => $headers, - '#rows' => $rows, - '#empty' => $this->t('No events found.'), - '#attributes' => [ - 'class' => ['devel-event-list', 'devel-filter-text'], - ], - ]; - - return $output; - } - - /** - * Helper function for resolve callable name. - * - * @param mixed $callable - * The for which resolve the name. Can be either the name of a function - * stored in a string variable, or an object and the name of a method - * within the object. - * - * @return string - * The resolved callable name or an empty string. - */ - protected function resolveCallableName($callable) { - if (is_callable($callable, TRUE, $callable_name)) { - return $callable_name; - } - return ''; - } - -} diff --git a/modules/devel/src/Controller/LayoutInfoController.php b/modules/devel/src/Controller/LayoutInfoController.php deleted file mode 100644 index 4a2cff2..0000000 --- a/modules/devel/src/Controller/LayoutInfoController.php +++ /dev/null @@ -1,91 +0,0 @@ -layoutPluginManager = $pluginManagerLayout; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.core.layout') - ); - } - - /** - * Builds the Layout Info page. - * - * @return array - * Array of page elements to render. - */ - public function layoutInfoPage() { - $definedLayouts = []; - $layouts = $this->layoutPluginManager->getDefinitions(); - foreach ($layouts as $layout) { - // @todo Revisit once https://www.drupal.org/node/2660124 gets in, getting - // the image should be as simple as $layout->getIcon(). - $image = NULL; - if ($layout->getIconPath() != NULL) { - $image = [ - 'data' => [ - '#theme' => 'image', - '#uri' => $layout->getIconPath(), - '#alt' => $layout->getLabel(), - '#height' => '65', - ] - ]; - } - $definedLayouts[] = [ - $image, - $layout->getLabel(), - $layout->getDescription(), - $layout->getCategory(), - implode(', ', $layout->getRegionLabels()), - $layout->getProvider(), - ]; - } - - return [ - '#theme' => 'table', - '#header' => [ - $this->t('Icon'), - $this->t('Label'), - $this->t('Description'), - $this->t('Category'), - $this->t('Regions'), - $this->t('Provider'), - ], - '#rows' => $definedLayouts, - '#empty' => $this->t('No layouts available.'), - '#attributes' => [ - 'class' => ['devel-layout-list'], - ], - ]; - } - -} diff --git a/modules/devel/src/Controller/RouteInfoController.php b/modules/devel/src/Controller/RouteInfoController.php deleted file mode 100644 index 45c9f6d..0000000 --- a/modules/devel/src/Controller/RouteInfoController.php +++ /dev/null @@ -1,203 +0,0 @@ -routeProvider = $provider; - $this->router = $router; - $this->dumper = $dumper; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('router.route_provider'), - $container->get('router.no_access_checks'), - $container->get('devel.dumper') - ); - } - - /** - * Builds the routes overview page. - * - * @return array - * A render array as expected by the renderer. - */ - public function routeList() { - $headers = [ - $this->t('Route Name'), - $this->t('Path'), - $this->t('Allowed Methods'), - $this->t('Operations'), - ]; - - $rows = []; - - foreach ($this->routeProvider->getAllRoutes() as $route_name => $route) { - $row['name'] = [ - 'data' => $route_name, - 'class' => 'table-filter-text-source', - ]; - $row['path'] = [ - 'data' => $route->getPath(), - 'class' => 'table-filter-text-source', - ]; - $row['methods']['data'] = [ - '#theme' => 'item_list', - '#items' => $route->getMethods(), - '#empty' => $this->t('ANY'), - '#context' => ['list_style' => 'comma-list'], - ]; - - // We cannot resolve routes with dynamic parameters from route path. For - // these routes we pass the route name. - // @see ::routeItem() - if (strpos($route->getPath(), '{') !== FALSE) { - $parameters = ['query' => ['route_name' => $route_name]]; - } - else { - $parameters = ['query' => ['path' => $route->getPath()]]; - } - - $row['operations']['data'] = [ - '#type' => 'operations', - '#links' => [ - 'devel' => [ - 'title' => $this->t('Devel'), - 'url' => Url::fromRoute('devel.route_info.item', [], $parameters), - ], - ], - ]; - - $rows[] = $row; - } - - $output['#attached']['library'][] = 'system/drupal.system.modules'; - - $output['filters'] = [ - '#type' => 'container', - '#attributes' => [ - 'class' => ['table-filter', 'js-show'], - ], - ]; - $output['filters']['name'] = [ - '#type' => 'search', - '#title' => $this->t('Search'), - '#size' => 30, - '#placeholder' => $this->t('Enter route name or path'), - '#attributes' => [ - 'class' => ['table-filter-text'], - 'data-table' => '.devel-filter-text', - 'autocomplete' => 'off', - 'title' => $this->t('Enter a part of the route name or path to filter by.'), - ], - ]; - $output['routes'] = [ - '#type' => 'table', - '#header' => $headers, - '#rows' => $rows, - '#empty' => $this->t('No routes found.'), - '#sticky' => TRUE, - '#attributes' => [ - 'class' => ['devel-route-list', 'devel-filter-text'], - ], - ]; - - return $output; - } - - /** - * Returns a render array representation of the route object. - * - * The method tries to resolve the route from the 'path' or the 'route_name' - * query string value if available. If no route is retrieved from the query - * string parameters it fallbacks to the current route. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * The request object. - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The route match. - * - * @return array - * A render array as expected by the renderer. - */ - public function routeDetail(Request $request, RouteMatchInterface $route_match) { - $route = NULL; - - // Get the route object from the path query string if available. - if ($path = $request->query->get('path')) { - try { - $route = $this->router->match($path); - } - catch (\Exception $e) { - drupal_set_message($this->t("Unable to load route for url '%url'", ['%url' => $path]), 'warning'); - } - } - - // Get the route object from the route name query string if available and - // the route is not retrieved by path. - if ($route === NULL && $route_name = $request->query->get('route_name')) { - try { - $route = $this->routeProvider->getRouteByName($route_name); - } - catch (\Exception $e) { - drupal_set_message($this->t("Unable to load route '%name'", ['%name' => $route_name]), 'warning'); - } - } - - // No route retrieved from path or name specified, get the current route. - if ($route === NULL) { - $route = $route_match->getRouteObject(); - } - - return $this->dumper->exportAsRenderable($route); - } - -} diff --git a/modules/devel/src/Controller/SwitchUserController.php b/modules/devel/src/Controller/SwitchUserController.php deleted file mode 100644 index e5da73c..0000000 --- a/modules/devel/src/Controller/SwitchUserController.php +++ /dev/null @@ -1,120 +0,0 @@ -account = $account; - $this->userStorage = $user_storage; - $this->moduleHandler = $module_handler; - $this->sessionManager = $session_manager; - $this->session = $session; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('current_user'), - $container->get('entity.manager')->getStorage('user'), - $container->get('module_handler'), - $container->get('session_manager'), - $container->get('session') - ); - } - - /** - * Switches to a different user. - * - * We don't call session_save_session() because we really want to change users. - * Usually unsafe! - * - * @param string $name - * The username to switch to, or NULL to log out. - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse - * A redirect response object. - * - * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ - public function switchUser($name = NULL) { - if (empty($name) || !($account = $this->userStorage->loadByProperties(['name' => $name]))) { - throw new AccessDeniedHttpException(); - } - $account = reset($account); - - // Call logout hooks when switching from original user. - $this->moduleHandler->invokeAll('user_logout', [$this->account]); - - // Regenerate the session ID to prevent against session fixation attacks. - $this->sessionManager->regenerate(); - - // Based off masquarade module as: - // https://www.drupal.org/node/218104 doesn't stick and instead only - // keeps context until redirect. - $this->account->setAccount($account); - $this->session->set('uid', $account->id()); - - // Call all login hooks when switching to masquerading user. - $this->moduleHandler->invokeAll('user_login', [$account]); - - return $this->redirect('<?php ?>
tags.'),
- '#default_value' => (isset($_SESSION['devel_execute_code']) ? $_SESSION['devel_execute_code'] : ''),
- '#rows' => 20,
- );
- $form['execute']['op'] = array('#type' => 'submit', '#value' => t('Execute'));
- $form['#redirect'] = FALSE;
- if (isset($_SESSION['devel_execute_code'])) {
- unset($_SESSION['devel_execute_code']);
- }
-
- return $form;
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- ob_start();
- $code = $form_state->getValue('code');
- print eval($code);
- $_SESSION['devel_execute_code'] = $code;
- dpm(ob_get_clean());
- }
-
-}
diff --git a/modules/devel/src/Form/RouterRebuildConfirmForm.php b/modules/devel/src/Form/RouterRebuildConfirmForm.php
deleted file mode 100644
index a1daf89..0000000
--- a/modules/devel/src/Form/RouterRebuildConfirmForm.php
+++ /dev/null
@@ -1,86 +0,0 @@
-routeBuilder = $route_builder;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('router.builder')
- );
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'devel_menu_rebuild';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getQuestion() {
- return $this->t('Are you sure you want to rebuild the router?');
- }
-
- /**
- * {@inheritdoc}
- */
- public function getCancelUrl() {
- return new Url('' . $name . $dump . ''; - - return $this->setSafeMarkup($dump); - } - - /** - * {@inheritdoc} - */ - public function exportAsRenderable($input, $name = NULL) { - $output['container'] = [ - '#type' => 'details', - '#title' => $name ? : $this->t('Variable'), - '#attached' => [ - 'library' => ['devel/devel'] - ], - '#attributes' => [ - 'class' => ['container-inline', 'devel-dumper', 'devel-selectable'], - ], - 'export' => [ - '#markup' => $this->export($input), - ], - ]; - - return $output; - } - - /** - * {@inheritdoc} - */ - public static function checkRequirements() { - return TRUE; - } - -} diff --git a/modules/devel/src/Plugin/Devel/Dumper/DrupalVariable.php b/modules/devel/src/Plugin/Devel/Dumper/DrupalVariable.php deleted file mode 100644 index a1561e3..0000000 --- a/modules/devel/src/Plugin/Devel/Dumper/DrupalVariable.php +++ /dev/null @@ -1,61 +0,0 @@ -Drupal Variable class.") - * ) - */ -class DrupalVariable extends DevelDumperBase { - - /** - * {@inheritdoc} - */ - public function export($input, $name = NULL) { - $name = $name ? $name . ' => ' : ''; - $dump = Variable::export($input); - // Run Xss::filterAdmin on the resulting string to prevent - // cross-site-scripting (XSS) vulnerabilities. - $dump = Xss::filterAdmin($dump); - $dump = '
' . $name . $dump . ''; - return $this->setSafeMarkup($dump); - } - - /** - * {@inheritdoc} - */ - public function exportAsRenderable($input, $name = NULL) { - $output['container'] = [ - '#type' => 'details', - '#title' => $name ? : $this->t('Variable'), - '#attached' => [ - 'library' => ['devel/devel'] - ], - '#attributes' => [ - 'class' => ['container-inline', 'devel-dumper', 'devel-selectable'], - ], - 'export' => [ - '#markup' => $this->export($input), - ], - ]; - - return $output; - } - - /** - * {@inheritdoc} - */ - public static function checkRequirements() { - return TRUE; - } - -} diff --git a/modules/devel/src/Plugin/Devel/Dumper/FirePhp.php b/modules/devel/src/Plugin/Devel/Dumper/FirePhp.php deleted file mode 100644 index 9140d00..0000000 --- a/modules/devel/src/Plugin/Devel/Dumper/FirePhp.php +++ /dev/null @@ -1,41 +0,0 @@ -FirePhp debugging tool.") - * ) - */ -class FirePhp extends DevelDumperBase { - - /** - * {@inheritdoc} - */ - public function dump($input, $name = NULL) { - $fb = new \FB(); - $fb->dump($name, $input); - } - - /** - * {@inheritdoc} - */ - public function export($input, $name = NULL) { - $this->dump($input); - return $this->t('Dump was redirected to the console.'); - } - - /** - * {@inheritdoc} - */ - public static function checkRequirements() { - return class_exists('FirePHP', TRUE); - } - -} diff --git a/modules/devel/src/Plugin/Devel/Dumper/VarDumper.php b/modules/devel/src/Plugin/Devel/Dumper/VarDumper.php deleted file mode 100644 index 59200fa..0000000 --- a/modules/devel/src/Plugin/Devel/Dumper/VarDumper.php +++ /dev/null @@ -1,47 +0,0 @@ -Symfony var-dumper debugging tool."), - * ) - * - */ -class VarDumper extends DevelDumperBase { - - /** - * {@inheritdoc} - */ - public function export($input, $name = NULL) { - $cloner = new VarCloner(); - $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper(); - - $output = fopen('php://memory', 'r+b'); - $dumper->dump($cloner->cloneVar($input), $output); - $output = stream_get_contents($output, -1, 0); - - if ($name) { - $output = $name . ' => ' . $output; - } - - return $this->setSafeMarkup($output); - } - - /** - * {@inheritdoc} - */ - public static function checkRequirements() { - return class_exists('Symfony\Component\VarDumper\Cloner\VarCloner', TRUE); - } - -} diff --git a/modules/devel/src/Plugin/Mail/DevelMailLog.php b/modules/devel/src/Plugin/Mail/DevelMailLog.php deleted file mode 100644 index 16cafc1..0000000 --- a/modules/devel/src/Plugin/Mail/DevelMailLog.php +++ /dev/null @@ -1,188 +0,0 @@ -config = $config_factory->get('devel.settings'); - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('config.factory') - ); - } - - /** - * {@inheritdoc} - */ - public function mail(array $message) { - $directory = $this->config->get('debug_mail_directory'); - - if (!$this->prepareDirectory($directory)) { - return FALSE; - } - - $pattern = $this->config->get('debug_mail_file_format'); - $filename = $this->replacePlaceholders($pattern, $message); - $output = $this->composeMessage($message); - - return (bool) file_put_contents($directory . '/' . $filename, $output); - } - - /** - * {@inheritdoc} - */ - public function format(array $message) { - // Join the body array into one string. - $message['body'] = implode("\n\n", $message['body']); - - // Convert any HTML to plain-text. - $message['body'] = MailFormatHelper::htmlToText($message['body']); - // Wrap the mail body for sending. - $message['body'] = MailFormatHelper::wrapMail($message['body']); - - return $message; - } - - /** - * Compose the output message. - * - * @param array $message - * A message array, as described in hook_mail_alter(). - * - * @return string - * The output message. - */ - protected function composeMessage($message) { - $mimeheaders = []; - $message['headers']['To'] = $message['to']; - foreach ($message['headers'] as $name => $value) { - $mimeheaders[] = $name . ': ' . Unicode::mimeHeaderEncode($value); - } - - $line_endings = Settings::get('mail_line_endings', PHP_EOL); - $output = join($line_endings, $mimeheaders) . $line_endings; - // 'Subject:' is a mail header and should not be translated. - $output .= 'Subject: ' . $message['subject'] . $line_endings; - // Blank line to separate headers from body. - $output .= $line_endings; - $output .= preg_replace('@\r?\n@', $line_endings, $message['body']); - return $output; - } - - /** - * Replaces placeholders with sanitized values in a string. - * - * @param $filename - * The string that contains the placeholders. The following placeholders - * are considered in the replacement: - * - %to: replaced by the email recipient value. - * - %subject: replaced by the email subject value. - * - %datetime: replaced by the current datetime in 'y-m-d_his' format. - * @param array $message - * A message array, as described in hook_mail_alter(). - * - * @return string - * The formatted string. - */ - protected function replacePlaceholders($filename, $message) { - $tokens = [ - '%to' => $message['to'], - '%subject' => $message['subject'], - '%datetime' => date('y-m-d_his'), - ]; - $filename = str_replace(array_keys($tokens), array_values($tokens), $filename); - return preg_replace('/[^a-zA-Z0-9_\-\.@]/', '_', $filename); - } - - /** - * Checks that the directory exists and is writable. - * Public directories will be protected by adding an .htaccess which - * indicates that the directory is private. - * - * @param $directory - * A string reference containing the name of a directory path or URI. - * - * @return bool - * TRUE if the directory exists (or was created), is writable and is - * protected (if it is public). FALSE otherwise. - */ - protected function prepareDirectory($directory) { - if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) { - return FALSE; - } - if (0 === strpos($directory, 'public://')) { - return file_save_htaccess($directory); - } - - return TRUE; - } - -} diff --git a/modules/devel/src/Plugin/Menu/DestinationMenuLink.php b/modules/devel/src/Plugin/Menu/DestinationMenuLink.php deleted file mode 100644 index 4edf1c3..0000000 --- a/modules/devel/src/Plugin/Menu/DestinationMenuLink.php +++ /dev/null @@ -1,32 +0,0 @@ -')->toString(); - return $options; - } - - /** - * {@inheritdoc} - * - * @todo Make cacheable once https://www.drupal.org/node/2582797 lands. - */ - public function getCacheMaxAge() { - return 0; - } - -} diff --git a/modules/devel/src/Plugin/Menu/MenuItemMenuLink.php b/modules/devel/src/Plugin/Menu/MenuItemMenuLink.php deleted file mode 100644 index 1dd26e5..0000000 --- a/modules/devel/src/Plugin/Menu/MenuItemMenuLink.php +++ /dev/null @@ -1,11 +0,0 @@ -')->getInternalPath(); - return $options; - } - - /** - * {@inheritdoc} - */ - public function getCacheMaxAge() { - return 0; - } - -} diff --git a/modules/devel/src/Render/FilteredMarkup.php b/modules/devel/src/Render/FilteredMarkup.php deleted file mode 100644 index d43c0d5..0000000 --- a/modules/devel/src/Render/FilteredMarkup.php +++ /dev/null @@ -1,23 +0,0 @@ -entityTypeManager = $entity_manager; - } - - /** - * {@inheritdoc} - */ - protected function alterRoutes(RouteCollection $collection) { - foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { - if ($route = $this->getEntityLoadRoute($entity_type)) { - $collection->add("entity.$entity_type_id.devel_load", $route); - } - if ($route = $this->getEntityRenderRoute($entity_type)) { - $collection->add("entity.$entity_type_id.devel_render", $route); - } - if ($route = $this->getEntityTypeDefinitionRoute($entity_type)) { - $collection->add("entity.$entity_type_id.devel_definition", $route); - } - } - } - - /** - * Gets the entity load route. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type. - * - * @return \Symfony\Component\Routing\Route|null - * The generated route, if available. - */ - protected function getEntityLoadRoute(EntityTypeInterface $entity_type) { - if ($devel_load = $entity_type->getLinkTemplate('devel-load')) { - $entity_type_id = $entity_type->id(); - $route = new Route($devel_load); - $route - ->addDefaults([ - '_controller' => '\Drupal\devel\Controller\EntityDebugController::entityLoad', - '_title' => 'Devel Load', - ]) - ->addRequirements([ - '_permission' => 'access devel information', - ]) - ->setOption('_admin_route', TRUE) - ->setOption('_devel_entity_type_id', $entity_type_id) - ->setOption('parameters', [ - $entity_type_id => ['type' => 'entity:' . $entity_type_id], - ]); - - return $route; - } - } - - /** - * Gets the entity render route. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type. - * - * @return \Symfony\Component\Routing\Route|null - * The generated route, if available. - */ - protected function getEntityRenderRoute(EntityTypeInterface $entity_type) { - if ($devel_render = $entity_type->getLinkTemplate('devel-render')) { - $entity_type_id = $entity_type->id(); - $route = new Route($devel_render); - $route - ->addDefaults([ - '_controller' => '\Drupal\devel\Controller\EntityDebugController::entityRender', - '_title' => 'Devel Render', - ]) - ->addRequirements([ - '_permission' => 'access devel information' - ]) - ->setOption('_admin_route', TRUE) - ->setOption('_devel_entity_type_id', $entity_type_id) - ->setOption('parameters', [ - $entity_type_id => ['type' => 'entity:' . $entity_type_id], - ]); - - return $route; - } - } - - /** - * Gets the entity type definition route. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type. - * - * @return \Symfony\Component\Routing\Route|null - * The generated route, if available. - */ - protected function getEntityTypeDefinitionRoute(EntityTypeInterface $entity_type) { - if ($devel_definition = $entity_type->getLinkTemplate('devel-definition')) { - $entity_type_id = $entity_type->id(); - $route = new Route($devel_definition); - $route - ->addDefaults([ - '_controller' => '\Drupal\devel\Controller\EntityDebugController::entityTypeDefinition', - '_title' => 'Entity type definition', - ]) - ->addRequirements([ - '_permission' => 'access devel information' - ]) - ->setOption('_admin_route', TRUE) - ->setOption('_devel_entity_type_id', $entity_type_id) - ->setOption('parameters', [ - $entity_type_id => ['type' => 'entity:' . $entity_type_id], - ]); - - return $route; - } - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() { - $events = parent::getSubscribedEvents(); - $events[RoutingEvents::ALTER] = ['onAlterRoutes', 100]; - return $events; - } - -} diff --git a/modules/devel/src/ToolbarHandler.php b/modules/devel/src/ToolbarHandler.php deleted file mode 100644 index 0d7cbcd..0000000 --- a/modules/devel/src/ToolbarHandler.php +++ /dev/null @@ -1,181 +0,0 @@ -menuLinkTree = $menu_link_tree; - $this->config = $config_factory->get('devel.toolbar.settings'); - $this->account = $account; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('toolbar.menu_tree'), - $container->get('config.factory'), - $container->get('current_user') - ); - } - - /** - * Hook bridge. - * - * @return array - * The devel toolbar items render array. - * - * @see hook_toolbar() - */ - public function toolbar() { - $items['devel'] = [ - '#cache' => [ - 'contexts' => ['user.permissions'], - ], - ]; - - if ($this->account->hasPermission('access devel information')) { - $items['devel'] += [ - '#type' => 'toolbar_item', - '#weight' => 999, - 'tab' => [ - '#type' => 'link', - '#title' => $this->t('Devel'), - '#url' => Url::fromRoute('devel.admin_settings'), - '#attributes' => [ - 'title' => $this->t('Development menu'), - 'class' => ['toolbar-icon', 'toolbar-icon-devel'], - ], - ], - 'tray' => [ - '#heading' => $this->t('Development menu'), - 'devel_menu' => [ - // Currently devel menu is uncacheable, so instead of poisoning the - // entire page cache we use a lazy builder. - // @see \Drupal\devel\Plugin\Menu\DestinationMenuLink - // @see \Drupal\devel\Plugin\Menu\RouteDetailMenuItem - '#lazy_builder' => [ToolbarHandler::class . ':lazyBuilder', []], - // Force the creation of the placeholder instead of rely on the - // automatical placeholdering or otherwise the page results - // uncacheable when max-age 0 is bubbled up. - '#create_placeholder' => TRUE, - ], - 'configuration' => [ - '#type' => 'link', - '#title' => $this->t('Configure'), - '#url' => Url::fromRoute('devel.toolbar.settings_form'), - '#options' => [ - 'attributes' => ['class' => ['edit-devel-toolbar']], - ], - ], - ], - '#attached' => [ - 'library' => 'devel/devel-toolbar', - ], - ]; - } - - return $items; - } - - /** - * Lazy builder callback for the devel menu toolbar. - * - * @return array - * The renderable array rapresentation of the devel menu. - */ - public function lazyBuilder() { - $parameters = new MenuTreeParameters(); - $parameters->onlyEnabledLinks()->setTopLevelOnly(); - - $tree = $this->menuLinkTree->load('devel', $parameters); - - $manipulators = [ - ['callable' => 'menu.default_tree_manipulators:checkAccess'], - ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'], - ['callable' => ToolbarHandler::class . ':processTree'], - ]; - $tree = $this->menuLinkTree->transform($tree, $manipulators); - - $build = $this->menuLinkTree->build($tree); - - CacheableMetadata::createFromRenderArray($build) - ->addCacheableDependency($this->config) - ->applyTo($build); - - return $build; - } - - /** - * Adds toolbar-specific attributes to the menu link tree. - * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree - * The menu link tree to manipulate. - * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] - * The manipulated menu link tree. - */ - public function processTree(array $tree) { - $visible_items = $this->config->get('toolbar_items') ?: []; - - foreach ($tree as $element) { - $plugin_id = $element->link->getPluginId(); - if (!in_array($plugin_id, $visible_items)) { - // Add a class that allow to hide the non prioritized menu items when - // the toolbar has horizontal orientation. - $element->options['attributes']['class'][] = 'toolbar-horizontal-item-hidden'; - } - } - - return $tree; - } - -} diff --git a/modules/devel/src/Twig/Extension/Debug.php b/modules/devel/src/Twig/Extension/Debug.php deleted file mode 100644 index 9922e61..0000000 --- a/modules/devel/src/Twig/Extension/Debug.php +++ /dev/null @@ -1,201 +0,0 @@ -dumper = $dumper; - } - - /** - * {@inheritdoc} - */ - public function getName() { - return 'devel_debug'; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() { - $functions = []; - - foreach (['devel_dump', 'kpr'] as $function) { - $functions[] = new \Twig_SimpleFunction($function, [$this, 'dump'], [ - 'is_safe' => ['html'], - 'needs_environment' => TRUE, - 'needs_context' => TRUE, - 'is_variadic' => TRUE, - ]); - } - - foreach (['devel_message', 'dpm', 'dsm'] as $function) { - $functions[] = new \Twig_SimpleFunction($function, [$this, 'message'], [ - 'is_safe' => ['html'], - 'needs_environment' => TRUE, - 'needs_context' => TRUE, - 'is_variadic' => TRUE, - ]); - } - - foreach (['devel_breakpoint'] as $function) { - $functions[] = new \Twig_SimpleFunction($function, [$this, 'breakpoint'], [ - 'needs_environment' => TRUE, - 'needs_context' => TRUE, - 'is_variadic' => TRUE, - ]); - } - - return $functions; - } - - /** - * Provides debug function to Twig templates. - * - * Handles 0, 1, or multiple arguments. - * - * @param \Twig_Environment $env - * The twig environment instance. - * @param array $context - * An array of parameters passed to the template. - * @param array $args - * An array of parameters passed the function. - * - * @return string - * String representation of the input variables. - * - * @see \Drupal\devel\DevelDumperManager::dump() - */ - public function dump(\Twig_Environment $env, array $context, array $args = []) { - if (!$env->isDebug()) { - return; - } - - ob_start(); - - // No arguments passed, display full Twig context. - if (empty($args)) { - $context_variables = $this->getContextVariables($context); - $this->dumper->dump($context_variables, 'Twig context'); - } - else { - foreach ($args as $variable) { - $this->dumper->dump($variable); - } - } - - return ob_get_clean(); - } - - /** - * Provides debug function to Twig templates. - * - * Handles 0, 1, or multiple arguments. - * - * @param \Twig_Environment $env - * The twig environment instance. - * @param array $context - * An array of parameters passed to the template. - * @param array $args - * An array of parameters passed the function. - * - * @return void - * - * @see \Drupal\devel\DevelDumperManager::message() - */ - public function message(\Twig_Environment $env, array $context, array $args = []) { - if (!$env->isDebug()) { - return; - } - - // No arguments passed, display full Twig context. - if (empty($args)) { - $context_variables = $this->getContextVariables($context); - $this->dumper->message($context_variables, 'Twig context'); - } - else { - foreach ($args as $variable) { - $this->dumper->message($variable); - } - } - - } - - /** - * Provides XDebug integration for Twig templates. - * - * To use this features simply put the following statement in the template - * of interest: - * - * @code - * {{ devel_breakpoint() }} - * @endcode - * - * When the template is evaluated is made a call to a dedicated method in - * devel twig debug extension in which is used xdebug_break(), that emits a - * breakpoint to the debug client (the debugger break on the specific line as - * if a normal file/line breakpoint was set on this line). - * In this way you'll be able to inspect any variables available in the - * template (environment, context, specific variables etc..) in your IDE. - * - * @param \Twig_Environment $env - * The twig environment instance. - * @param array $context - * An array of parameters passed to the template. - * @param array $args - * An array of parameters passed the function. - */ - public function breakpoint(\Twig_Environment $env, array $context, array $args = []) { - if (!$env->isDebug()) { - return; - } - - if (function_exists('xdebug_break')) { - xdebug_break(); - } - } - - /** - * Filters the Twig context variable. - * - * @param array $context - * The Twig context. - * - * @return array - * An array Twig context variables. - */ - protected function getContextVariables(array $context) { - $context_variables = []; - foreach ($context as $key => $value) { - if (!$value instanceof \Twig_Template) { - $context_variables[$key] = $value; - } - } - return $context_variables; - } - -} diff --git a/modules/devel/tests/modules/devel_dumper_test/css/devel_dumper_test.css b/modules/devel/tests/modules/devel_dumper_test/css/devel_dumper_test.css deleted file mode 100644 index e69de29..0000000 diff --git a/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.info.yml b/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.info.yml deleted file mode 100644 index 265aeb3..0000000 --- a/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.info.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Devel dumper test module' -type: module -description: 'Test pluggable dumpers.' -package: Testing -# version: VERSION -# core: 8.x - -# Information added by Drupal.org packaging script on 2017-10-05 -version: '8.x-1.2' -core: '8.x' -project: 'devel' -datestamp: 1507197848 diff --git a/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.libraries.yml b/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.libraries.yml deleted file mode 100644 index 8e8c2ad..0000000 --- a/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.libraries.yml +++ /dev/null @@ -1,7 +0,0 @@ -devel_dumper_test: - version: 0 - css: - theme: - css/devel_dumper_test.css: {} - js: - js/devel_dumper_test.js: {} diff --git a/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.routing.yml b/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.routing.yml deleted file mode 100644 index 650b337..0000000 --- a/modules/devel/tests/modules/devel_dumper_test/devel_dumper_test.routing.yml +++ /dev/null @@ -1,39 +0,0 @@ -devel_dumper_test.dump: - path: '/devel_dumper_test/dump' - defaults: - _controller: '\Drupal\devel_dumper_test\Controller\DumperTestController::dump' - _title: 'Devel Dumper Test' - requirements: - _permission: 'access devel information' - -devel_dumper_test.message: - path: '/devel_dumper_test/message' - defaults: - _controller: '\Drupal\devel_dumper_test\Controller\DumperTestController::message' - _title: 'Devel Dumper Test' - requirements: - _permission: 'access devel information' - -devel_dumper_test.export: - path: '/devel_dumper_test/export' - defaults: - _controller: '\Drupal\devel_dumper_test\Controller\DumperTestController::export' - _title: 'Devel Dumper Test' - requirements: - _permission: 'access devel information' - -devel_dumper_test.export_renderable: - path: '/devel_dumper_test/export_renderable' - defaults: - _controller: '\Drupal\devel_dumper_test\Controller\DumperTestController::exportRenderable' - _title: 'Devel Dumper Test' - requirements: - _permission: 'access devel information' - -devel_dumper_test.debug: - path: '/devel_dumper_test/debug' - defaults: - _controller: '\Drupal\devel_dumper_test\Controller\DumperTestController::debug' - _title: 'Devel Dumper Test' - requirements: - _access: 'TRUE' diff --git a/modules/devel/tests/modules/devel_dumper_test/js/devel_dumper_test.js b/modules/devel/tests/modules/devel_dumper_test/js/devel_dumper_test.js deleted file mode 100644 index e69de29..0000000 diff --git a/modules/devel/tests/modules/devel_dumper_test/src/Controller/DumperTestController.php b/modules/devel/tests/modules/devel_dumper_test/src/Controller/DumperTestController.php deleted file mode 100644 index 2a78e6e..0000000 --- a/modules/devel/tests/modules/devel_dumper_test/src/Controller/DumperTestController.php +++ /dev/null @@ -1,89 +0,0 @@ -dumper = $devel_dumper_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('devel.dumper') - ); - } - - /** - * @return array - */ - public function dump() { - $this->dumper->dump('Test output'); - - return [ - '#markup' => 'test', - ]; - } - - /** - * @return array - */ - public function message() { - $this->dumper->message('Test output'); - - return [ - '#markup' => 'test', - ]; - } - - /** - * @return array - */ - public function debug() { - $this->dumper->debug('Test output'); - - return [ - '#markup' => 'test', - ]; - } - - /** - * @return array - */ - public function export() { - return [ - '#markup' => $this->dumper->export('Test output'), - ]; - } - - /** - * @return array - */ - public function exportRenderable() { - return $this->dumper->exportAsRenderable('Test output'); - } - -} diff --git a/modules/devel/tests/modules/devel_dumper_test/src/Plugin/Devel/Dumper/AvailableTestDumper.php b/modules/devel/tests/modules/devel_dumper_test/src/Plugin/Devel/Dumper/AvailableTestDumper.php deleted file mode 100644 index b15f567..0000000 --- a/modules/devel/tests/modules/devel_dumper_test/src/Plugin/Devel/Dumper/AvailableTestDumper.php +++ /dev/null @@ -1,60 +0,0 @@ -' . 'AvailableTestDumper::dump() ' . $input . ''; - echo $input; - } - - /** - * {@inheritdoc} - */ - public function export($input, $name = NULL) { - // Add a predetermined string to $input to check if this dumper has been - // selected successfully. - $input = '
' . 'AvailableTestDumper::export() ' . $input . ''; - return $this->setSafeMarkup($input); - } - - /** - * {@inheritdoc} - */ - public function exportAsRenderable($input, $name = NULL) { - // Add a predetermined string to $input to check if this dumper has been - // selected successfully. - $input = '
' . 'AvailableTestDumper::exportAsRenderable() ' . $input . ''; - - return [ - '#attached' => [ - 'library' => ['devel_dumper_test/devel_dumper_test'] - ], - '#markup' => $this->setSafeMarkup($input), - ]; - } - - /** - * {@inheritdoc} - */ - public static function checkRequirements() { - return TRUE; - } -} diff --git a/modules/devel/tests/modules/devel_dumper_test/src/Plugin/Devel/Dumper/NotAvailableTestDumper.php b/modules/devel/tests/modules/devel_dumper_test/src/Plugin/Devel/Dumper/NotAvailableTestDumper.php deleted file mode 100644 index 2b0d886..0000000 --- a/modules/devel/tests/modules/devel_dumper_test/src/Plugin/Devel/Dumper/NotAvailableTestDumper.php +++ /dev/null @@ -1,41 +0,0 @@ -' . $input . ''; - echo $input; - } - - /** - * {@inheritdoc} - */ - public function export($input, $name = NULL) { - $input = '
' . $input . ''; - return $this->setSafeMarkup($input); - } - - /** - * {@inheritdoc} - */ - public static function checkRequirements() { - return FALSE; - } - -} diff --git a/modules/devel/tests/modules/devel_entity_test/devel_entity_test.info.yml b/modules/devel/tests/modules/devel_entity_test/devel_entity_test.info.yml deleted file mode 100644 index 4b01554..0000000 --- a/modules/devel/tests/modules/devel_entity_test/devel_entity_test.info.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: 'Devel entity test module' -type: module -description: 'Provides entity types for Devel tests.' -package: Testing -# version: VERSION -# core: 8.x -dependencies: - - field - - text - - entity_test - -# Information added by Drupal.org packaging script on 2017-10-05 -version: '8.x-1.2' -core: '8.x' -project: 'devel' -datestamp: 1507197848 diff --git a/modules/devel/tests/modules/devel_entity_test/devel_entity_test.links.task.yml b/modules/devel/tests/modules/devel_entity_test/devel_entity_test.links.task.yml deleted file mode 100644 index 052baa9..0000000 --- a/modules/devel/tests/modules/devel_entity_test/devel_entity_test.links.task.yml +++ /dev/null @@ -1,2 +0,0 @@ -devel_entity_test.local_tasks: - deriver: 'Drupal\devel_entity_test\Plugin\Derivative\DevelEntityTestLocalTasks' diff --git a/modules/devel/tests/modules/devel_entity_test/devel_entity_test.module b/modules/devel/tests/modules/devel_entity_test/devel_entity_test.module deleted file mode 100644 index 4be887b..0000000 --- a/modules/devel/tests/modules/devel_entity_test/devel_entity_test.module +++ /dev/null @@ -1,29 +0,0 @@ -getDefinitions(); - foreach ($entity_info as $entity_type => $info) { - if ($entity_info[$entity_type]->getProvider() == 'devel_entity_test_canonical' && !isset($view_modes[$entity_type])) { - $view_modes[$entity_type] = array( - 'full' => array( - 'label' => t('Full object'), - 'status' => TRUE, - 'cache' => TRUE, - ), - 'teaser' => array( - 'label' => t('Teaser'), - 'status' => TRUE, - 'cache' => TRUE, - ), - ); - } - } -} diff --git a/modules/devel/tests/modules/devel_entity_test/src/Entity/DevelEntityTestCanonical.php b/modules/devel/tests/modules/devel_entity_test/src/Entity/DevelEntityTestCanonical.php deleted file mode 100644 index e7ed04f..0000000 --- a/modules/devel/tests/modules/devel_entity_test/src/Entity/DevelEntityTestCanonical.php +++ /dev/null @@ -1,44 +0,0 @@ -derivatives = array(); - - $this->derivatives['devel_entity_test_canonical.canonical'] = array(); - $this->derivatives['devel_entity_test_canonical.canonical']['base_route'] = "entity.devel_entity_test_canonical.canonical"; - $this->derivatives['devel_entity_test_canonical.canonical']['route_name'] = "entity.devel_entity_test_canonical.canonical"; - $this->derivatives['devel_entity_test_canonical.canonical']['title'] = 'View'; - - $this->derivatives['devel_entity_test_edit.edit'] = array(); - $this->derivatives['devel_entity_test_edit.edit']['base_route'] = "entity.devel_entity_test_edit.edit_form"; - $this->derivatives['devel_entity_test_edit.edit']['route_name'] = "entity.devel_entity_test_edit.edit_form"; - $this->derivatives['devel_entity_test_edit.edit']['title'] = 'Edit'; - - return parent::getDerivativeDefinitions($base_plugin_definition); - } - -} diff --git a/modules/devel/tests/modules/devel_test/devel_test.info.yml b/modules/devel/tests/modules/devel_test/devel_test.info.yml deleted file mode 100644 index 191c825..0000000 --- a/modules/devel/tests/modules/devel_test/devel_test.info.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Devel test module' -type: module -description: 'Support module for Devel testing.' -package: Testing -# version: VERSION -# core: 8.x - -# Information added by Drupal.org packaging script on 2017-10-05 -version: '8.x-1.2' -core: '8.x' -project: 'devel' -datestamp: 1507197848 diff --git a/modules/devel/tests/modules/devel_test/devel_test.module b/modules/devel/tests/modules/devel_test/devel_test.module deleted file mode 100644 index e94fb71..0000000 --- a/modules/devel/tests/modules/devel_test/devel_test.module +++ /dev/null @@ -1,20 +0,0 @@ - $this->t('Simple page'), - ]; - } - -} diff --git a/modules/devel/tests/modules/devel_test/src/Routing/TestRouteSubscriber.php b/modules/devel/tests/modules/devel_test/src/Routing/TestRouteSubscriber.php deleted file mode 100644 index 1bf9332..0000000 --- a/modules/devel/tests/modules/devel_test/src/Routing/TestRouteSubscriber.php +++ /dev/null @@ -1,20 +0,0 @@ -set('devel_test_route_rebuild','Router rebuild fired'); - } - -} diff --git a/modules/devel/tests/src/Functional/DevelContainerInfoTest.php b/modules/devel/tests/src/Functional/DevelContainerInfoTest.php deleted file mode 100644 index c47d773..0000000 --- a/modules/devel/tests/src/Functional/DevelContainerInfoTest.php +++ /dev/null @@ -1,261 +0,0 @@ -drupalPlaceBlock('local_tasks_block'); - $this->drupalPlaceBlock('page_title_block'); - - $this->develUser = $this->drupalCreateUser(['access devel information']); - $this->drupalLogin($this->develUser); - } - - /** - * Tests container info menu link. - */ - public function testContainerInfoMenuLink() { - $this->drupalPlaceBlock('system_menu_block:devel'); - // Ensures that the events info link is present on the devel menu and that - // it points to the correct page. - $this->drupalGet(''); - $this->clickLink('Container Info'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->addressEquals('/devel/container/service'); - $this->assertSession()->pageTextContains('Container services'); - } - - /** - * Tests service list page. - */ - public function testServiceList() { - $this->drupalGet('/devel/container/service'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Container services'); - $this->assertContainerInfoLocalTasks(); - - $page = $this->getSession()->getPage(); - - // Ensures that the services table is found. - $table = $page->find('css', 'table.devel-service-list'); - $this->assertNotNull($table); - - // Ensures that the expected table headers are found. - /** @var $headers \Behat\Mink\Element\NodeElement[] */ - $headers = $table->findAll('css', 'thead th'); - $this->assertEquals(4, count($headers)); - - $expected_headers = ['ID', 'Class', 'Alias', 'Operations']; - $actual_headers = array_map(function ($element) { - return $element->getText(); - }, $headers); - $this->assertSame($expected_headers, $actual_headers); - - // Ensures that all the serivices are listed in the table. - $cached_definition = \Drupal::service('kernel')->getCachedContainerDefinition(); - $this->assertNotNull($cached_definition); - $rows = $table->findAll('css', 'tbody tr'); - $this->assertEquals(count($cached_definition['services']), count($rows)); - - // Tests the presence of some (arbitrarily chosen) services in the table. - $expected_services = [ - 'config.factory' => [ - 'class' => 'Drupal\Core\Config\ConfigFactory', - 'alias' => '', - ], - 'devel.route_subscriber' => [ - 'class' => 'Drupal\devel\Routing\RouteSubscriber', - 'alias' => '', - ], - 'plugin.manager.element_info' => [ - 'class' => 'Drupal\Core\Render\ElementInfoManager', - 'alias' => 'element_info', - ], - ]; - - foreach ($expected_services as $service_id => $expected) { - $row = $table->find('css', sprintf('tbody tr:contains("%s")', $service_id)); - $this->assertNotNull($row); - - /** @var $cells \Behat\Mink\Element\NodeElement[] */ - $cells = $row->findAll('css', 'td'); - $this->assertEquals(4, count($cells)); - - $cell_service_id = $cells[0]; - $this->assertEquals($service_id, $cell_service_id->getText()); - $this->assertTrue($cell_service_id->hasClass('table-filter-text-source')); - - $cell_class = $cells[1]; - $this->assertEquals($expected['class'], $cell_class->getText()); - $this->assertTrue($cell_class->hasClass('table-filter-text-source')); - - $cell_alias = $cells[2]; - $this->assertEquals($expected['alias'], $cell_alias->getText()); - $this->assertTrue($cell_class->hasClass('table-filter-text-source')); - - $cell_operations = $cells[3]; - $actual_href = $cell_operations->findLink('Devel')->getAttribute('href'); - $expected_href = Url::fromRoute('devel.container_info.service.detail', ['service_id' => $service_id])->toString(); - $this->assertEquals($expected_href, $actual_href); - } - - // Ensures that the page is accessible ony to users with the adequate - // permissions. - $this->drupalLogout(); - $this->drupalGet('devel/container/service'); - $this->assertSession()->statusCodeEquals(403); - } - - /** - * Tests service detail page. - */ - public function testServiceDetail() { - $service_id = 'devel.dumper'; - - // Ensures that the page works as expected. - $this->drupalGet("/devel/container/service/$service_id"); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains("Service $service_id detail"); - - // Ensures that the page returns a 404 error if the requested service is - // not defined. - $this->drupalGet('/devel/container/service/not.exists'); - $this->assertSession()->statusCodeEquals(404); - - // Ensures that the page is accessible ony to users with the adequate - // permissions. - $this->drupalLogout(); - $this->drupalGet("devel/container/service/$service_id"); - $this->assertSession()->statusCodeEquals(403); - } - - /** - * Tests parameter list page. - */ - public function testParameterList() { - // Ensures that the page works as expected. - $this->drupalGet('/devel/container/parameter'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Container parameters'); - $this->assertContainerInfoLocalTasks(); - - $page = $this->getSession()->getPage(); - - // Ensures that the parameters table is found. - $table = $page->find('css', 'table.devel-parameter-list'); - $this->assertNotNull($table); - - // Ensures that the expected table headers are found. - /** @var $headers \Behat\Mink\Element\NodeElement[] */ - $headers = $table->findAll('css', 'thead th'); - $this->assertEquals(2, count($headers)); - - $expected_headers = ['Name', 'Operations']; - $actual_headers = array_map(function ($element) { - return $element->getText(); - }, $headers); - $this->assertSame($expected_headers, $actual_headers); - - // Ensures that all the parameters are listed in the table. - $cached_definition = \Drupal::service('kernel')->getCachedContainerDefinition(); - $this->assertNotNull($cached_definition); - $rows = $table->findAll('css', 'tbody tr'); - $this->assertEquals(count($cached_definition['parameters']), count($rows)); - - // Tests the presence of some parameters in the table. - $expected_parameters = [ - 'container.modules', - 'cache_bins', - 'factory.keyvalue', - 'twig.config', - ]; - - foreach ($expected_parameters as $parameter_name) { - $row = $table->find('css', sprintf('tbody tr:contains("%s")', $parameter_name)); - $this->assertNotNull($row); - - /** @var $cells \Behat\Mink\Element\NodeElement[] */ - $cells = $row->findAll('css', 'td'); - $this->assertEquals(2, count($cells)); - - $cell_parameter_name = $cells[0]; - $this->assertEquals($parameter_name, $cell_parameter_name->getText()); - $this->assertTrue($cell_parameter_name->hasClass('table-filter-text-source')); - - $cell_operations = $cells[1]; - $actual_href = $cell_operations->findLink('Devel')->getAttribute('href'); - $expected_href = Url::fromRoute('devel.container_info.parameter.detail', ['parameter_name' => $parameter_name])->toString(); - $this->assertEquals($expected_href, $actual_href); - } - - // Ensures that the page is accessible ony to users with the adequate - // permissions. - $this->drupalLogout(); - $this->drupalGet('devel/container/service'); - $this->assertSession()->statusCodeEquals(403); - } - - /** - * Tests parameter detail page. - */ - public function testParameterDetail() { - $parameter_name = 'cache_bins'; - - // Ensures that the page works as expected. - $this->drupalGet("/devel/container/parameter/$parameter_name"); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains("Parameter $parameter_name value"); - - // Ensures that the page returns a 404 error if the requested parameter is - // not defined. - $this->drupalGet('/devel/container/parameter/not_exists'); - $this->assertSession()->statusCodeEquals(404); - - // Ensures that the page is accessible ony to users with the adequate - // permissions. - $this->drupalLogout(); - $this->drupalGet("devel/container/service/$parameter_name"); - $this->assertSession()->statusCodeEquals(403); - } - - /** - * Asserts that container info local tasks are present. - */ - protected function assertContainerInfoLocalTasks() { - $expected_local_tasks = [ - ['devel.container_info.service', []], - ['devel.container_info.parameter', []], - ]; - - $this->assertLocalTasks($expected_local_tasks); - } - -} diff --git a/modules/devel/tests/src/Functional/DevelControllerTest.php b/modules/devel/tests/src/Functional/DevelControllerTest.php deleted file mode 100644 index 0fc375a..0000000 --- a/modules/devel/tests/src/Functional/DevelControllerTest.php +++ /dev/null @@ -1,122 +0,0 @@ -randomMachineName(); - $data = ['type' => 'entity_test', 'name' => $random_label]; - $this->entity = entity_create('entity_test', $data); - $this->entity->save(); - - // Create a test entity with only canonical route. - $random_label = $this->randomMachineName(); - $data = ['type' => 'devel_entity_test_canonical', 'name' => $random_label]; - $this->entity_canonical = entity_create('devel_entity_test_canonical', $data); - $this->entity_canonical->save(); - - // Create a test entity with only edit route. - $random_label = $this->randomMachineName(); - $data = ['type' => 'devel_entity_test_edit', 'name' => $random_label]; - $this->entity_edit = entity_create('devel_entity_test_edit', $data); - $this->entity_edit->save(); - - // Create a test entity with no routes. - $random_label = $this->randomMachineName(); - $data = ['type' => 'devel_entity_test_no_links', 'name' => $random_label]; - $this->entity_no_links = entity_create('devel_entity_test_no_links', $data); - $this->entity_no_links->save(); - - $this->drupalPlaceBlock('local_tasks_block'); - - $web_user = $this->drupalCreateUser([ - 'view test entity', - 'administer entity_test content', - 'access devel information', - ]); - $this->drupalLogin($web_user); - } - - function testRouteGeneration() { - // Test Devel load and render routes for entities with both route - // definitions. - $this->drupalGet('entity_test/' . $this->entity->id()); - $this->assertText('Devel', 'Devel tab is present'); - $this->drupalGet('devel/entity_test/' . $this->entity->id()); - $this->assertResponse(200); - $this->assertText('Definition', 'Devel definition tab is present'); - $this->assertText('Load', 'Devel load tab is present'); - $this->assertText('Render', 'Devel load tab is present'); - $this->assertLinkByHref('devel/entity_test/' . $this->entity->id() . '/render'); - $this->drupalGet('devel/entity_test/' . $this->entity->id() . '/render'); - $this->assertResponse(200); - $this->assertLinkByHref('devel/entity_test/' . $this->entity->id() . '/definition'); - $this->drupalGet('devel/entity_test/' . $this->entity->id() . '/definition'); - $this->assertResponse(200); - - // Test Devel load and render routes for entities with only canonical route - // definitions. - $this->drupalGet('devel_entity_test_canonical/' . $this->entity_canonical->id()); - $this->assertText('Devel', 'Devel tab is present'); - //TODO this fail since assertNoLinkByHref search by partial value. - //$this->assertNoLinkByHref('devel/devel_entity_test_canonical/' . $this->entity_canonical->id()); - $this->assertLinkByHref('devel/devel_entity_test_canonical/' . $this->entity_canonical->id() . '/render'); - $this->drupalGet('devel/devel_entity_test_canonical/' . $this->entity_canonical->id()); - $this->assertResponse(404); - $this->drupalGet('devel/devel_entity_test_canonical/' . $this->entity_canonical->id() . '/render'); - $this->assertResponse(200); - $this->assertLinkByHref('devel/devel_entity_test_canonical/' . $this->entity_canonical->id() . '/definition'); - $this->drupalGet('devel/devel_entity_test_canonical/' . $this->entity_canonical->id() . '/definition'); - $this->assertResponse(200); - - // Test Devel load and render routes for entities with only edit route - // definitions. - $this->drupalGet('devel_entity_test_edit/manage/' . $this->entity_edit->id()); - $this->assertText('Devel', 'Devel tab is present'); - $this->assertLinkByHref('devel/devel_entity_test_edit/' . $this->entity_edit->id()); - $this->assertNoLinkByHref('devel/devel_entity_test_edit/' . $this->entity_edit->id() . '/render'); - $this->assertNoLinkByHref('devel/devel_entity_test_edit/' . $this->entity_edit->id() . '/definition'); - $this->drupalGet('devel/devel_entity_test_edit/' . $this->entity_edit->id()); - $this->assertResponse(200); - $this->drupalGet('devel/devel_entity_test_edit/' . $this->entity_edit->id() . '/render'); - $this->assertResponse(404); - $this->drupalGet('devel/devel_entity_test_edit/' . $this->entity_edit->id() . '/definition'); - $this->assertResponse(200); - - // Test Devel load and render routes for entities with no route - // definitions. - $this->drupalGet('devel_entity_test_no_links/' . $this->entity_edit->id()); - $this->assertNoText('Devel', 'Devel tab is not present'); - $this->assertNoLinkByHref('devel/devel_entity_test_no_links/' . $this->entity_no_links->id()); - $this->assertNoLinkByHref('devel/devel_entity_test_no_links/' . $this->entity_no_links->id() . '/render'); - $this->assertNoLinkByHref('devel/devel_entity_test_no_links/' . $this->entity_no_links->id() . '/definition'); - $this->drupalGet('devel/devel_entity_test_no_links/' . $this->entity_no_links->id()); - $this->assertResponse(404); - $this->drupalGet('devel/devel_entity_test_no_links/' . $this->entity_no_links->id() . '/render'); - $this->assertResponse(404); - $this->drupalGet('devel/devel_entity_test_no_links/' . $this->entity_no_links->id() . '/definition'); - $this->assertResponse(404); - } - -} diff --git a/modules/devel/tests/src/Functional/DevelDumperTest.php b/modules/devel/tests/src/Functional/DevelDumperTest.php deleted file mode 100644 index a4ef9b4..0000000 --- a/modules/devel/tests/src/Functional/DevelDumperTest.php +++ /dev/null @@ -1,165 +0,0 @@ -drupalCreateUser(['administer site configuration', 'access devel information']); - $this->drupalLogin($admin_user); - } - - /** - * Test dumpers configuration page. - */ - public function testDumpersConfiguration() { - $this->drupalGet('admin/config/development/devel'); - - // Ensures that the dumper input is present on the config page. - $this->assertSession()->fieldExists('dumper'); - - // Ensures that the 'default' dumper is enabled by default. - $this->assertSession()->checkboxChecked('edit-dumper-default'); - - // Ensures that all dumpers declared by devel are present on the config page - // and that only the available dumpers are selectable. - $dumpers = [ - 'default', - 'drupal_variable', - 'firephp', - 'chromephp', - 'var_dumper', - ]; - $available_dumpers = ['default', 'drupal_variable']; - - foreach ($dumpers as $dumper) { - $this->assertFieldByXPath('//input[@type="radio" and @name="dumper"]', $dumper); - if (in_array($dumper, $available_dumpers)) { - $this->assertFieldByXPath('//input[@name="dumper" and not(@disabled="disabled")]', $dumper); - } - else { - $this->assertFieldByXPath('//input[@name="dumper" and @disabled="disabled"]', $dumper); - } - } - - // Ensures that dumper plugins declared by other modules are present on the - // config page and that only the available dumpers are selectable. - $this->assertFieldByXPath('//input[@name="dumper"]', 'available_test_dumper'); - $this->assertSession()->pageTextContains('Available test dumper.'); - $this->assertSession()->pageTextContains('Drupal dumper for testing purposes (available).'); - $this->assertFieldByXPath('//input[@name="dumper" and not(@disabled="disabled")]', 'available_test_dumper', 'Available dumper input not is disabled.'); - - $this->assertFieldByXPath('//input[@name="dumper"]', 'not_available_test_dumper'); - $this->assertSession()->pageTextContains('Not available test dumper.'); - $this->assertSession()->pageTextContains('Drupal dumper for testing purposes (not available).Not available. You may need to install external dependencies for use this plugin.'); - $this->assertFieldByXPath('//input[@name="dumper" and @disabled="disabled"]', 'not_available_test_dumper', 'Non available dumper input is disabled.'); - - // Ensures that saving of the dumpers configuration works as expected. - $edit = [ - 'dumper' => 'drupal_variable', - ]; - $this->drupalPostForm('admin/config/development/devel', $edit, t('Save configuration')); - $this->assertSession()->pageTextContains(t('The configuration options have been saved.')); - - $config = \Drupal::config('devel.settings')->get('devel_dumper'); - $this->assertEquals('drupal_variable', $config, 'The configuration options have been properly saved'); - - // Ensure that if the chosen dumper is not available (e.g. the module that - // provide it is uninstalled) the 'default' dumper appears selected in the - // config page. - \Drupal::service('module_installer')->install(['kint']); - - $this->drupalGet('admin/config/development/devel'); - $this->assertFieldByXPath('//input[@name="dumper"]', 'kint'); - - $edit = [ - 'dumper' => 'kint', - ]; - $this->drupalPostForm('admin/config/development/devel', $edit, t('Save configuration')); - $this->assertSession()->pageTextContains(t('The configuration options have been saved.')); - - $config = \Drupal::config('devel.settings')->get('devel_dumper'); - $this->assertEquals('kint', $config, 'The configuration options have been properly saved'); - - \Drupal::service('module_installer')->uninstall(['kint']); - - $this->drupalGet('admin/config/development/devel'); - $this->assertNoFieldByXPath('//input[@name="dumper"]', 'kint'); - $this->assertSession()->checkboxChecked('edit-dumper-default'); - } - - /** - * Test variable is dumped in page. - */ - function testDumpersOutput() { - $edit = [ - 'dumper' => 'available_test_dumper', - ]; - $this->drupalPostForm('admin/config/development/devel', $edit, t('Save configuration')); - $this->assertSession()->pageTextContains(t('The configuration options have been saved.')); - - $this->drupalGet('devel_dumper_test/dump'); - $elements = $this->xpath('//body/pre[contains(text(), :message)]', [':message' => 'AvailableTestDumper::dump() Test output']); - $this->assertTrue(!empty($elements), 'Dumped message is present.'); - - $this->drupalGet('devel_dumper_test/message'); - $elements = $this->xpath('//div[contains(@class, "messages")]/pre[contains(text(), :message)]', [':message' => 'AvailableTestDumper::export() Test output']); - $this->assertTrue(!empty($elements), 'Dumped message is present.'); - - $this->drupalGet('devel_dumper_test/export'); - $elements = $this->xpath('//div[@class="layout-content"]//pre[contains(text(), :message)]', [':message' => 'AvailableTestDumper::export() Test output']); - $this->assertTrue(!empty($elements), 'Dumped message is present.'); - - $this->drupalGet('devel_dumper_test/export_renderable'); - $elements = $this->xpath('//div[@class="layout-content"]//pre[contains(text(), :message)]', [':message' => 'AvailableTestDumper::exportAsRenderable() Test output']); - $this->assertTrue(!empty($elements), 'Dumped message is present.'); - // Ensures that plugins can add libraries to the page when the - // ::exportAsRenderable() method is used. - $this->assertSession()->responseContains('devel_dumper_test/css/devel_dumper_test.css'); - $this->assertSession()->responseContains('devel_dumper_test/js/devel_dumper_test.js'); - - $debug_filename = file_directory_temp() . '/drupal_debug.txt'; - - $this->drupalGet('devel_dumper_test/debug'); - $file_content = file_get_contents($debug_filename); - $expected = <<