From 6153b0d88077a826c927b10c7dc313d1a30c8db7 Mon Sep 17 00:00:00 2001 From: Saphyel Date: Mon, 31 Oct 2016 11:34:18 +0000 Subject: [PATCH 1/2] PLAT-558 Update layout plugin --- profiles/cr/drupal-org.make.yml | 2 +- .../layout_plugin/layout_plugin.api.php | 26 ++ .../layout_plugin/layout_plugin.drush.inc | 1 - .../layout_plugin/layout_plugin.info.yml | 8 +- .../layout_plugin/layout_plugin.module | 19 ++ .../block_page_layout.info.yml | 14 - .../schema/block_page_layout.schema.yml | 13 - .../DisplayVariant/BlockPageLayoutVariant.php | 248 ------------------ .../src/Tests/BlockPageLayoutTest.php | 96 ------- .../layout_plugin_example.info.yml | 9 +- .../src/Plugin/Layout/LayoutExampleTest.php | 5 - .../layout_plugin/src/Annotation/Layout.php | 18 +- .../contrib/layout_plugin/src/Layout.php | 6 - .../src/Plugin/Layout/LayoutBase.php | 88 ++++--- .../src/Plugin/Layout/LayoutDefault.php | 6 - .../src/Plugin/Layout/LayoutInterface.php | 9 +- .../src/Plugin/Layout/LayoutPluginManager.php | 64 +++-- .../Layout/LayoutPluginManagerInterface.php | 10 +- .../config/schema/layout_test.schema.yml | 7 + .../layout_test/css/layout-test-1col.css | 1 + .../layout_test/css/layout-test-2col.css | 16 ++ .../modules/layout_test/layout_test.info.yml | 12 + .../layout_test/layout_test.layouts.yml | 21 ++ .../layout_test/layout_test.libraries.yml | 11 + .../src/Plugin/Layout/LayoutTestPlugin.php | 59 +++++ .../templates/layout-test-1col.html.twig | 14 + .../templates/layout-test-2col.html.twig | 14 + .../templates/layout-test-plugin.html.twig | 15 ++ .../tests/src/Kernel/LayoutTest.php | 141 ++++++++++ .../tests/src/Unit/PluginManagerTest.php | 35 ++- 30 files changed, 504 insertions(+), 484 deletions(-) create mode 100644 profiles/cr/modules/contrib/layout_plugin/layout_plugin.api.php delete mode 100644 profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/block_page_layout.info.yml delete mode 100644 profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/config/schema/block_page_layout.schema.yml delete mode 100644 profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Plugin/DisplayVariant/BlockPageLayoutVariant.php delete mode 100644 profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Tests/BlockPageLayoutTest.php create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/config/schema/layout_test.schema.yml create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/css/layout-test-1col.css create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/css/layout-test-2col.css create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/layout_test.info.yml create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/layout_test.layouts.yml create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/layout_test.libraries.yml create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/src/Plugin/Layout/LayoutTestPlugin.php create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-1col.html.twig create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-2col.html.twig create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-plugin.html.twig create mode 100644 profiles/cr/modules/contrib/layout_plugin/tests/src/Kernel/LayoutTest.php diff --git a/profiles/cr/drupal-org.make.yml b/profiles/cr/drupal-org.make.yml index 3392605660..4011d704a9 100644 --- a/profiles/cr/drupal-org.make.yml +++ b/profiles/cr/drupal-org.make.yml @@ -64,7 +64,7 @@ projects: inline_entity_form: version: 1.0-alpha6 layout_plugin: - version: 1.0-alpha22 + version: 1.0-alpha23 page_manager: version: 1.0-alpha23 panels: diff --git a/profiles/cr/modules/contrib/layout_plugin/layout_plugin.api.php b/profiles/cr/modules/contrib/layout_plugin/layout_plugin.api.php new file mode 100644 index 0000000000..651b3be6c7 --- /dev/null +++ b/profiles/cr/modules/contrib/layout_plugin/layout_plugin.api.php @@ -0,0 +1,26 @@ +' . t('About') . ''; + $output .= '

' . t('Layout Plugin allows modules or themes to register layouts, and for other modules to list the available layouts and render them. For more information, see the online documentation for the Layout Plugin module.', [':layout-plugin-documentation' => 'https://www.drupal.org/node/2619128']) . '

'; + $output .= '

' . t('Uses') . '

'; + $output .= '

' . t('This is an API module which serves as the plugin manager for layouts. API modules provide a common set of routines, protocols, and tools developers use for building specific features into modules for your site. See the Layout Plugin project page for a complete listing of Modules that use Layout Plugin.', [':layout_plugin' => 'https://www.drupal.org/project/layout_plugin']) . '

'; + $output .= '

' . t('Registering a Layout Plugin - There are several ways to register your layout. For more information of the simplest, most common case and then building up to some of the more advanced techniques, see How to register layouts with Layout Plugin.', [':layout_plugin' => 'https://www.drupal.org/node/2578731']) . '

'; + $output .= '

' . t('Rendering a Layout Plugin - To render a layout plugin you first get the layout plugin manager, then list available layouts and instantiate the layout plugin. Rendering is then possible and a configuration display for showing and storing layouts is made available. For more information on rendering layouts, see How to render layouts using Layout Plugin.', [':layout_plugin' => 'https://www.drupal.org/node/2619168']) . '

'; + return $output; + } +} + /** * Implements hook_theme(). */ diff --git a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/block_page_layout.info.yml b/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/block_page_layout.info.yml deleted file mode 100644 index 5cf3469989..0000000000 --- a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/block_page_layout.info.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Block Page (with Layout plugin) -type: module -description: 'Block Page (with Layout plugin integration)' -# core: 8.x -package: Examples -dependencies: - - page_manager - - layout_plugin - -# Information added by Drupal.org packaging script on 2016-01-11 -version: '8.x-1.0-alpha22' -core: '8.x' -project: 'layout_plugin' -datestamp: 1452531565 diff --git a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/config/schema/block_page_layout.schema.yml b/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/config/schema/block_page_layout.schema.yml deleted file mode 100644 index 3256817397..0000000000 --- a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/config/schema/block_page_layout.schema.yml +++ /dev/null @@ -1,13 +0,0 @@ -display_variant.plugin.block_page_layout: - type: ctools.block_display_variant - label: 'Block page layout display variant' - mapping: - page_title: - type: string - label: Page Title - layout: - type: string - label: Layout - layout_settings: - type: layout_plugin.settings.[%parent.layout] - label: Layout settings diff --git a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Plugin/DisplayVariant/BlockPageLayoutVariant.php b/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Plugin/DisplayVariant/BlockPageLayoutVariant.php deleted file mode 100644 index e0a4fd3e55..0000000000 --- a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Plugin/DisplayVariant/BlockPageLayoutVariant.php +++ /dev/null @@ -1,248 +0,0 @@ -layoutManager = $layout_manager; - - parent::__construct($configuration, $plugin_id, $plugin_definition, $context_handler, $account, $uuid_generator, $token, $block_manager, $condition_manager); - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('context.handler'), - $container->get('current_user'), - $container->get('uuid'), - $container->get('token'), - $container->get('plugin.manager.block'), - $container->get('plugin.manager.condition'), - $container->get('plugin.manager.layout_plugin') - ); - } - - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { - return parent::defaultConfiguration() + [ - 'layout' => '', - 'layout_settings' => [], - ]; - } - - /** - * Returns instance of the layout plugin used by this page variant. - * - * @return \Drupal\layout_plugin\Plugin\Layout\LayoutInterface - * A layout plugin instance. - */ - public function getLayout() { - if (!isset($this->layout)) { - $this->layout = $this->layoutManager->createInstance($this->configuration['layout'], $this->configuration['layout_settings']); - } - return $this->layout; - } - - /** - * {@inheritdoc} - */ - public function getRegionNames() { - return $this->getLayout()->getPluginDefinition()['region_names']; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form = parent::buildConfigurationForm($form, $form_state); - - // Only allow selecting the layout when creating a new variant. - if (empty($this->configuration['layout'])) { - $form['layout'] = [ - '#title' => $this->t('Layout'), - '#type' => 'select', - '#options' => $this->layoutManager->getLayoutOptions(array('group_by_category' => TRUE)), - ]; - } - else { - $form['layout'] = [ - '#type' => 'value', - '#value' => $this->configuration['layout'], - ]; - - // If a layout is already selected, show the layout settings. - $form['layout_settings_wrapper'] = [ - '#type' => 'fieldset', - '#title' => $this->t('Layout settings'), - ]; - $form['layout_settings_wrapper']['layout_settings'] = []; - - // Get settings form from layout plugin. - $layout = $this->layoutManager->createInstance($this->configuration['layout'], $this->configuration['layout_settings'] ?: []); - $form['layout_settings_wrapper']['layout_settings'] = $layout->buildConfigurationForm($form['layout_settings_wrapper']['layout_settings'], $form_state); - - // Process callback to configure #parents correctly on settings, since - // we don't know where in the form hierarchy our settings appear. - $form['#process'][] = [$this, 'layoutSettingsProcessCallback']; - } - - return $form; - } - - /** - * Form API #process callback: expands form with hierarchy information. - */ - public function layoutSettingsProcessCallback(array &$element, FormStateInterface $form_state, array &$complete_form) { - $settings_element =& $element['layout_settings_wrapper']['layout_settings']; - - // Set the #parents on the layout_settings so they end up as a sibling of - // layout. - $layout_settings_parents = array_merge($element['#parents'], ['layout_settings']); - $settings_element['#parents'] = $layout_settings_parents; - $settings_element['#tree'] = TRUE; - - // Store the array parents for our element so that we can use it to pull out - // the layout settings in the validate and submit functions. - $complete_form['#variant_array_parents'] = $element['#array_parents']; - - return $element; - } - - /** - * Extracts the layout settings form and form state from the full form. - * - * @param array $form - * Full form array. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Full form state. - * - * @return array - * An array with two values: the new form array and form state object. - */ - protected function getLayoutSettingsForm(array &$form, FormStateInterface $form_state) { - $layout_settings_form = NestedArray::getValue($form, array_merge($form['#variant_array_parents'], ['layout_settings_wrapper', 'layout_settings'])); - $layout_settings_form_state = (new FormState())->setValues($form_state->getValue('layout_settings')); - return [$layout_settings_form, $layout_settings_form_state]; - } - - /** - * {@inheritdoc} - */ - public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { - parent::validateConfigurationForm($form, $form_state); - - // Validate layout settings. - if ($form_state->hasValue('layout_settings')) { - $layout = $this->layoutManager->createInstance($form_state->getValue('layout'), $this->configuration['layout_settings']); - list ($layout_settings_form, $layout_settings_form_state) = $this->getLayoutSettingsForm($form, $form_state); - $layout->validateConfigurationForm($layout_settings_form, $layout_settings_form_state); - - // Save the layout plugin for later (so we don't have to instantiate again - // on submit. - $form_state->set('layout_plugin', $layout); - } - } - - /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { - parent::submitConfigurationForm($form, $form_state); - - $this->configuration['layout'] = $form_state->getValue('layout'); - - // Submit layout settings. - if ($form_state->hasValue('layout_settings')) { - $layout = $form_state->has('layout_plugin') ? $form_state->get('layout_plugin') : $this->getLayout(); - list ($layout_settings_form, $layout_settings_form_state) = $this->getLayoutSettingsForm($form, $form_state); - $layout->submitConfigurationForm($layout_settings_form, $layout_settings_form_state); - $this->configuration['layout_settings'] = $layout->getConfiguration(); - } - } - - /** - * {@inheritdoc} - */ - public function buildRegions(array $build) { - $regions = parent::buildRegions($build); - $layout = $this->getLayout(); - return $layout->build($regions); - } - -} diff --git a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Tests/BlockPageLayoutTest.php b/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Tests/BlockPageLayoutTest.php deleted file mode 100644 index 1eca90de6b..0000000000 --- a/profiles/cr/modules/contrib/layout_plugin/modules/block_page_layout/src/Tests/BlockPageLayoutTest.php +++ /dev/null @@ -1,96 +0,0 @@ -drupalPlaceBlock('local_tasks_block'); - $this->drupalPlaceBlock('local_actions_block'); - $this->drupalPlaceBlock('system_branding_block'); - $this->drupalPlaceBlock('page_title_block'); - - \Drupal::service('theme_handler')->install(['bartik', 'classy']); - $this->config('system.theme')->set('admin', 'classy')->save(); - - $this->drupalLogin($this->drupalCreateUser(['administer pages', 'access administration pages', 'view the administration theme'])); - } - - /** - * Tests adding a layout with settings. - */ - public function testLayoutSettings() { - // Create new page. - $this->drupalGet('admin/structure/page_manager/add'); - $edit = [ - 'id' => 'foo', - 'label' => 'foo', - 'path' => 'testing', - ]; - $this->drupalPostForm(NULL, $edit, 'Save'); - - // Add variant with a layout that has settings. - $this->clickLink('Add new variant'); - $this->clickLink('Block page (with Layout plugin integration)'); - $edit = [ - 'id' => 'block_page_layout_1', - 'label' => 'Default', - 'variant_settings[layout]' => 'layout_example_test', - ]; - $this->drupalPostForm(NULL, $edit, 'Save'); - - // Add a block. - $this->clickLink('Add new block'); - $this->clickLink('Powered by Drupal'); - $edit = [ - 'region' => 'top', - ]; - $this->drupalPostForm(NULL, $edit, 'Add block'); - - // Check the default value and change a layout setting. - $this->assertText('Blah'); - $this->assertFieldByName("variant_settings[layout_settings][setting_1]", "Default"); - $edit = [ - 'variant_settings[layout_settings][setting_1]' => 'Abracadabra', - ]; - $this->drupalPostForm(NULL, $edit, 'Save'); - - // Go back to the variant edit form and see that the setting stuck. - $this->drupalGet('admin/structure/page_manager/manage/foo/variant/block_page_layout_1'); - $this->assertFieldByName("variant_settings[layout_settings][setting_1]", "Abracadabra"); - - // View the page and make sure the setting is present. - $this->drupalGet('testing'); - $this->assertText('Blah:'); - $this->assertText('Abracadabra'); - $this->assertText('Powered by Drupal'); - } - -} diff --git a/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/layout_plugin_example.info.yml b/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/layout_plugin_example.info.yml index b9092d04ee..5a0eed311a 100644 --- a/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/layout_plugin_example.info.yml +++ b/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/layout_plugin_example.info.yml @@ -1,13 +1,14 @@ name: Example Layouts type: module -description: 'Example layout plugins.' +description: 'Registers a few example layouts to use for testing or demonstration.' # core: 8.x package: Examples +hidden: true dependencies: - layout_plugin -# Information added by Drupal.org packaging script on 2016-01-11 -version: '8.x-1.0-alpha22' +# Information added by Drupal.org packaging script on 2016-10-12 +version: '8.x-1.0-alpha23' core: '8.x' project: 'layout_plugin' -datestamp: 1452531565 +datestamp: 1476238141 diff --git a/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/src/Plugin/Layout/LayoutExampleTest.php b/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/src/Plugin/Layout/LayoutExampleTest.php index 5c33662128..6753be4c3e 100644 --- a/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/src/Plugin/Layout/LayoutExampleTest.php +++ b/profiles/cr/modules/contrib/layout_plugin/modules/layout_plugin_example/src/Plugin/Layout/LayoutExampleTest.php @@ -1,10 +1,5 @@ pluginDefinition['label']; + } + + /** + * Gets the optional description for advanced layouts. * - * @return string - * The layout description + * @return \Drupal\Core\Annotation\Translation|NULL + * The layout description. */ public function getDescription() { - return $this->pluginDefinition['description']; + return isset($this->pluginDefinition['description']) ? $this->pluginDefinition['description'] : NULL; } /** - * Get human-readable list of regions keyed by machine name. + * Gets the human-readable category. * - * @return array + * @return \Drupal\Core\Annotation\Translation + * The human-readable category. + */ + public function getCategory() { + return $this->pluginDefinition['category']; + } + + /** + * Gets human-readable list of regions keyed by machine name. + * + * @return \Drupal\Core\Annotation\Translation[] * An array of human-readable region names keyed by machine name. */ public function getRegionNames() { @@ -43,7 +60,7 @@ public function getRegionNames() { } /** - * Get information on regions keyed by machine name. + * Gets information on regions keyed by machine name. * * @return array * An array of information on regions keyed by machine name. @@ -53,56 +70,56 @@ public function getRegionDefinitions() { } /** - * Get the base path for all resources. + * Gets the path to resources like icon or template. * - * @return string - * The full base to all resources. + * @return string|NULL + * The path relative to the Drupal root. */ public function getBasePath() { - return isset($this->pluginDefinition['path']) && $this->pluginDefinition['path'] ? $this->pluginDefinition['path'] : FALSE; + return isset($this->pluginDefinition['path']) ? $this->pluginDefinition['path'] : NULL; } /** - * Get the full path to the icon image. + * Gets the path to the preview image. * * This can optionally be used in the user interface to show the layout of * regions visually. * - * @return string - * The full path to preview image file. + * @return string|NULL + * The path to preview image file. */ public function getIconFilename() { - return isset($this->pluginDefinition['icon']) && $this->pluginDefinition['icon'] ? $this->pluginDefinition['icon'] : FALSE; + return isset($this->pluginDefinition['icon']) ? $this->pluginDefinition['icon'] : NULL; } /** - * Get the asset library name. + * Get the asset library. * - * @return string + * @return string|NULL * The asset library. */ public function getLibrary() { - return isset($this->pluginDefinition['library']) && $this->pluginDefinition['library'] ? $this->pluginDefinition['library'] : FALSE; + return isset($this->pluginDefinition['library']) ? $this->pluginDefinition['library'] : NULL; } /** - * Get the theme function for rendering this layout. + * Gets the theme hook used to render this layout. * - * @return string - * Theme function name. + * @return string|NULL + * Theme hook. */ - public function getTheme() { - return isset($this->pluginDefinition['theme']) && $this->pluginDefinition['theme'] ? $this->pluginDefinition['theme'] : FALSE; + public function getThemeHook() { + return isset($this->pluginDefinition['theme']) ? $this->pluginDefinition['theme'] : NULL; } /** * {@inheritdoc} */ public function build(array $regions) { - $build = $regions; + $build = array_intersect_key($regions, $this->getRegionDefinitions()); $build['#layout'] = $this->getPluginDefinition(); $build['#settings'] = $this->getConfiguration(); - if ($theme = $this->getTheme()) { + if ($theme = $this->getThemeHook()) { $build['#theme'] = $theme; } if ($library = $this->getLibrary()) { @@ -153,9 +170,10 @@ public function defaultConfiguration() { } /** - * @{inheritdoc} + * {@inheritdoc} */ public function calculateDependencies() { - return []; + return isset($this->configuration['dependencies']) ? $this->configuration['dependencies'] : []; } + } diff --git a/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutDefault.php b/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutDefault.php index b7960d4802..462b68d5b6 100644 --- a/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutDefault.php +++ b/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutDefault.php @@ -1,13 +1,7 @@ moduleHandler->moduleExists($library_provider)) { + $definition['dependencies'] = ['module' => [$library_provider]]; + } + elseif ($this->themeHandler->themeExists($library_provider)) { + $definition['dependencies'] = ['theme' => [$library_provider]]; + } + } + // Add the path to the icon filename. if (!empty($definition['icon'])) { $definition['icon'] = $definition['path'] . '/' . $definition['icon']; @@ -122,24 +130,25 @@ public function processDefinition(&$definition, $plugin_id) { */ public function getLayoutOptions(array $params = []) { $group_by_category = !empty($params['group_by_category']); - $plugins = $this->getDefinitions(); + $plugins = $group_by_category ? $this->getGroupedDefinitions() : ['default' => $this->getDefinitions()]; + $categories = $group_by_category ? $this->getCategories() : ['default']; - // Sort the plugins first by category, then by label. + // Go through each category, sort it, and get just the labels out. $options = array(); - foreach ($plugins as $id => $plugin) { - if ($group_by_category) { - $category = isset($plugin['category']) ? (string) $plugin['category'] : 'default'; - if (!isset($options[$category])) { - $options[$category] = array(); - } + foreach ($categories as $category) { + // Convert from a translation to a real string. + $category = (string) $category; + + // Sort the category. + $plugins[$category] = $this->getSortedDefinitions($plugins[$category]); + + // Put only the label in the options array. + foreach ($plugins[$category] as $id => $plugin) { $options[$category][$id] = $plugin['label']; } - else { - $options[$id] = $plugin['label']; - } } - return $options; + return $group_by_category ? $options : $options['default']; } /** @@ -198,6 +207,24 @@ public function alterThemeImplementations(array &$theme_registry) { } } + /** + * Gets the version of the given provider. + * + * Wraps system_get_info() so that we can mock it in our tests. + * + * @param string $provider_type + * The provider type (ex. module or theme). + * @param string $provider + * The name of the provider. + * + * @return string + * The version string for the provider or 'VERSION' if it can't be found. + */ + protected function getProviderVersion($provider_type, $provider) { + $info = system_get_info($provider_type, $provider); + return !empty($info['version']) ? $info['version'] : 'VERSION'; + } + /** * {@inheritdoc} */ @@ -215,8 +242,7 @@ public function getLibraryInfo() { } $library_info[$library_name] = [ - // @todo: Should be the version of the provider module or theme. - 'version' => 'VERSION', + 'version' => $this->getProviderVersion($definition['provider_type'], $definition['provider']), 'css' => [ 'theme' => [ '/' . $definition['css'] => [], diff --git a/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutPluginManagerInterface.php b/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutPluginManagerInterface.php index 546800c8d9..46f8208376 100644 --- a/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutPluginManagerInterface.php +++ b/profiles/cr/modules/contrib/layout_plugin/src/Plugin/Layout/LayoutPluginManagerInterface.php @@ -1,17 +1,13 @@ 'Default', + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $configuration = $this->getConfiguration(); + $form['setting_1'] = [ + '#type' => 'textfield', + '#title' => 'Blah', + '#default_value' => $configuration['setting_1'], + ]; + return $form; + } + + /** + * @inheritDoc + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + parent::submitConfigurationForm($form, $form_state); + + $this->configuration['setting_1'] = $form_state->getValue('setting_1'); + } + +} diff --git a/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-1col.html.twig b/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-1col.html.twig new file mode 100644 index 0000000000..e7a7eb5baa --- /dev/null +++ b/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-1col.html.twig @@ -0,0 +1,14 @@ +{# +/** + * @file + * Template for an example 1 column layout. + */ +#} +
+
+ {{ content.top }} +
+
+ {{ content.bottom }} +
+
diff --git a/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-2col.html.twig b/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-2col.html.twig new file mode 100644 index 0000000000..11433ee99c --- /dev/null +++ b/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-2col.html.twig @@ -0,0 +1,14 @@ +{# +/** + * @file + * Template for an example 2 column layout. + */ +#} +
+
+ {{ content.left }} +
+
+ {{ content.right }} +
+
diff --git a/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-plugin.html.twig b/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-plugin.html.twig new file mode 100644 index 0000000000..e49942c4cb --- /dev/null +++ b/profiles/cr/modules/contrib/layout_plugin/tests/modules/layout_test/templates/layout-test-plugin.html.twig @@ -0,0 +1,15 @@ +{# +/** + * @file + * Template for layout_test_plugin layout. + */ +#} +
+
+ Blah: + {{ settings.setting_1 }} +
+
+ {{ content.main }} +
+
diff --git a/profiles/cr/modules/contrib/layout_plugin/tests/src/Kernel/LayoutTest.php b/profiles/cr/modules/contrib/layout_plugin/tests/src/Kernel/LayoutTest.php new file mode 100644 index 0000000000..eab53ff2ed --- /dev/null +++ b/profiles/cr/modules/contrib/layout_plugin/tests/src/Kernel/LayoutTest.php @@ -0,0 +1,141 @@ +layoutManager = $this->container->get('plugin.manager.layout_plugin'); + } + + /** + * Test listing the available layouts. + */ + public function testLayoutDefinitions() { + $expected_layouts = [ + 'layout_test_1col', + 'layout_test_2col', + 'layout_test_plugin', + ]; + $this->assertEquals($expected_layouts, array_keys($this->layoutManager->getDefinitions())); + } + + /** + * Test rendering a layout. + * + * @dataProvider renderLayoutData + */ + public function testRenderLayout($layout_id, $config, $regions, $html) { + /** @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout */ + $layout = $this->layoutManager->createInstance($layout_id, $config); + $built = $layout->build($regions); + $this->render($built); + $this->assertRaw($html); + } + + /** + * Data provider for testRenderLayout(). + */ + public function renderLayoutData() { + $data = [ + 'layout_test_1col' => [ + 'layout_test_1col', + [], + [ + 'top' => [ + '#markup' => 'This is the top', + ], + 'bottom' => [ + '#markup' => 'This is the bottom', + ], + ], + ], + + 'layout_test_2col' => [ + 'layout_test_2col', + [], + [ + 'left' => [ + '#markup' => 'This is the left', + ], + 'right' => [ + '#markup' => 'This is the right', + ], + ], + ], + + 'layout_test_plugin' => [ + 'layout_test_plugin', + [ + 'setting_1' => 'Config value' + ], + [ + 'main' => [ + '#markup' => 'Main region', + ], + ] + ], + ]; + + $data['layout_test_1col'][] = <<<'EOD' +
+
+ This is the top +
+
+ This is the bottom +
+
+EOD; + + $data['layout_test_2col'][] = <<<'EOD' +
+
+ This is the left +
+
+ This is the right +
+
+EOD; + + $data['layout_test_plugin'][] = <<<'EOD' +
+
+ Blah: + Config value +
+
+ Main region +
+
+EOD; + + return $data; + } + +} diff --git a/profiles/cr/modules/contrib/layout_plugin/tests/src/Unit/PluginManagerTest.php b/profiles/cr/modules/contrib/layout_plugin/tests/src/Unit/PluginManagerTest.php index cd9aef7e4f..fee5433df5 100644 --- a/profiles/cr/modules/contrib/layout_plugin/tests/src/Unit/PluginManagerTest.php +++ b/profiles/cr/modules/contrib/layout_plugin/tests/src/Unit/PluginManagerTest.php @@ -1,10 +1,5 @@ 'Complex layout', 'category' => 'Test layouts', 'template' => 'complex-layout', + 'library' => 'library_module/library_name', 'provider' => 'layout_plugin_test', 'path' => 'layout/complex', 'icon' => 'complex-layout.png', @@ -80,6 +76,7 @@ public function testProcessDefinition() { $this->assertEquals('modules/layout_plugin_test/layout/complex', $definition['template_path']); $this->assertEquals('modules/layout_plugin_test/layout/complex/complex-layout.png', $definition['icon']); $this->assertEquals('complex_layout', $definition['theme']); + $this->assertEquals(['module' => ['library_module']], $definition['dependencies']); // A layout with a template path. $definition = [ @@ -315,10 +312,10 @@ public function testAlterThemeImplementations() { * @covers ::getLibraryInfo */ public function testGetLibraryInfo() { - /** @var LayoutPluginManager|\PHPUnit_Framework_MockObject_MockBuilder $layout_manager */ + /** @var \Drupal\layout_plugin\Plugin\Layout\LayoutPluginManager|\PHPUnit_Framework_MockObject_MockObject $layout_manager */ $layout_manager = $this->getMockBuilder('Drupal\layout_plugin\Plugin\Layout\LayoutPluginManager') ->disableOriginalConstructor() - ->setMethods(['getDefinitions']) + ->setMethods(['getDefinitions', 'getProviderVersion']) ->getMock(); $layout_manager->method('getDefinitions') @@ -327,22 +324,44 @@ public function testGetLibraryInfo() { 'simple_layout' => [ 'css' => 'modules/layout_plugin_test/layouts/simple_layout/simple-layout.css', 'library' => 'layout_plugin/simple_layout', + 'provider_type' => 'module', + 'provider' => 'layout_plugin_test', + ], + 'theme_layout' => [ + 'css' => 'themes/theme_with_layout/layouts/theme_layout/theme-layout.css', + 'library' => 'layout_plugin/theme_layout', + 'provider_type' => 'theme', + 'provider' => 'theme_with_layout', ], 'complex_layout' => [ 'library' => 'layout_plugin_test/complex_layout', ], ]); + $layout_manager->method('getProviderVersion') + ->willReturnMap([ + ['module', 'layout_plugin_test', '1.2.3'], + ['theme', 'theme_with_layout', '2.3.4'], + ]); + $library_info = $layout_manager->getLibraryInfo(); $this->assertEquals([ 'simple_layout' => [ - 'version' => 'VERSION', + 'version' => '1.2.3', 'css' => [ 'theme' => [ '/modules/layout_plugin_test/layouts/simple_layout/simple-layout.css' => [], ], ], ], + 'theme_layout' => [ + 'version' => '2.3.4', + 'css' => [ + 'theme' => [ + '/themes/theme_with_layout/layouts/theme_layout/theme-layout.css' => [], + ], + ], + ], ], $library_info); } From 9e237ac9115535471d231de7ba1525ffe6e25b1d Mon Sep 17 00:00:00 2001 From: Saphyel Date: Mon, 31 Oct 2016 11:59:32 +0000 Subject: [PATCH 2/2] PLAT-561 Update ds --- profiles/cr/drupal-org.make.yml | 2 +- profiles/cr/modules/contrib/ds/composer.json | 3 - .../contrib/ds/config/install/ds.settings.yml | 1 + .../schema/ds.entity_display.schema.yml | 3 + .../contrib/ds/config/schema/ds.schema.yml | 3 + .../modules/contrib/ds/css/ds-2col-fluid.css | 4 +- .../contrib/ds/css/ds-2col-stacked-fluid.css | 7 +- .../contrib/ds/css/ds-2col-stacked.css | 7 +- .../cr/modules/contrib/ds/css/ds-2col.css | 4 +- .../contrib/ds/css/ds-3col-equal-width.css | 6 +- .../ds/css/ds-3col-stacked-equal-width.css | 6 +- .../contrib/ds/css/ds-3col-stacked-fluid.css | 6 +- .../contrib/ds/css/ds-3col-stacked.css | 6 +- .../cr/modules/contrib/ds/css/ds-3col.css | 6 +- .../cr/modules/contrib/ds/css/ds-4col.css | 8 +- .../cr/modules/contrib/ds/css/ds.admin.css | 17 +- .../modules/contrib/ds/drush/ExampleField.php | 6 +- .../cr/modules/contrib/ds/drush/ds.drush.inc | 10 +- .../drush/example_layout/example_layout.inc | 4 +- profiles/cr/modules/contrib/ds/ds.api.php | 62 ++-- profiles/cr/modules/contrib/ds/ds.info.yml | 6 +- profiles/cr/modules/contrib/ds/ds.install | 20 ++ .../cr/modules/contrib/ds/ds.links.task.yml | 5 + profiles/cr/modules/contrib/ds/ds.module | 156 ++++++---- .../modules/contrib/ds/includes/field_ui.inc | 266 +++++++++++------- .../ds/modules/ds_devel/ds_devel.info.yml | 6 +- .../ds/modules/ds_devel/ds_devel.module | 7 +- .../src/Controller/DsDevelController.php | 5 - .../Plugin/Derivative/DsDevelLocalTask.php | 7 +- .../ds_devel/src/Routing/RouteSubscriber.php | 7 +- .../core.entity_view_mode.node.revision.yml | 4 +- .../ds/modules/ds_extras/ds_extras.info.yml | 6 +- .../ds/modules/ds_extras/ds_extras.module | 23 +- .../src/Controller/DsExtrasController.php | 31 +- .../src/EventSubscriber/RouteSubscriber.php | 9 +- .../ds_extras/src/ExtrasPermissions.php | 15 +- .../src/Plugin/Block/DsRegionBlock.php | 5 - .../src/Plugin/Derivative/DsRegionBlock.php | 9 +- .../src/Plugin/DsField/SwitchField.php | 55 +++- .../ds_switch_view_mode.info.yml | 6 +- .../ds_switch_view_mode.module | 12 +- .../ds_switch_view_mode/src/Permissions.php | 9 +- .../contrib/ds/src/Annotation/DsField.php | 6 +- .../ds/src/Annotation/DsFieldTemplate.php | 5 - .../ds/src/Controller/DsController.php | 29 +- .../ds/src/Controller/FieldController.php | 13 +- profiles/cr/modules/contrib/ds/src/Ds.php | 40 ++- .../cr/modules/contrib/ds/src/DsAttribute.php | 11 +- .../ds/src/Form/BlockFieldConfigForm.php | 70 ++++- .../contrib/ds/src/Form/BlockFieldForm.php | 15 +- .../contrib/ds/src/Form/ChangeLayoutForm.php | 34 +-- .../contrib/ds/src/Form/ClassesForm.php | 24 +- .../contrib/ds/src/Form/CopyFieldForm.php | 11 +- .../contrib/ds/src/Form/EmergencyForm.php | 31 +- .../contrib/ds/src/Form/FieldDeleteForm.php | 26 +- .../contrib/ds/src/Form/FieldFormBase.php | 50 ++-- .../contrib/ds/src/Form/SettingsForm.php | 40 ++- .../contrib/ds/src/Form/TokenFieldForm.php | 11 +- .../ds/src/Plugin/Derivative/BundleField.php | 78 +++++ .../ds/src/Plugin/Derivative/DsEntityRow.php | 8 +- .../ds/src/Plugin/Derivative/DsLocalTask.php | 7 +- .../Plugin/Derivative/DynamicBlockField.php | 5 - .../Plugin/Derivative/DynamicCopyField.php | 5 - .../ds/src/Plugin/Derivative/DynamicField.php | 6 +- .../Plugin/Derivative/DynamicTokenField.php | 5 - .../Plugin/DsField/Block/BlockDescription.php | 105 +++++++ .../ds/src/Plugin/DsField/BlockBase.php | 86 ++++-- .../Plugin/DsField/Book/BookNavigation.php | 16 +- .../ds/src/Plugin/DsField/BundleField.php | 59 ++++ .../Plugin/DsField/Comment/CommentAuthor.php | 7 +- .../DsField/Comment/CommentChangedDate.php | 5 - .../DsField/Comment/CommentPostDate.php | 5 - .../Plugin/DsField/Comment/CommentTitle.php | 7 +- .../Plugin/DsField/Comment/CommentUser.php | 8 +- .../DsField/Comment/CommentUserSignature.php | 5 - .../contrib/ds/src/Plugin/DsField/Date.php | 55 +++- .../ds/src/Plugin/DsField/DsFieldBase.php | 41 ++- .../src/Plugin/DsField/DsFieldInterface.php | 25 +- .../src/Plugin/DsField/DynamicBlockField.php | 11 +- .../src/Plugin/DsField/DynamicCopyField.php | 41 +-- .../src/Plugin/DsField/DynamicTokenField.php | 5 - .../contrib/ds/src/Plugin/DsField/Entity.php | 51 +++- .../contrib/ds/src/Plugin/DsField/Field.php | 12 +- .../contrib/ds/src/Plugin/DsField/Link.php | 12 +- .../contrib/ds/src/Plugin/DsField/Markup.php | 5 - .../ds/src/Plugin/DsField/Node/NodeAuthor.php | 25 +- .../Plugin/DsField/Node/NodeChangedDate.php | 5 - .../ds/src/Plugin/DsField/Node/NodeLink.php | 5 - .../ds/src/Plugin/DsField/Node/NodeLinks.php | 5 - .../src/Plugin/DsField/Node/NodePostDate.php | 5 - .../Plugin/DsField/Node/NodeSubmittedBy.php | 80 ++++-- .../ds/src/Plugin/DsField/Node/NodeTitle.php | 5 - .../DsField/Taxonomy/TaxonomyTermLink.php | 5 - .../DsField/Taxonomy/TaxonomyTermTitle.php | 5 - .../ds/src/Plugin/DsField/ThemePluginBase.php | 5 - .../contrib/ds/src/Plugin/DsField/Title.php | 12 +- .../ds/src/Plugin/DsField/TokenBase.php | 39 ++- .../ds/src/Plugin/DsField/User/User.php | 8 +- .../src/Plugin/DsField/User/UserSignature.php | 7 +- .../ds/src/Plugin/DsField/User/Username.php | 5 - .../Plugin/DsFieldTemplate/DefaultField.php | 5 - .../DsFieldTemplate/DsFieldTemplateBase.php | 13 +- .../DsFieldTemplateInterface.php | 5 - .../ds/src/Plugin/DsFieldTemplate/Expert.php | 86 +++--- .../ds/src/Plugin/DsFieldTemplate/Minimal.php | 5 - .../ds/src/Plugin/DsFieldTemplate/Reset.php | 7 +- .../Plugin/DsFieldTemplatePluginManager.php | 5 - .../contrib/ds/src/Plugin/DsLayout.php | 58 ++-- .../contrib/ds/src/Plugin/DsPluginManager.php | 5 - .../Render/ConfigurableLanguageRenderer.php | 5 - .../Entity/Render/CurrentLanguageRenderer.php | 5 - .../Entity/Render/DefaultLanguageRenderer.php | 5 - .../views/Entity/Render/RendererBase.php | 12 +- .../Render/TranslationLanguageRenderer.php | 5 - .../ds/src/Plugin/views/row/EntityRow.php | 43 ++- .../ds/src/Routing/RouteSubscriber.php | 9 +- .../ds/src/Tests/BlockFieldPluginTest.php | 74 ++++- .../contrib/ds/src/Tests/BlockTest.php | 106 +++++++ .../contrib/ds/src/Tests/CacheTagsTest.php | 13 +- .../contrib/ds/src/Tests/CommentTest.php | 55 ++-- .../contrib/ds/src/Tests/DsTestTrait.php | 24 +- .../ds/src/Tests/DynamicFieldPluginTest.php | 28 +- .../contrib/ds/src/Tests/EntitiesTest.php | 53 ++-- .../contrib/ds/src/Tests/ExportablesTest.php | 19 +- .../contrib/ds/src/Tests/FastTestBase.php | 39 ++- .../contrib/ds/src/Tests/FieldGroupTest.php | 20 +- .../ds/src/Tests/FieldPermissionsTest.php | 26 +- .../contrib/ds/src/Tests/FieldPluginTest.php | 14 +- .../ds/src/Tests/FieldTemplateTest.php | 79 +++--- .../contrib/ds/src/Tests/HiddenRegionTest.php | 27 +- .../ds/src/Tests/LayoutClassesTest.php | 61 ++-- .../contrib/ds/src/Tests/LayoutFluidTest.php | 19 +- .../contrib/ds/src/Tests/LayoutPluginTest.php | 37 ++- .../ds/src/Tests/ManageDisplayTabTest.php | 34 +-- .../contrib/ds/src/Tests/TwigRenderTest.php | 53 ++++ .../contrib/ds/src/Tests/ViewsTest.php | 37 ++- ...tity_view_display.node.article.default.yml | 1 + .../ds_exportables_test.info.yml | 6 +- .../modules/ds_test/css/dstest-2col-fluid.css | 1 - .../tests/modules/ds_test/css/dstest-2col.css | 3 +- .../ds/tests/modules/ds_test/ds_test.info.yml | 6 +- .../tests/modules/ds_test/ds_test.layouts.yml | 9 + .../ds_test/src/Plugin/Block/DsTestBlock.php | 42 +++ .../ds_test/src/Plugin/DsField/TestField.php | 5 - .../ds_test/src/Plugin/DsField/TestField2.php | 5 - .../Plugin/DsField/TestFieldEmptyString.php | 5 - .../src/Plugin/DsField/TestFieldFalse.php | 5 - .../src/Plugin/DsField/TestFieldNothing.php | 6 - .../src/Plugin/DsField/TestFieldNull.php | 5 - .../src/Plugin/DsField/TestFieldZeroFloat.php | 5 - .../src/Plugin/DsField/TestFieldZeroInt.php | 5 - .../Plugin/DsField/TestFieldZeroString.php | 5 - .../src/Plugin/DsField/TestMultipleField.php | 39 +++ .../src/Plugin/DsFieldTemplate/TestLayout.php | 5 - .../templates/dstest-1col-title.html.twig | 18 ++ .../FunctionalJavascript/JavascriptTest.php | 81 ++++++ 156 files changed, 2104 insertions(+), 1391 deletions(-) rename profiles/cr/modules/contrib/ds/modules/ds_extras/config/{install => optional}/core.entity_view_mode.node.revision.yml (74%) create mode 100644 profiles/cr/modules/contrib/ds/src/Plugin/Derivative/BundleField.php create mode 100644 profiles/cr/modules/contrib/ds/src/Plugin/DsField/Block/BlockDescription.php create mode 100644 profiles/cr/modules/contrib/ds/src/Plugin/DsField/BundleField.php create mode 100644 profiles/cr/modules/contrib/ds/src/Tests/BlockTest.php create mode 100644 profiles/cr/modules/contrib/ds/src/Tests/TwigRenderTest.php create mode 100644 profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/Block/DsTestBlock.php create mode 100644 profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsField/TestMultipleField.php create mode 100644 profiles/cr/modules/contrib/ds/tests/modules/ds_test/templates/dstest-1col-title.html.twig create mode 100644 profiles/cr/modules/contrib/ds/tests/src/FunctionalJavascript/JavascriptTest.php diff --git a/profiles/cr/drupal-org.make.yml b/profiles/cr/drupal-org.make.yml index 06ad444321..7461433d46 100644 --- a/profiles/cr/drupal-org.make.yml +++ b/profiles/cr/drupal-org.make.yml @@ -64,7 +64,7 @@ projects: panelizer: version: 3.0-alpha2 ds: - version: 2.4 + version: 2.6 field_group: version: 1.0-rc4 entity_reference_revisions: diff --git a/profiles/cr/modules/contrib/ds/composer.json b/profiles/cr/modules/contrib/ds/composer.json index 40a33729ed..8ff0492223 100644 --- a/profiles/cr/modules/contrib/ds/composer.json +++ b/profiles/cr/modules/contrib/ds/composer.json @@ -25,8 +25,5 @@ "issues": "https://www.drupal.org/project/issues/ds", "irc": "irc://irc.freenode.org/drupal-contribute", "source": "http://git.drupal.org/project/ds.git" - }, - "require": { - "drupal/layout_plugin": "8.*" } } diff --git a/profiles/cr/modules/contrib/ds/config/install/ds.settings.yml b/profiles/cr/modules/contrib/ds/config/install/ds.settings.yml index 663db92640..333281dd79 100644 --- a/profiles/cr/modules/contrib/ds/config/install/ds.settings.yml +++ b/profiles/cr/modules/contrib/ds/config/install/ds.settings.yml @@ -5,3 +5,4 @@ ft-show-colon: false classes: region: { } field: { } +use_field_names: true diff --git a/profiles/cr/modules/contrib/ds/config/schema/ds.entity_display.schema.yml b/profiles/cr/modules/contrib/ds/config/schema/ds.entity_display.schema.yml index 4f07ffcce6..240046e250 100644 --- a/profiles/cr/modules/contrib/ds/config/schema/ds.entity_display.schema.yml +++ b/profiles/cr/modules/contrib/ds/config/schema/ds.entity_display.schema.yml @@ -18,6 +18,9 @@ core.entity_view_display.*.*.*.third_party.ds: disable_css: type: boolean label: 'Disable CSS or not' + entity_classes: + type: string + label: 'Entity, bundle and view mode classes' settings: type: mapping label: 'Display Suite layout settings' diff --git a/profiles/cr/modules/contrib/ds/config/schema/ds.schema.yml b/profiles/cr/modules/contrib/ds/config/schema/ds.schema.yml index 49a2714358..dbcbd7d485 100644 --- a/profiles/cr/modules/contrib/ds/config/schema/ds.schema.yml +++ b/profiles/cr/modules/contrib/ds/config/schema/ds.schema.yml @@ -32,3 +32,6 @@ ds.settings: sequence: - type: string label: 'Field class' + use_field_names: + type: boolean + label: 'Use field names as field keys' diff --git a/profiles/cr/modules/contrib/ds/css/ds-2col-fluid.css b/profiles/cr/modules/contrib/ds/css/ds-2col-fluid.css index 9a03ae79b7..5c4af3fcd9 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-2col-fluid.css +++ b/profiles/cr/modules/contrib/ds/css/ds-2col-fluid.css @@ -9,7 +9,7 @@ } [dir="rtl"] .ds-2col-fluid > .group-left { - float: right; + float: right; } .ds-2col-fluid > .group-right { @@ -18,7 +18,7 @@ } [dir="rtl"] .ds-2col-fluid > .group-right { - float: left; + float: left; } .ds-2col-fluid.group-one-column > .group-left, diff --git a/profiles/cr/modules/contrib/ds/css/ds-2col-stacked-fluid.css b/profiles/cr/modules/contrib/ds/css/ds-2col-stacked-fluid.css index e4b65a021c..f70ef6cd1c 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-2col-stacked-fluid.css +++ b/profiles/cr/modules/contrib/ds/css/ds-2col-stacked-fluid.css @@ -3,16 +3,13 @@ * Styling for the ds-2col-stacked-fluid template. */ -.ds-2col-stacked-fluid > .group-header { -} - .ds-2col-stacked-fluid > .group-left { float: left; /* LTR */ width: 50%; } [dir="rtl"] .ds-2col-stacked-fluid > .group-left { - float: right; + float: right; } .ds-2col-stacked-fluid > .group-right { @@ -21,7 +18,7 @@ } [dir="rtl"] .ds-2col-stacked-fluid > .group-right { - float: left; + float: left; } .ds-2col-stacked-fluid.group-one-column > .group-left, diff --git a/profiles/cr/modules/contrib/ds/css/ds-2col-stacked.css b/profiles/cr/modules/contrib/ds/css/ds-2col-stacked.css index 22428a17f3..1f57dd0402 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-2col-stacked.css +++ b/profiles/cr/modules/contrib/ds/css/ds-2col-stacked.css @@ -3,16 +3,13 @@ * Styling for the ds-2col-stacked template. */ -.ds-2col-stacked > .group-header { -} - .ds-2col-stacked > .group-left { float: left; /* LTR */ width: 50%; } [dir="rtl"] .ds-2col-stacked > .group-left { - float: right; + float: right; } .ds-2col-stacked > .group-right { @@ -21,7 +18,7 @@ } [dir="rtl"] .ds-2col-stacked > .group-right { - float: left; + float: left; } .ds-2col-stacked > .group-footer { diff --git a/profiles/cr/modules/contrib/ds/css/ds-2col.css b/profiles/cr/modules/contrib/ds/css/ds-2col.css index 24e6ce17ad..b5235b6f64 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-2col.css +++ b/profiles/cr/modules/contrib/ds/css/ds-2col.css @@ -9,7 +9,7 @@ } [dir="rtl"] .ds-2col > .group-left { - float: right; + float: right; } .ds-2col > .group-right { @@ -18,5 +18,5 @@ } [dir="rtl"] .ds-2col > .group-right { - float: right; + float: right; } diff --git a/profiles/cr/modules/contrib/ds/css/ds-3col-equal-width.css b/profiles/cr/modules/contrib/ds/css/ds-3col-equal-width.css index 3c89bb3518..81f817b1e4 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-3col-equal-width.css +++ b/profiles/cr/modules/contrib/ds/css/ds-3col-equal-width.css @@ -9,7 +9,7 @@ } [dir="rtl"] .ds-3col-equal > .group-left { - float: right; + float: right; } .ds-3col-equal > .group-middle { @@ -18,7 +18,7 @@ } [dir="rtl"] .ds-3col-equal > .group-middle { - float: right; + float: right; } .ds-3col-equal > .group-right { @@ -27,5 +27,5 @@ } [dir="rtl"] .ds-3col-equal > .group-right { - float: left; + float: left; } diff --git a/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-equal-width.css b/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-equal-width.css index c4a27591a4..b5ce5b2ad8 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-equal-width.css +++ b/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-equal-width.css @@ -13,7 +13,7 @@ } [dir="rtl"] .ds-3col-stacked-equal > .group-left { - float: right; + float: right; } .ds-3col-stacked-equal > .group-middle { @@ -22,7 +22,7 @@ } [dir="rtl"] .ds-3col-stacked-equal > .group-middle { - float: right; + float: right; } .ds-3col-stacked-equal > .group-right { @@ -31,7 +31,7 @@ } [dir="rtl"] .ds-3col-stacked-equal > .group-right { - float: left; + float: left; } .ds-3col-stacked-equal > .group-footer { diff --git a/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-fluid.css b/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-fluid.css index 75519c786e..bdcadac862 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-fluid.css +++ b/profiles/cr/modules/contrib/ds/css/ds-3col-stacked-fluid.css @@ -13,7 +13,7 @@ } [dir="rtl"] .ds-3col-stacked-fluid > .group-left { - float: right; + float: right; } .ds-3col-stacked-fluid > .group-middle { @@ -22,7 +22,7 @@ } [dir="rtl"] .ds-3col-stacked-fluid > .group-middle { - float: right; + float: right; } .ds-3col-stacked-fluid.group-one-sidebar > .group-middle { @@ -39,7 +39,7 @@ } [dir="rtl"] .ds-3col-stacked-fluid > .group-right { - float: left; + float: left; } .ds-3col-stacked-fluid > .group-footer { diff --git a/profiles/cr/modules/contrib/ds/css/ds-3col-stacked.css b/profiles/cr/modules/contrib/ds/css/ds-3col-stacked.css index 286e4213b4..f79ba5460a 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-3col-stacked.css +++ b/profiles/cr/modules/contrib/ds/css/ds-3col-stacked.css @@ -13,7 +13,7 @@ } [dir="rtl"] .ds-3col-stacked > .group-left { - float: right; + float: right; } .ds-3col-stacked > .group-middle { @@ -22,7 +22,7 @@ } [dir="rtl"] .ds-3col-stacked > .group-middle { - float: right; + float: right; } .ds-3col-stacked > .group-right { @@ -31,7 +31,7 @@ } [dir="rtl"] .ds-3col-stacked > .group-right { - float: left; + float: left; } .ds-3col-stacked > .group-footer { diff --git a/profiles/cr/modules/contrib/ds/css/ds-3col.css b/profiles/cr/modules/contrib/ds/css/ds-3col.css index 79cbc38b9b..6145d88ab9 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-3col.css +++ b/profiles/cr/modules/contrib/ds/css/ds-3col.css @@ -9,7 +9,7 @@ } [dir="rtl"] .ds-3col > .group-left { - float: right; + float: right; } .ds-3col > .group-middle { @@ -18,7 +18,7 @@ } [dir="rtl"] .ds-3col > .group-middle { - float: right; + float: right; } .ds-3col > .group-right { @@ -27,5 +27,5 @@ } [dir="rtl"] .ds-3col > .group-right { - float: left; + float: left; } diff --git a/profiles/cr/modules/contrib/ds/css/ds-4col.css b/profiles/cr/modules/contrib/ds/css/ds-4col.css index 6dc2fad608..dc86992a22 100644 --- a/profiles/cr/modules/contrib/ds/css/ds-4col.css +++ b/profiles/cr/modules/contrib/ds/css/ds-4col.css @@ -9,7 +9,7 @@ } [dir="rtl"] .ds-4col > .group-first { - float: right; + float: right; } .ds-4col > .group-second { @@ -18,7 +18,7 @@ } [dir="rtl"] .ds-4col > .group-second { - float: right; + float: right; } .ds-4col > .group-third { @@ -27,7 +27,7 @@ } [dir="rtl"] .ds-4col > .group-third { - float: right; + float: right; } .ds-4col > .group-fourth { @@ -36,5 +36,5 @@ } [dir="rtl"] .ds-4col > .group-fourth { - float: right; + float: right; } diff --git a/profiles/cr/modules/contrib/ds/css/ds.admin.css b/profiles/cr/modules/contrib/ds/css/ds.admin.css index 4d9e2df2c1..d50282bf19 100644 --- a/profiles/cr/modules/contrib/ds/css/ds.admin.css +++ b/profiles/cr/modules/contrib/ds/css/ds.admin.css @@ -1,13 +1,12 @@ - /** * @file * Administration CSS for Display Suite. */ + .ds-extras-field-template { margin-bottom: 1em; } - #field-display-overview .ft-settings .ft-group { border-top: 1px solid #aaa; padding: 5px 0; @@ -43,7 +42,7 @@ width: 130px; } -.ds-after-suggestion{ +.ds-after-suggestion { clear: both; padding-top: 10px; } @@ -69,7 +68,7 @@ table th.ds-display-list-options { .vertical-tabs fieldset#edit-additional-settings-ds-page-title-options-page-option-contexts { margin: 1em 0; padding: 2.5em 0 0; - border: 1px solid #CCCCCC; + border: 1px solid #cccccc; } #edit-additional-settings-ds-page-title-options-page-option-contexts legend { @@ -88,15 +87,15 @@ table th.ds-display-list-options { } .ds-layout-change-save { - clear: both; + clear: both; } .ds-layout-preview-arrow { - float: left; - margin: 80px 10px 0 5px; + float: left; + margin: 80px 10px 0 5px; } .ds-layout-regions { - float: left; - width: 210px; + float: left; + width: 210px; } diff --git a/profiles/cr/modules/contrib/ds/drush/ExampleField.php b/profiles/cr/modules/contrib/ds/drush/ExampleField.php index 2e723b339f..58aa99f34e 100644 --- a/profiles/cr/modules/contrib/ds/drush/ExampleField.php +++ b/profiles/cr/modules/contrib/ds/drush/ExampleField.php @@ -1,8 +1,4 @@ t('Left'), 'right' => t('Right'), ), - // Uncomment if you want to include a CSS file for this layout (example_layout.css) + // Uncomment if you want to include a CSS file for this layout (example_layout.css). // 'css' => TRUE, - // Uncomment if you want to include a preview for this layout (example_layout.png) + // Uncomment if you want to include a preview for this layout (example_layout.png). // 'image' => TRUE, ); } diff --git a/profiles/cr/modules/contrib/ds/ds.api.php b/profiles/cr/modules/contrib/ds/ds.api.php index 5d94d43de6..d24d57bd9f 100644 --- a/profiles/cr/modules/contrib/ds/ds.api.php +++ b/profiles/cr/modules/contrib/ds/ds.api.php @@ -46,10 +46,10 @@ function hook_ds_field_templates_info_alter(&$plugins) { * As soon as you have hook_ds_fields and one of the fields * has a settings key, Display Suite will call this hook for the summary. * - * @param $field + * @param array $field * The configuration of the field. * - * @return $summary + * @return string * The summary to show on the Field UI. */ function hook_ds_field_format_summary($field) { @@ -59,21 +59,21 @@ function hook_ds_field_format_summary($field) { /** * Modify the layout settings just before they get saved. * - * @param $record + * @param array $record * The record just before it gets saved into the database. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form_state values. */ -function hook_ds_layout_settings_alter($record, $form_state) { +function hook_ds_layout_settings_alter($record, \Drupal\Core\Form\FormStateInterface $form_state) { $record['layout']['settings']['classes'] = array('layout-class'); } /** * Alter the layout render array. * - * @param $layout_render_array - * The render array - * @param $context + * @param array $layout_render_array + * The render array. + * @param array $context * An array with the context that is being rendered. Available keys are * - entity * - entity_type @@ -92,10 +92,10 @@ function hook_ds_pre_render_alter(&$layout_render_array, $context, &$vars) { * * This function is only called when a layout has been chosen. * - * @param $context + * @param array $context * A collection of keys for the context. The keys are 'entity_type', * 'bundle' and 'view_mode'. - * @param $region_info + * @param array $region_info * A collection of info for regions. The keys are 'region_options' * and 'table_regions'. */ @@ -110,11 +110,10 @@ function hook_ds_layout_region_alter($context, &$region_info) { /** * Alter the field label options. * - * Note that you will either - * update the preprocess functions or the field.html.twig file when - * adding new options. + * Note that you will either update the preprocess functions or the + * field.html.twig file when adding new options. * - * @param $field_label_options + * @param array $field_label_options * A collection of field label options. */ function hook_ds_label_options_alter(&$field_label_options) { @@ -124,9 +123,9 @@ function hook_ds_label_options_alter(&$field_label_options) { /** * Alter the view mode just before it's rendered by the DS views entity plugin. * - * @param $view_mode + * @param string $view_mode * The name of the view mode. - * @param $context + * @param array $context * A collection of items which can be used to identify in what * context an entity is being rendered. The variable contains 3 keys: * - entity: The entity being rendered. @@ -140,25 +139,32 @@ function hook_ds_views_view_mode_alter(&$view_mode, $context) { } /** - * Theme an entity through an advanced function coming from the views entity plugin. + * Theme an entity through an advanced function. * - * @param $entity - * The entity - * @param $view_mode + * The function is coming from the views entity plugin. + * + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity. + * @param string $view_mode * The name of the view mode. + * + * @return array + * The rendered entity */ -function hook_ds_views_row_render_entity($entity, $view_mode) { - $entity = entity_load('node', 1); - return entity_view($entity, $view_mode); +function hook_ds_views_row_render_entity(\Drupal\Core\Entity\EntityInterface $entity, $view_mode) { + $entity = Drupal\ds\Plugin\DsField\Node::load(1); + return \Drupal::entityManager()->getViewBuilder('node')->view($entity, $view_mode); } /** - * Theme an entity through an advanced function coming from the views entity plugin. + * Theme an entity through an advanced function. + * + * Function is coming from the views entity plugin. * - * @param $build - * The builded entity - * @param $context - * Collection of parameters (row, view and view_mode) + * @param array $build + * The builded entity. + * @param array $context + * Collection of parameters (row, view and view_mode). */ function hook_ds_views_row_render_entity_alter(&$build, $context) { // You can do whatever you want to here. diff --git a/profiles/cr/modules/contrib/ds/ds.info.yml b/profiles/cr/modules/contrib/ds/ds.info.yml index 2bc9740c6a..95dceefab8 100644 --- a/profiles/cr/modules/contrib/ds/ds.info.yml +++ b/profiles/cr/modules/contrib/ds/ds.info.yml @@ -9,8 +9,8 @@ dependencies: test_dependencies: - field_group -# Information added by Drupal.org packaging script on 2016-05-23 -version: '8.x-2.4' +# Information added by Drupal.org packaging script on 2016-09-29 +version: '8.x-2.6' core: '8.x' project: 'ds' -datestamp: 1464029046 +datestamp: 1475152442 diff --git a/profiles/cr/modules/contrib/ds/ds.install b/profiles/cr/modules/contrib/ds/ds.install index 8ebe678fe3..d7cabf23af 100644 --- a/profiles/cr/modules/contrib/ds/ds.install +++ b/profiles/cr/modules/contrib/ds/ds.install @@ -5,9 +5,29 @@ * Display Suite install file. */ +use Drupal\Core\Entity\Entity\EntityViewDisplay; + /** * Implements hook_install(). */ function ds_install() { module_set_weight('ds', 1); } + +/** + * Disable adding entity, bundle, view mode classes per display. + */ +function ds_update_8001() { + + /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ + foreach (EntityViewDisplay::loadMultiple() as $display) { + $ds = $display->getThirdPartySetting('ds', 'layout'); + if (!empty($ds)) { + $ds['entity_classes'] = 'old_view_mode'; + $display + ->setThirdPartySetting('ds', 'layout', $ds) + ->save(); + } + } + +} diff --git a/profiles/cr/modules/contrib/ds/ds.links.task.yml b/profiles/cr/modules/contrib/ds/ds.links.task.yml index 9f82d001bd..b49d2ea5ba 100644 --- a/profiles/cr/modules/contrib/ds/ds.links.task.yml +++ b/profiles/cr/modules/contrib/ds/ds.links.task.yml @@ -3,6 +3,11 @@ ds.display_task: title: Displays base_route: ds.display_task weight: 0 +ds.list_task: + route_name: ds.structure + title: List + parent_id: ds.display_task + weight: 5 ds.settings_task: route_name: ds.admin_settings title: Settings diff --git a/profiles/cr/modules/contrib/ds/ds.module b/profiles/cr/modules/contrib/ds/ds.module index 69e6077ee7..1c1c6b9a93 100644 --- a/profiles/cr/modules/contrib/ds/ds.module +++ b/profiles/cr/modules/contrib/ds/ds.module @@ -14,14 +14,30 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FormatterInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Template\Attribute; use Drupal\Core\Url; use Drupal\ds\Ds; use Drupal\ds\DsAttribute; -use Drupal\ds\Plugin\DsFieldTemplate\DsFieldTemplateInterface; use Drupal\field\Entity\FieldConfig; use Drupal\layout_plugin\Layout; +/** + * Implements hook_help(). + */ +function ds_help($route_name, RouteMatchInterface $route_match){ + switch ($route_name) { + case 'help.page.ds': + $output = ''; + $output .= '

' . t('About') . '

'; + $output .= '
' . t('The Display Suite module allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files.'); + $output .= '
' . t('It allows you to apply theme templates to content type displays. It comes with predefined layouts such as "two columns", "three columns stacked", "three columns fluid" et cetera, but also lets you define your own.'); + $output .= '
' . t('Display Suite allows you to create fields from tokens or blocks. This gives you full control over the way content is displayed without having to maintain dozens of twig files.'); + $output .= '
' . t('More documentation about Display Suite in Drupal 8 can be found in Drupal\'s Community Documentation .'); + return $output; + } +} + /** * Implements hook_theme(). */ @@ -32,7 +48,7 @@ function ds_theme() { 'render element' => 'content', ]; - // Field templates + // Field templates. if (\Drupal::config('ds.settings')->get('field_template')) { $field_layouts = \Drupal::service('plugin.manager.ds.field.layout')->getDefinitions(); foreach ($field_layouts as $key => $plugin) { @@ -134,7 +150,7 @@ function ds_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInt $bundle = $entity->bundle(); $view_mode = $display->getMode(); - // Add extra metadata needed for contextual links + // Add extra metadata needed for contextual links. if (isset($build['#contextual_links'][$entity_type])) { $build['#contextual_links'][$entity_type]['metadata']['ds_bundle'] = $bundle; $build['#contextual_links'][$entity_type]['metadata']['ds_view_mode'] = $view_mode; @@ -159,14 +175,14 @@ function ds_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInt // Get configuration. $configuration = $display->getThirdPartySettings('ds'); - // Put #entity_type, #bundle and #layout on the build so we can - // access it in ds_entity_variables(). + // Put #entity_type, #bundle and #layout on the build so we can access it in + // ds_entity_variables(). $build['#entity_type'] = $entity_type; $build['#bundle'] = $bundle; $build['#ds_configuration'] = $configuration; $build['#entity'] = $entity; - // Implement UI limit + // Implement UI limit. $components = $display->getComponents(); foreach ($components as $field => $component) { if (isset($component['third_party_settings']['ds']) && !empty($component['third_party_settings']['ds']['ds_limit'])) { @@ -198,7 +214,8 @@ function ds_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInt foreach ($configuration['regions'] as $region_name => $region) { foreach ($region as $weight => $key) { - // Ignore if this field is not a DS field, just pull it in from the entity. + // Ignore if this field is not a DS field, just pull it in from the + // entity. if (!isset($fields[$key])) { continue; } @@ -212,12 +229,12 @@ function ds_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInt $field['settings'] = $field_values[$key]['settings']; } - /** @var $field_instance \Drupal\ds\Plugin\DsField\DsFieldInterface */ + /* @var $field_instance \Drupal\ds\Plugin\DsField\DsFieldInterface */ $field_instance = Ds::getFieldInstance($key, $field, $entity, $view_mode, $display, $build); $field_value = $field_instance->build(); $field_title = $field_instance->getTitle(); - // Only allow non empty fields + // Only allow non empty fields. if (!empty($field_value)) { $build[$key] = array( '#theme' => 'field', @@ -232,12 +249,17 @@ function ds_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInt '#view_mode' => '_custom', '#ds_view_mode' => $view_mode, '#items' => array((object) array('_attributes' => array())), - '#is_multiple' => FALSE, + '#is_multiple' => $field_instance->isMultiple(), '#access' => ($field_permissions && function_exists('ds_extras_ds_field_access')) ? ds_extras_ds_field_access($key, $entity_type) : TRUE, - 0 => array( - $field_value, - ), + '#formatter' => 'ds_field' ); + + if ($field_instance->isMultiple()) { + $build[$key] += $field_value; + } + else { + $build[$key][0] = array($field_value); + } } } } @@ -258,6 +280,7 @@ function template_preprocess_ds_entity_view(&$variables) { if (!empty($build['#cache']['keys'])) { $build['#cache']['keys'][0] = 'ds_entity_view'; } + unset($build['#theme']); unset($build['#pre_render']); unset($build['#sorted']); unset($build['#children']); @@ -266,8 +289,10 @@ function template_preprocess_ds_entity_view(&$variables) { unset($build['#suffix']); // Create region variables based on the layout settings. + $use_field_names = \Drupal::config('ds.settings')->get('use_field_names'); + $regions = []; foreach (array_keys($configuration['regions']) as $region_name) { - $build[$region_name] = array(); + $regions[$region_name] = array(); // Create the region content. if (!empty($configuration['regions'][$region_name])) { @@ -279,15 +304,21 @@ function template_preprocess_ds_entity_view(&$variables) { if (!isset($build[$field]['#weight'])) { $build[$field]['#weight'] = $key; } - $build[$region_name][$key] = $build[$field]; + + if ($use_field_names) { + $regions[$region_name][$field] = $build[$field]; + } + else { + $regions[$region_name][$key] = $build[$field]; + } } } } $layout = Layout::layoutPluginManager()->createInstance($configuration['layout']['id'], $configuration['layout']['settings']); - $build = $layout->build($build); + $build = array_merge($build, $layout->build($regions)); - // Disable CSS files when needed + // Disable CSS files when needed. if ($build['#ds_configuration']['layout']['disable_css']) { $library = $build['#ds_configuration']['layout']['library']; $attached = $build['#attached']['library']; @@ -308,11 +339,13 @@ function ds_preprocess_ds_layout(&$variables) { $layout_settings = $variables['settings']; // Fetch the entity type. + $bundle = FALSE; + $entity_type = FALSE; if (isset($variables['content']['#entity_type'])) { $entity_type = $variables['content']['#entity_type']; } - else { - $entity_type = FALSE; + if (isset($variables['content']['#bundle'])) { + $bundle = $variables['content']['#bundle']; } // Template layout. @@ -331,7 +364,7 @@ function ds_preprocess_ds_layout(&$variables) { foreach ($layout_settings['wrappers'] as $region_name => $wrapper) { // @todo remove from D9, This is deprecated $variables[$region_name . '_classes'] = !empty($layout_settings['classes'][$region_name]) ? ' ' . implode(' ', $layout_settings['classes'][$region_name]) : ''; - // The new way of doing stuff is creating an attributes object + // The new way of doing stuff is creating an attributes object. if (!empty($layout_settings['classes'][$region_name])) { $variables[$region_name . '_attributes'] = new Attribute(['class' => $layout_settings['classes'][$region_name]]); } @@ -372,9 +405,11 @@ function ds_preprocess_ds_layout(&$variables) { $url = $variables['content']['#' . $entity_type]->toUrl()->getInternalPath(); } break; + case 'custom': $url = $layout_settings['link_custom']; break; + case 'tokens': if ($entity_type) { $url = \Drupal::service('token')->replace($layout_settings['link_custom'], array($layout_settings => $variables['content']['#' . $entity_type]), array('clear' => TRUE)); @@ -390,33 +425,50 @@ function ds_preprocess_ds_layout(&$variables) { if ($entity_type) { if (isset($variables['content']['#ds_configuration'])) { - // Add view-mode-{name} to classes. - if (!in_array('view-mode-' . $variables['content']['#view_mode'], $variables['attributes']['class'])) { - $variables['attributes']['class'][] = 'view-mode-' . $variables['content']['#view_mode']; + + // Add theming-classes to template. + $entity_classes = !empty($variables['content']['#ds_configuration']['layout']['entity_classes']) ? $variables['content']['#ds_configuration']['layout']['entity_classes'] : 'old_view_mode'; + if ($entity_classes != 'no_classes') { + if ($entity_classes == 'all_classes') { + $variables['attributes']['class'][] = Html::cleanCssIdentifier($entity_type); + $variables['attributes']['class'][] = Html::cleanCssIdentifier($entity_type) . '--type-' . Html::cleanCssIdentifier($bundle); + $variables['attributes']['class'][] = Html::cleanCssIdentifier($entity_type) . '--view-mode-' . Html::cleanCssIdentifier($variables['content']['#view_mode']); + } + elseif ($entity_classes == 'old_view_mode') { + // Add (old style, non cleaned) view-mode-{name} to classes. + if (!in_array('view-mode-' . $variables['content']['#view_mode'], $variables['attributes']['class'])) { + $variables['attributes']['class'][] = 'view-mode-' . $variables['content']['#view_mode']; + } + } } // Let other modules know we have rendered. $variables['rendered_by_ds'] = TRUE; // Let other modules alter the ds array before rendering. - $context = array('entity' => isset($variables[$entity_type]) ? $variables[$entity_type] : (isset($variables['content']['#' . $entity_type]) ? $variables['content']['#' . $entity_type] : ''), 'entity_type' => $variables['content']['#entity_type'], 'bundle' => $variables['content']['#bundle'], 'view_mode' => $variables['content']['#view_mode']); + $context = array( + 'entity' => isset($variables[$entity_type]) ? $variables[$entity_type] : (isset($variables['content']['#' . $entity_type]) ? $variables['content']['#' . $entity_type] : ''), + 'entity_type' => $variables['content']['#entity_type'], + 'bundle' => $variables['content']['#bundle'], + 'view_mode' => $variables['content']['#view_mode'], + ); \Drupal::moduleHandler()->alter('ds_pre_render', $variables['content'], $context, $variables); } } // Copy the regions from 'content' into the top-level. - foreach(Element::children($variables['content']) as $name) { + foreach (Element::children($variables['content']) as $name) { $variables[$name] = $variables['content'][$name]; } - // Copy entity to top level to improve theme experience + // Copy entity to top level to improve theme experience. if (isset($variables['content']['#entity'])) { $variables[$variables['content']['#entity_type']] = $variables['content']['#entity']; } } /** - * Implements hook_theme_suggestions_alter() + * Implements hook_theme_suggestions_alter(). */ function ds_theme_suggestions_alter(&$suggestions, $variables, $base_theme_hook) { if (isset($variables['content']) && is_array($variables['content']) && isset($variables['content']['#ds_configuration']) && $base_theme_hook != 'ds_entity_view') { @@ -460,7 +512,7 @@ function ds_contextual_links_view_alter(&$element, $items) { $destination = \Drupal::destination()->getAsArray(); $url->setOption('query', $destination); - // When there is no bundle defined, return + // When there is no bundle defined, return. if (!empty($bundle)) { $element['#links']['manage-display'] = array( 'title' => t('Manage display'), @@ -472,7 +524,7 @@ function ds_contextual_links_view_alter(&$element, $items) { } /** - * Implements hook_local_tasks_alter() + * Implements hook_local_tasks_alter(). */ function ds_local_tasks_alter(&$local_tasks) { if (!\Drupal::moduleHandler()->moduleExists('contextual') || !\Drupal::moduleHandler()->moduleExists('field_ui')) { @@ -490,7 +542,7 @@ function ds_preprocess_field(&$variables) { $bundle = $variables['element']['#bundle']; $view_mode = isset($variables['element']['#ds_view_mode']) ? $variables['element']['#ds_view_mode'] : $variables['element']['#view_mode']; - /** @var $entity_display EntityDisplayInterface */ + /* @var $entity_display EntityDisplayInterface */ $entity_display = Ds::getDisplay($entity_type, $bundle, $view_mode); if ($entity_display && $entity_display->getThirdPartySetting('ds', 'layout')) { @@ -524,9 +576,10 @@ function ds_preprocess_field(&$variables) { $config = $field_settings[$entity_type][$bundle][$view_mode][$field_name]['ft']; $variables['ds-config'] = $config; - // When dealing with a field template we need to massage to values before printing to prevent layout issues. + // When dealing with a field template we need to massage to values before + // printing to prevent layout issues. if (isset($config['id']) && $config['id'] != 'default' && !empty($variables['ds-config']['settings'])) { - /** @var DsFieldTemplateInterface $layout_instance */ + /* @var \Drupal\ds\Plugin\DsFieldTemplate\DsFieldTemplateInterface $layout_instance */ $layout_instance = \Drupal::service('plugin.manager.ds.field.layout')->createInstance($config['id']); if (isset($variables['element']['#object'])) { $layout_instance->setEntity($variables['element']['#object']); @@ -535,7 +588,7 @@ function ds_preprocess_field(&$variables) { } } - // CSS classes + // CSS classes. if (isset($config['settings']['classes'])) { foreach ($config['settings']['classes'] as $class_name) { if (isset($variables['element']['#object'])) { @@ -559,14 +612,16 @@ function ds_preprocess_field(&$variables) { } /** - * Implements hook_theme_suggestions_HOOK_alter() for field templates. + * Implements hook_theme_suggestions_HOOK_alter(). + * + * The suggestion alters for for field templates. */ function ds_theme_suggestions_field_alter(&$suggestions, $variables) { $entity_type = $variables['element']['#entity_type']; $bundle = $variables['element']['#bundle']; $view_mode = isset($variables['element']['#ds_view_mode']) ? $variables['element']['#ds_view_mode'] : $variables['element']['#view_mode']; - /** @var $entity_display EntityDisplayInterface */ + /* @var $entity_display EntityDisplayInterface */ $entity_display = Ds::getDisplay($entity_type, $bundle, $view_mode); if ($entity_display && $entity_display->getThirdPartySetting('ds', 'layout')) { @@ -603,10 +658,10 @@ function ds_theme_suggestions_field_alter(&$suggestions, $variables) { $config = $field_settings[$entity_type][$bundle][$view_mode][$field_name]['ft']; } - // Initialize suggestion name + // Initialize suggestion name. $suggestion = ''; - // Determine the field template. In case it's something different + // Determine the field template. In case it's something different. if (isset($config['id']) && $config['id'] != 'default') { $layout_instance = \Drupal::service('plugin.manager.ds.field.layout')->createInstance($config['id']); @@ -644,7 +699,7 @@ function ds_theme_suggestions_field_alter(&$suggestions, $variables) { } /** - * Field template settings form + * Field template settings form. */ function ds_field_template_settings_form(array &$form, FormStateInterface &$form_state, array $context) { $functions = Ds::getFieldLayoutOptions(); @@ -666,7 +721,7 @@ function ds_field_template_settings_form(array &$form, FormStateInterface &$form $plugin_settings = $form_state->get('plugin_settings'); $field_settings = isset($plugin_settings[$key]['ft']) ? $plugin_settings[$key]['ft'] : array(); - // In case with an ajax refresh we fetch the function from a different place + // In case with an ajax refresh we fetch the function from a different place. $values = $form_state->getValues(); if (isset($values['fields'][$key]['settings_edit_form']['settings']['ft']['id'])) { $field_function = $values['fields'][$key]['settings_edit_form']['settings']['ft']['id']; @@ -702,11 +757,13 @@ function ds_field_template_settings_form(array &$form, FormStateInterface &$form $config = isset($field_settings['settings']) ? $field_settings['settings'] : array(); $field_layout_instance = \Drupal::service('plugin.manager.ds.field.layout')->createInstance($field_function, $config); - // Alter the form to add specific field layout settings + // Alter the form to add specific field layout settings. $form['ft']['settings'] = array( '#type' => 'container', '#attributes' => array( - 'class' => array('ft-settings') + 'class' => array( + 'ft-settings', + ), ), ); @@ -721,7 +778,7 @@ function ds_field_ui_display_overview_multistep_js($form, &$form_state) { } /** - * Form submission handler for changing conditions in field_ui_display_overview_form(). + * Submission handler for condition changes in field_ui_display_overview_form(). */ function ds_field_ui_display_overview_multistep_submit($form, &$form_state) { $form_state['rebuild'] = TRUE; @@ -742,7 +799,7 @@ function ds_field_formatter_third_party_settings_form(FormatterInterface $plugin '#type' => 'textfield', '#title' => t('UI limit'), '#size' => 2, - '#description' => t('Enter a number to limit the number of items or \'delta\' to print a specific delta (usually configured in views or found in entity->ds_delta). Leave empty to display them all. Note that depending on the formatter settings, this option might not always work.'), + '#description' => t("Enter a number to limit the number of items or 'delta' to print a specific delta (usually configured in views or found in entity->ds_delta). Leave empty to display them all. Note that depending on the formatter settings, this option might not always work."), '#default_value' => !empty($settings[$name]['ds_limit']) ? $settings[$name]['ds_limit'] : '', ); } @@ -770,7 +827,7 @@ function ds_field_formatter_settings_summary_alter(&$summary, $context) { $field = $context['field_definition']; if (isset($context['form_state'])) { - /** @var $form_state FormStateInterface */ + /* @var $form_state FormStateInterface */ $form_state = $context['form_state']; $plugin_settings = $form_state->get('plugin_settings'); $field_function = isset($plugin_settings[$field->getName()]['ft']['id']) ? $plugin_settings[$field->getName()]['ft']['id'] : $default_field_function; @@ -833,11 +890,11 @@ function template_preprocess_field__ds_field_expert(&$variables) { foreach ($vars as $key => $variable_name) { $var_attributes = array(); - // Add classes + // Add classes. if (!empty($variables['settings'][$key . '-cl'])) { $var_attributes['class'] = explode(' ', $variables['settings'][$key . '-cl']); } - // Add attributes + // Add attributes. if (!empty($variables['settings'][$key . '-at'])) { $attributes = explode(' ', $variables['settings'][$key . '-at']); foreach ($attributes as $key => $attribute) { @@ -851,7 +908,8 @@ function template_preprocess_field__ds_field_expert(&$variables) { $variables[$variable_name] = new DsAttribute($var_attributes); } - // In order to allow HTML we need to filter XSS the output of the prefix/suffix. + // In order to allow HTML we need to filter XSS the output of the + // prefix/suffix. $variables['settings']['prefix'] = XSS::filterAdmin($variables['settings']['prefix']); $variables['settings']['suffix'] = XSS::filterAdmin($variables['settings']['suffix']); } @@ -872,12 +930,12 @@ function ds_ds_field_operations_alter(&$operations, $field) { * Implements hook_entity_type_alter(). */ function ds_entity_type_alter(array &$entity_types) { - /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + /* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ foreach ($entity_types as $entity_type_id => $entity_type) { $base_table = $entity_type->getBaseTable(); if ($entity_type->get('field_ui_base_route') && !empty($base_table)) { if ($entity_type->hasLinkTemplate('canonical')) { - $entity_type->setLinkTemplate('display', $entity_type->getLinkTemplate('canonical') . '/display'); + $entity_type->setLinkTemplate('display', $entity_type->getLinkTemplate('canonical') . '/manage_display'); } } } diff --git a/profiles/cr/modules/contrib/ds/includes/field_ui.inc b/profiles/cr/modules/contrib/ds/includes/field_ui.inc index a31a861552..f4b86a182f 100644 --- a/profiles/cr/modules/contrib/ds/includes/field_ui.inc +++ b/profiles/cr/modules/contrib/ds/includes/field_ui.inc @@ -7,10 +7,8 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\Cache; -use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Entity\EntityViewDisplay; -use Drupal\Core\Entity\EntityFormInterface; use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; @@ -20,21 +18,20 @@ use Drupal\ds\Plugin\DsField\DsFieldInterface; use Drupal\field\FieldConfigInterface; use Drupal\field_ui\FieldUI; use Drupal\layout_plugin\Layout; -use Drupal\layout_plugin\Plugin\Layout\LayoutInterface; /** * Adds the Display Suite fields and layouts to the form. */ -function ds_field_ui_fields_layouts(&$form, FormStateInterface $form_state) { +function ds_field_ui_fields_layouts(&$form, FormStateInterface $form_state) { global $base_root, $base_path; // Get the entity_type, bundle and view mode. $entity_type = $form['#entity_type']; $bundle = $form['#bundle']; - /** @var EntityFormInterface $entity_form */ + /* @var \Drupal\Core\Entity\EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); - /** @var EntityDisplayInterface $entity_display */ + /* @var \Drupal\Core\Entity\Display\EntityDisplayInterface $entity_display */ $entity_display = $entity_form->getEntity(); $view_mode = $entity_display->getMode(); @@ -48,7 +45,7 @@ function ds_field_ui_fields_layouts(&$form, FormStateInterface $form_state) { if (!empty($form['#ds_layout'])) { _ds_field_ui_fields($entity_type, $bundle, $view_mode, $form, $form_state); - // Also alter core fields + // Also alter core fields. _ds_field_ui_core_fields($form, $form_state); } @@ -108,7 +105,7 @@ function ds_field_ui_create_vertical_tabs(&$form) { $form['modes']['#group'] = 'additional_settings'; $form['modes']['#weight'] = -10; if ($view_mode_admin_access) { - $url = \Drupal\Core\Url::fromRoute('field_ui.display_mode'); + $url = Url::fromRoute('field_ui.display_mode'); $form['modes']['view_modes_custom']['#description'] = \Drupal::l(t('Manage display modes'), $url); } } @@ -117,10 +114,13 @@ function ds_field_ui_create_vertical_tabs(&$form) { /** * Add Regions to 'Manage fields' or 'Manage display' screen. * - * @param $form + * @param array $form * The form to add layout fieldset and extra Display Suite fields. - * @param $form_state + * @param FormStateInterface $form_state * The current form state. + * + * @return array $form + * The altered form */ function ds_field_ui_regions($form, FormStateInterface $form_state) { @@ -128,9 +128,9 @@ function ds_field_ui_regions($form, FormStateInterface $form_state) { $entity_type = $form['#entity_type']; $bundle = $form['#bundle']; - /** @var EntityFormInterface $entity_form */ + /* @var EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); - /** @var EntityDisplayInterface $entity_display */ + /* @var \Drupal\Core\Entity\Display\EntityDisplayInterface $entity_display */ $entity_display = $entity_form->getEntity(); $view_mode = $entity_display->getMode(); @@ -165,7 +165,10 @@ function ds_field_ui_regions($form, FormStateInterface $form_state) { t('Name'), t('Field'), t('Widget'), - array('data' => t('Operations'), 'colspan' => 2), + array( + 'data' => t('Operations'), + 'colspan' => 2, + ), ); $table['#regions'] = array(); @@ -182,7 +185,7 @@ function ds_field_ui_regions($form, FormStateInterface $form_state) { $context = array( 'entity_type' => $entity_type, 'bundle' => $bundle, - 'view_mode' => $view_mode + 'view_mode' => $view_mode, ); $region_info = array( 'region_options' => &$region_options, @@ -193,7 +196,7 @@ function ds_field_ui_regions($form, FormStateInterface $form_state) { $region_options['hidden'] = t('Disabled'); $table['#regions']['hidden'] = array( 'title' => t('Disabled'), - 'message' => t('No fields are hidden.') + 'message' => t('No fields are hidden.'), ); $region = array( @@ -202,7 +205,7 @@ function ds_field_ui_regions($form, FormStateInterface $form_state) { '#default_value' => 'hidden', '#attributes' => array( 'class' => array('ds-field-region'), - ) + ), ); // Update existing rows by changing rowHandler and adding regions. @@ -241,7 +244,7 @@ function ds_field_ui_regions($form, FormStateInterface $form_state) { /** * Returns the region to which a row in the Field UI screen belongs. * - * @param $row + * @param array $row * The current row that is being rendered in the Field UI screen. * * @return string @@ -262,7 +265,7 @@ function ds_field_ui_layouts_validate($form, FormStateInterface $form_state) { // Only validate the layout settings if the layout hasn't changed. if (!$new_layout && !empty($layout)) { - /** @var LayoutInterface $layout_plugin */ + /* @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout_plugin */ $layout_plugin = Layout::layoutPluginManager()->createInstance($form_state->getValue('layout'), []); $layout_form = isset($form['layout_configuration']) ? $form['layout_configuration'] : []; foreach (Element::children($form) as $name) { @@ -292,19 +295,23 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { // Get default values. $entity_type = $form['#entity_type']; - /** @var EntityFormInterface $entity_form */ + /* @var \Drupal\Core\Entity\EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); // Get the entity display. - /** @var EntityDisplayInterface $display */ + /* @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ $display = $entity_form->getEntity(); - // Get view mode + // Get view mode. $view_mode = $display->getMode(); // Determine layout variables. $layout = $form_state->getValue('layout'); $disable_css = $form_state->getValue('disable_css'); + $entity_classes = $form_state->getValue('entity_classes'); + if (empty($entity_classes)) { + $entity_classes = 'all_classes'; + } $old_layout = $form_state->getValue('old_layout'); $new_layout = ($layout != $old_layout) || empty($old_layout); @@ -313,16 +320,16 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { return; } - $ds_layouts = Ds::getLayouts(); // Save layout and add regions if necessary. $record = array(); $record['layout'] = array( 'id' => $layout, - 'path' => !empty($layout) ? $ds_layouts[$layout]['path'] : '', + 'path' => !empty($layout) ? $ds_layouts[$layout]['path'] : '', 'library' => isset($ds_layouts[$layout]['library']) ? $ds_layouts[$layout]['library'] : FALSE, 'disable_css' => $disable_css ? TRUE : FALSE, + 'entity_classes' => $entity_classes, ); $record['regions'] = array(); @@ -343,6 +350,10 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { $first_region = key($sl['regions']); $record['layout']['settings']['classes'] = array(); $record['layout']['settings']['wrappers'] = array(); + // Set default region values. + foreach ($sl['regions'] as $region_name => $content) { + $record['layout']['settings']['wrappers'][$region_name] = 'div'; + } $record['layout']['settings']['outer_wrapper'] = 'div'; $record['layout']['settings']['attributes'] = ''; $record['layout']['settings']['link_attribute'] = FALSE; @@ -351,7 +362,11 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { foreach ($fields as $field_key => $field) { // Ignore new fieldgroup, new field or existing field. - if (in_array($field_key, array('_add_new_field', '_add_existing_field', '_add_new_group'))) { + if (in_array($field_key, array( + '_add_new_field', + '_add_existing_field', + '_add_new_group', + ))) { continue; } @@ -373,8 +388,9 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { $fields = _ds_sort_fields($form_state->getValue('fields'), 'weight'); foreach ($fields as $key => $field) { - // Make sure we need to save anything for this field. + // Make sure to hide hidden fields. if ($field['region'] == 'hidden') { + $form_state->setValue(['fields', $key, 'type'], 'hidden'); continue; } @@ -384,7 +400,7 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { $record['regions'][$field['region']][] = $key; } - /** @var LayoutInterface $layout_plugin */ + /* @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout_plugin */ $layout_plugin = Layout::layoutPluginManager()->createInstance($layout, []); $layout_form = isset($form['layout_configuration']) ? $form['layout_configuration'] : []; foreach (Element::children($form) as $name) { @@ -449,9 +465,9 @@ function ds_field_ui_fields_save($form, FormStateInterface $form_state) { } // Get the entity display. - /** @var EntityFormInterface $entity_form */ + /* @var \Drupal\Core\Entity\EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); - /** @var EntityDisplayInterface $display */ + /* @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ $display = $entity_form->getEntity(); $field_settings = array(); @@ -483,15 +499,16 @@ function ds_field_ui_fields_save($form, FormStateInterface $form_state) { $settings['settings'] = $all_plugin_settings[$field]['settings']; } elseif (isset($all_plugin_settings[$field])) { - // When the settings for that fields aren't changed the structure is different. - // @todo figure out how we can fix this + // When the settings for that fields aren't changed the structure is + // different. + // @todo figure out how we can fix this. $settings['settings'] = $all_plugin_settings[$field]; } $field_settings[$field] = $settings; - // Always unset the field template settings from the regular settings array - // @todo needs serious review + // Always unset the field template settings from the regular settings array. + // @todo needs serious review. unset($field_settings[$field]['settings']['ft']); // Add field template plugin settings if provided. @@ -504,13 +521,14 @@ function ds_field_ui_fields_save($form, FormStateInterface $form_state) { $function = isset($values['id']) ? $values['id'] : $default_field_function; $field_settings[$field]['ft']['id'] = $function; - // It's important for schema validation to never save empty arrays + // It's important for schema validation to never save empty arrays. if (empty($field_settings[$field]['ft']['settings'])) { unset($field_settings[$field]['ft']['settings']); } } - // Last but not least unset the settings if they are empty after moving the field template settings + // Last but not least unset the settings if they are empty after moving the + // field template settings. if (empty($field_settings[$field]['settings'])) { unset($field_settings[$field]['settings']); } @@ -532,20 +550,20 @@ function ds_field_ui_fields_save($form, FormStateInterface $form_state) { */ function ds_field_ui_layout_clone($form, FormStateInterface $form_state) { $clone = $form_state->getValue('clone'); - list(,,$cv) = explode('.', $clone); + list(, , $cv) = explode('.', $clone); $entity_type = $form['#entity_type']; $bundle = $form['#bundle']; - /** @var EntityFormInterface $entity_form */ + /* @var \Drupal\Core\Entity\EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); // Get the entity display. - /** @var EntityDisplayInterface $old_display */ + /* @var \Drupal\Core\Entity\Display\EntityDisplayInterface $old_display */ $old_display = $entity_form->getEntity(); $view_mode = $old_display->getMode(); $old_display->delete(); - /** @var EntityViewDisplayInterface $display */ + /* @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */ $display = EntityViewDisplay::load($entity_type . '.' . $bundle . '.' . $cv); $clone_display = $display->createCopy($view_mode); @@ -558,17 +576,21 @@ function ds_field_ui_layout_clone($form, FormStateInterface $form_state) { /** * Creates a summary for the field format configuration summary. * - * @param $field - * The configuration of the field. + * @param DsFieldInterface $plugin_instance + * An instance of the plugin. + * @param array $settings + * The passed settings. + * @param FormStateInterface $form_state + * The form state of the summary. * * @return array $summary - * The summary + * The summary. */ function ds_field_settings_summary(DsFieldInterface $plugin_instance, $settings, FormStateInterface $form_state) { - // Create the form + // Create the form. $summary = $plugin_instance->settingsSummary($settings); - // Add field template summary + // Add field template summary. ds_field_formatter_settings_summary_alter($summary, array('field_definition' => $plugin_instance, 'form_state' => $form_state)); if (empty($summary)) { @@ -585,16 +607,17 @@ function ds_field_settings_summary(DsFieldInterface $plugin_instance, $settings, /** * Creates a form for Display Suite fields. - * . - * @param $field - * The field definition. + * + * @param DsFieldInterface $plugin_instance + * An instance of the plugin. * @param FormStateInterface $form_state - * The form_state + * The form state of the form. * * @return mixed $form + * The altered form. */ function ds_field_settings_form(DsFieldInterface $plugin_instance, FormStateInterface $form_state) { - // Create the form + // Create the form. $form = $plugin_instance->settingsForm(array(), $form_state); // Add field template settings to every field if enabled. @@ -616,6 +639,11 @@ function ds_field_settings_form(DsFieldInterface $plugin_instance, FormStateInte /** * Add fake field group value in. + * + * @param array $form + * The actual form. + * @param FormStateInterface $form_state + * The form state of the form. */ function _ds_field_group_field_ui_fix_notices($form, FormStateInterface $form_state) { $field_group = array( @@ -630,16 +658,16 @@ function _ds_field_group_field_ui_fix_notices($form, FormStateInterface $form_st /** * Add the layouts fieldset on the Field UI screen. * - * @param $entity_type + * @param string $entity_type * The name of the entity type. - * @param $bundle - * The name of the bundle - * @param $view_mode - * The name of the view_mode - * @param $form + * @param string $bundle + * The name of the bundle. + * @param string $view_mode + * The name of the view_mode. + * @param array $form * A collection of form properties. * @param FormStateInterface $form_state - * The form_state + * The form_state. */ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, &$form, FormStateInterface $form_state) { $ds_layouts = Ds::getLayouts(); @@ -650,7 +678,7 @@ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, &$form, F // Create new layout option group. if (!empty($layout_definition['category'])) { - $optgroup = (string)$layout_definition['category']; + $optgroup = (string) $layout_definition['category']; } if (!isset($layout_options[$optgroup])) { @@ -670,7 +698,10 @@ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, &$form, F // Add layouts form. $form['ds_layouts'] = array( '#type' => 'details', - '#title' => t('Layout for @bundle in @view_mode', array('@bundle' => str_replace('_', ' ', $bundle), '@view_mode' => str_replace('_', ' ', $view_mode))), + '#title' => t('Layout for @bundle in @view_mode', array( + '@bundle' => str_replace('_', ' ', $bundle), + '@view_mode' => str_replace('_', ' ', $view_mode), + )), '#collapsible' => TRUE, '#group' => 'additional_settings', '#collapsed' => FALSE, @@ -679,15 +710,16 @@ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, &$form, F // @todo cleanup $layout = array(); - /** @var EntityFormInterface $entity_form */ + /* @var \Drupal\Core\Entity\EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); - /** @var EntityViewDisplayInterface $display */ + /* @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */ $display = $entity_form->getEntity(); if ($display->getThirdPartySetting('ds', 'layout')) { $layout_configuration = $display->getThirdPartySetting('ds', 'layout'); $layout = $ds_layouts[$layout_configuration['id']]; $layout['layout'] = $layout_configuration['id']; $layout['disable_css'] = $layout_configuration['disable_css']; + $layout['entity_classes'] = $layout_configuration['entity_classes']; $layout['settings'] = $layout_configuration['settings'] ?: []; $layout['regions'] = $display->getThirdPartySetting('ds', 'regions'); $layout['fields'] = $display->getThirdPartySetting('ds', 'fields'); @@ -698,12 +730,12 @@ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, &$form, F $form['#ds_layout'] = $layout; } - // Load the layout preview form + // Load the layout preview form. $layout['layout_options'] = $layout_options; - _ds_field_ui_table_layouts_preview($form, $form_state, $ds_layouts, $layout, $entity_type, $bundle, $view_mode); + _ds_field_ui_table_layouts_preview($form, $form_state, $ds_layouts, $layout, $display); if (!empty($layout) && !empty($layout['settings'])) { - /** @var LayoutInterface $layout_plugin */ + /* @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout_plugin */ $layout_plugin = Layout::layoutPluginManager()->createInstance($layout['layout'], $layout['settings'] ?: []); $layout_configuration_form = $layout_plugin->buildConfigurationForm([], $form_state); @@ -790,22 +822,18 @@ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, &$form, F /** * Add the layout previews to the Field UI screen. * - * @param $form + * @param array $form * A collection of form properties. * @param FormStateInterface $form_state - * The state of the form - * @param $ds_layouts - * Collection of all the layouts - * @param $layout - * Current selected layout - * @param $entity_type - * The name of the entity type. - * @param $bundle - * The name of the bundle - * @param $view_mode - * The name of the view_mode + * The state of the form. + * @param array $ds_layouts + * Collection of all the layouts. + * @param array $layout + * Current selected layout. + * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display + * The entity display object. */ -function _ds_field_ui_table_layouts_preview(&$form, FormStateInterface $form_state, $ds_layouts, $layout, $entity_type, $bundle, $view_mode) { +function _ds_field_ui_table_layouts_preview(&$form, FormStateInterface $form_state, $ds_layouts, $layout, EntityViewDisplayInterface $display) { $layout_string = ''; $form['ds_layouts']['layout'] = array( @@ -840,12 +868,12 @@ function _ds_field_ui_table_layouts_preview(&$form, FormStateInterface $form_sta $selected = '' . $chosen_layout['label'] . ''; $selected .= '
' . t('The default template can be found in %path', array('%path' => $chosen_layout['template_path'])); $suggestions_array = array(); - $suggestions_array[0] = $layout_string . '--' . $entity_type; - $suggestions_array[2] = $layout_string . '--' . $entity_type . '-' . $bundle; - $suggestions_array[4] = $layout_string . '--' . $entity_type . '--{id}'; - if ($view_mode != 'default') { - $suggestions_array[1] = $layout_string . '--' . $entity_type . '-' . $view_mode; - $suggestions_array[3] = $layout_string . '--' . $entity_type . '-' . $bundle . '-' . $view_mode; + $suggestions_array[0] = $layout_string . '--' . $display->getTargetEntityTypeId(); + $suggestions_array[2] = $layout_string . '--' . $display->getTargetBundle() . '-' . $display->getTargetBundle(); + $suggestions_array[4] = $layout_string . '--' . $display->getTargetEntityTypeId() . '--{id}'; + if ($display->getMode() != 'default') { + $suggestions_array[1] = $layout_string . '--' . $display->getTargetEntityTypeId() . '-' . $display->getMode(); + $suggestions_array[3] = $layout_string . '--' . $display->getTargetEntityTypeId() . '-' . $display->getTargetBundle() . '-' . $display->getMode(); } ksort($suggestions_array); @@ -896,7 +924,29 @@ function _ds_field_ui_table_layouts_preview(&$form, FormStateInterface $form_sta '#title' => t('Disable layout CSS styles'), '#default_value' => $disable_css, ); + + } + + $entity_classes = 'all_classes'; + if (isset($layout['entity_classes'])) { + $entity_classes = $layout['entity_classes']; + } + if ($form_state->hasValue('entity_classes') && $entity_classes !== $form_state->getValue('entity_classes')) { + $entity_classes = $form_state->getValue('entity_classes'); } + + // Default classes. + $form['ds_layouts']['preview']['info']['settings']['entity_classes'] = array( + '#type' => 'select', + '#title' => t('Entity classes'), + '#options' => array( + 'all_classes' => t('Entity, bundle and view mode'), + 'no_classes' => t('No classes'), + 'old_view_mode' => t('View mode (deprecated)'), + ), + '#default_value' => $entity_classes, + ); + $form['ds_layouts']['preview']['clear'] = array( '#markup' => '
', ); @@ -905,11 +955,11 @@ function _ds_field_ui_table_layouts_preview(&$form, FormStateInterface $form_sta if (!isset($layout['layout']) || $layout_string != $layout['layout']) { // Get admin path. - $route = FieldUI::getOverviewRouteInfo($entity_type, $bundle); + $route = FieldUI::getOverviewRouteInfo($display->getTargetEntityTypeId(), $display->getTargetBundle()); $route_parameters = $route->getRouteParameters(); - $route_parameters['view_mode_name'] = $view_mode; + $route_parameters['view_mode_name'] = $display->getMode(); $options = $route->getOptions(); - $route_name = 'entity.entity_view_display.' . $entity_type . '.view_mode'; + $route_name = 'entity.entity_view_display.' . $display->getTargetEntityTypeId() . '.view_mode'; $admin_path = \Drupal::service('url_generator')->generateFromRoute($route_name, $route_parameters, $options); $destination_url = ''; @@ -918,9 +968,9 @@ function _ds_field_ui_table_layouts_preview(&$form, FormStateInterface $form_sta if (isset($layout['regions'])) { $route_name = 'ds.change_layout'; $route_parameters = array( - 'entity_type' => $entity_type, - 'bundle' => $bundle, - 'display_mode' => $view_mode, + 'entity_type' => $display->getTargetEntityTypeId(), + 'bundle' => $display->getTargetBundle(), + 'display_mode' => $display->getMode(), 'new_layout' => $layout_string, ); $options = array(); @@ -953,7 +1003,7 @@ function ds_field_ui_table_layouts_preview_callback($form, FormStateInterface $f * Form submission handler for _ds_field_ui_table_layouts_preview(). */ function ds_field_ui_change_layout_submit($form, FormStateInterface $form_state) { - // Remove original destination + // Remove original destination. \Drupal::request()->query->remove('destination'); $destination = $form_state->getValue('layout_changed_url'); @@ -974,13 +1024,13 @@ function ds_field_ui_change_layout_submit($form, FormStateInterface $form_state) /** * Add the fields to the Field UI form. * - * @param $entity_type + * @param string $entity_type * The name of the entity type. - * @param $bundle - * The name of the bundle - * @param $view_mode - * The name of the view_mode - * @param $form + * @param string $bundle + * The name of the bundle. + * @param string $view_mode + * The name of the view_mode. + * @param array $form * A collection of form properties. * @param FormStateInterface $form_state * A collection of form_state properties. @@ -1009,9 +1059,9 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, FormStat ); \Drupal::moduleHandler()->alter('ds_label_options', $field_label_options); - /** @var EntityFormInterface $entity_form */ + /* @var \Drupal\Core\Entity\EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); - /** @var EntityViewDisplayInterface $display */ + /* @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */ $display = $entity_form->getEntity(); $parent_options = array(); @@ -1033,14 +1083,14 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, FormStat ); // Check if we can display this field here. - /** @var $plugin_instance DsFieldInterface */ + /* @var $plugin_instance DsFieldInterface */ $plugin_instance = \Drupal::service('plugin.manager.ds')->createInstance($field['plugin_id'], $configuration); if (!$plugin_instance->isAllowed()) { continue; } - // Don't filter out fields when $displays is empty + // Don't filter out fields when $displays is empty. if (!empty($displays)) { $continue = TRUE; foreach ($displays as $limitation) { @@ -1059,7 +1109,7 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, FormStat $form['#ds_fields'][] = $key; - // Fetch saved plugin settings + // Fetch saved plugin settings. $form_state_plugin_settings = $form_state->get('plugin_settings'); // Check on formatter settings. @@ -1081,12 +1131,12 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, FormStat } $plugin_instance->setConfiguration($plugin_settings); - // Save fetched plugin settings + // Save fetched plugin settings. $form_state->set('plugin_settings', $form_state_plugin_settings); $hidden = array('hidden' => t('- Hidden -')); - // Get the formatters from the field instance + // Get the formatters from the field instance. $formatters = $plugin_instance->formatters(); // This should be temporary. Don't want to copy stuff from the object to @@ -1165,7 +1215,7 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, FormStat /** * Alter the core field on the the Field UI form. * - * @param $form + * @param array $form * A collection of form properties. * @param FormStateInterface $form_state * A collection of form_state properties. @@ -1173,16 +1223,16 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, FormStat function _ds_field_ui_core_fields(&$form, FormStateInterface $form_state) { $entity_type = $form['#entity_type']; $bundle = $form['#bundle']; - /** @var EntityFormInterface $entity_form */ + /* @var \Drupal\Core\Entity\EntityFormInterface $entity_form */ $entity_form = $form_state->getFormObject(); - /** @var EntityViewDisplay $entity_display */ + /* @var EntityViewDisplay $entity_display */ $entity_display = $entity_form->getEntity(); // Gather type information. $instances = \Drupal::service('entity_field.manager')->getFieldDefinitions($entity_type, $bundle); $table = &$form['fields']; - // Get all persisted values for fields and plugin settings + // Get all persisted values for fields and plugin settings. $form_state_plugin_settings = $form_state->get('plugin_settings'); // Field rows. @@ -1216,7 +1266,7 @@ function _ds_field_ui_core_fields(&$form, FormStateInterface $form_state) { } } - // Set updated plugin settings + // Set updated plugin settings. $form_state->set('plugin_settings', $form_state_plugin_settings); } @@ -1302,9 +1352,9 @@ function ds_field_row_form_format_summary_construct(&$table, $key, FormStateInte /** * Utility function to sort a multidimensional array by a value in a sub-array. * - * @param $a + * @param array $a * The array to sort. - * @param $subkey + * @param string $subkey * The subkey to sort by. * * @return array diff --git a/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.info.yml b/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.info.yml index abfca919a7..b8c1b29167 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.info.yml +++ b/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.info.yml @@ -7,8 +7,8 @@ dependencies: - ds - devel -# Information added by Drupal.org packaging script on 2016-05-23 -version: '8.x-2.4' +# Information added by Drupal.org packaging script on 2016-09-29 +version: '8.x-2.6' core: '8.x' project: 'ds' -datestamp: 1464029046 +datestamp: 1475152442 diff --git a/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.module b/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.module index a900ab3e10..a734da68f9 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.module +++ b/profiles/cr/modules/contrib/ds/modules/ds_devel/ds_devel.module @@ -1,10 +1,15 @@ $entity_type) { if ($entity_type->hasViewBuilderClass() && $entity_type->hasLinkTemplate('canonical')) { $entity_type->setLinkTemplate('devel-markup', $entity_type->getLinkTemplate('canonical') . '/devel/markup'); diff --git a/profiles/cr/modules/contrib/ds/modules/ds_devel/src/Controller/DsDevelController.php b/profiles/cr/modules/contrib/ds/modules/ds_devel/src/Controller/DsDevelController.php index 9cbfabdee2..7b8583f93c 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_devel/src/Controller/DsDevelController.php +++ b/profiles/cr/modules/contrib/ds/modules/ds_devel/src/Controller/DsDevelController.php @@ -1,10 +1,5 @@ 'details', '#group' => 'additional_settings', - '#title' => t('Block regions'), + '#title' => t('Block regions (deprecated)'), '#description' => t('Create additional regions in this layout which will be exposed as blocks.') ); - + $url = Url::fromUri('https://www.drupal.org/node/2754967'); + $link = Drupal::l(t('handbook page'), $url); + $form['region_to_block']['deprecated'] = array( + '#markup' => '' . t('This functionality is not compatible with some caching modules. Read the @handbook for a better alternative.', array('@handbook' => $link)) . '' + ); $form['region_to_block']['new_block_region'] = array( '#type' => 'textfield', '#title' => t('Region name'), @@ -201,6 +206,7 @@ function ds_extras_form_ds_admin_form_alter(&$form, FormStateInterface $form_sta '#type' => 'details', '#title' => t('Extra fields'), '#group' => 'additional_settings', + '#weight' => 2, '#tree' => TRUE, ); @@ -222,13 +228,6 @@ function ds_extras_form_ds_admin_form_alter(&$form, FormStateInterface $form_sta ), ); - $form['fs3'] = array( - '#type' => 'details', - '#title' => t('Other'), - '#group' => 'additional_settings', - '#tree' => TRUE, - ); - $form['fs3']['field_permissions'] = array( '#type' => 'checkbox', '#title' => t('Field permissions'), @@ -237,10 +236,12 @@ function ds_extras_form_ds_admin_form_alter(&$form, FormStateInterface $form_sta ); if (\Drupal::moduleHandler()->moduleExists('block')) { + $url = Url::fromUri('https://www.drupal.org/node/2754967'); + $link = Drupal::l(t('handbook page'), $url); $form['fs3']['region_to_block'] = array( '#type' => 'checkbox', - '#title' => t('Region to block'), - '#description' => t('Create additional regions exposed as block. Note: this will not work on the default view mode.'), + '#title' => t('Region to block (deprecated)'), + '#description' => t('Create additional regions exposed as block. Note: this will not work on the default view mode.') . '
' . '' . t('This functionality is not compatible with some caching modules. Read the @handbook for a better alternative.', array('@handbook' => $link)) . '', '#default_value' => $config->get('region_to_block'), ); } diff --git a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Controller/DsExtrasController.php b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Controller/DsExtrasController.php index 00a9b1d56e..c36b4d8390 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Controller/DsExtrasController.php +++ b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Controller/DsExtrasController.php @@ -1,18 +1,11 @@ entityTypeManager()->getStorage('node')->loadRevision($node_revision); + /* @var \Drupal\node\NodeInterface $node */ + $node = $this->entityTypeManager() + ->getStorage('node') + ->loadRevision($node_revision); // Determine view mode. - $view_mode = \Drupal::config('ds_extras.settings')->get('override_node_revision_view_mode'); + $view_mode = \Drupal::config('ds_extras.settings') + ->get('override_node_revision_view_mode'); drupal_static('ds_view_mode', $view_mode); - $page = node_view($node, $view_mode); + $page = node_view($node, $view_mode); unset($page['nodes'][$node->id()]['#cache']); return $page; } /** - * Checks access for the switch view mode route + * Checks access for the switch view mode route. */ public function accessSwitchViewMode() { - return $this->config('ds_extras.settings')->get('switch_field') ? AccessResult::allowed() : AccessResult::forbidden(); + return $this->config('ds_extras.settings') + ->get('switch_field') ? AccessResult::allowed() : AccessResult::forbidden(); } } diff --git a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/EventSubscriber/RouteSubscriber.php b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/EventSubscriber/RouteSubscriber.php index 85b253242c..63865f8d20 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/EventSubscriber/RouteSubscriber.php +++ b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/EventSubscriber/RouteSubscriber.php @@ -1,10 +1,5 @@ entityTypeManager = $entity_type_manager; @@ -46,8 +41,6 @@ public static function create(ContainerInterface $container) { /** * Returns an array of ds extras permissions. - * - * @return array */ public function extrasPermissions() { $permissions = []; @@ -60,7 +53,7 @@ public function extrasPermissions() { $fields = Ds::getFields($entity_type); foreach ($fields as $key => $finfo) { $permissions['view ' . $key . ' on ' . $entity_type] = array( - 'title' => t('View @field on @entity_type', array('@field' => $finfo['title'], '@entity_type' => $info->getLabel())), + 'title' => $this->t('View @field on @entity_type', array('@field' => $finfo['title'], '@entity_type' => $info->getLabel())), ); } } diff --git a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/Block/DsRegionBlock.php b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/Block/DsRegionBlock.php index 4195c572a4..e84b317ffa 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/Block/DsRegionBlock.php +++ b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/Block/DsRegionBlock.php @@ -1,10 +1,5 @@ get('region_blocks'); + $region_blocks = \Drupal::config('ds_extras.settings')->get('region_blocks'); if (empty($region_blocks)) { return $this->derivatives; diff --git a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/DsField/SwitchField.php b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/DsField/SwitchField.php index 4b35a8a573..ec427c4652 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/DsField/SwitchField.php +++ b/profiles/cr/modules/contrib/ds/modules/ds_extras/src/Plugin/DsField/SwitchField.php @@ -1,17 +1,13 @@ entityDisplayRepository = $entity_display_repository; + + parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_display.repository') + ); + } + /** * {@inheritdoc} */ @@ -31,17 +56,17 @@ public function build() { $settings = $this->getConfiguration(); if (!empty($settings)) { - /** @var EntityInterface $entity */ + /* @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $this->entity(); - // Basic route parameters + // Basic route parameters. $route_parameters = array( 'entityType' => $entity->getEntityTypeId(), 'entityId' => $entity->id(), ); $selector = $this->viewMode() == 'default' ? 'full' : $this->viewMode(); - // Basic route options + // Basic route options. $route_options = array( 'query' => array( 'selector' => 'view-mode-' . $selector, @@ -54,7 +79,7 @@ public function build() { ); foreach ($settings['vms'] as $key => $value) { - // If the label is empty, do not create a link + // If the label is empty, do not create a link. if (!empty($value)) { $route_parameters['viewMode'] = $key == 'default' ? 'full' : $key; $items[] = \Drupal::l($value, Url::fromRoute('ds_extras.switch_view_mode', $route_parameters, $route_options)); @@ -85,16 +110,16 @@ public function build() { public function settingsForm($form, FormStateInterface $form_state) { $entity_type = $this->getEntityTypeId(); $bundle = $this->bundle(); - $view_modes = \Drupal::service('entity_display.repository')->getViewModes($entity_type); + $view_modes = $this->entityDisplayRepository->getViewModes($entity_type); $form['info'] = array( - '#markup' => t('Enter a label for the link for the view modes you want to switch to.
Leave empty to hide link. They will be localized.'), + '#markup' => $this->t('Enter a label for the link for the view modes you want to switch to.
Leave empty to hide link. They will be localized.'), ); $config = $this->getConfiguration(); $config = isset($config['vms']) ? $config['vms'] : array(); foreach ($view_modes as $key => $value) { - $entity_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $key); + $entity_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $key); if (!empty($entity_display)) { if ($entity_display->status()) { $form['vms'][$key] = array( @@ -117,12 +142,12 @@ public function settingsSummary($settings) { $entity_type = $this->getEntityTypeId(); $bundle = $this->bundle(); $settings = isset($settings['vms']) ? $settings['vms'] : array(); - $view_modes = \Drupal::service('entity_display.repository')->getViewModes($entity_type); + $view_modes = $this->entityDisplayRepository->getViewModes($entity_type); $summary[] = 'View mode labels'; foreach ($view_modes as $key => $value) { - $entity_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $key); + $entity_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $key); if (!empty($entity_display)) { if ($entity_display->status()) { $label = isset($settings[$key]) ? $settings[$key] : $key; diff --git a/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.info.yml b/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.info.yml index 3a13eae3bf..4d4a6e82fa 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.info.yml +++ b/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.info.yml @@ -6,8 +6,8 @@ package: 'Display Suite' dependencies: - ds -# Information added by Drupal.org packaging script on 2016-05-23 -version: '8.x-2.4' +# Information added by Drupal.org packaging script on 2016-09-29 +version: '8.x-2.6' core: '8.x' project: 'ds' -datestamp: 1464029046 +datestamp: 1475152442 diff --git a/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.module b/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.module index b6b8866933..1c5d2eb568 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.module +++ b/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/ds_switch_view_mode.module @@ -34,7 +34,7 @@ function ds_switch_view_mode_entity_base_field_info(EntityTypeInterface $entity_ * Implements hook_entity_view_mode_alter(). */ function ds_switch_view_mode_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) { - if ($entity->getEntityTypeId() == 'node' && node_is_page($entity) && !empty($entity->ds_switch->value)) { + if ($entity->getEntityTypeId() == 'node' && node_is_page($entity) && !empty($entity->ds_switch->value) && $view_mode == 'full') { $view_mode = $entity->ds_switch->value; } } @@ -46,7 +46,7 @@ function ds_switch_view_mode_entity_view_mode_alter(&$view_mode, EntityInterface */ function ds_switch_view_mode_form_node_form_alter(&$form, FormStateInterface $form_state) { // Switch full view mode. - /** @var Drupal\node\NodeInterface $node */ + /* @var Drupal\node\NodeInterface $node */ $node = $form_state->getFormObject()->getEntity(); if (\Drupal::currentUser()->hasPermission('ds switch ' . $node->bundle()) || \Drupal::currentUser()->hasPermission('ds switch view mode')) { @@ -106,6 +106,14 @@ function ds_switch_view_mode_form_node_form_alter(&$form, FormStateInterface $fo $mode = $node->get('ds_switch')->value; } $chosen_layout = $layouts[$mode]; + if (empty($chosen_layout)) { + if (isset($layouts['full'])) { + $chosen_layout = $layouts['full']; + } + else { + $chosen_layout = $layouts['']; + } + } $layout_settings = $chosen_layout->getThirdPartySettings('ds'); $ds_layouts = Ds::getLayouts(); diff --git a/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/src/Permissions.php b/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/src/Permissions.php index b87858de44..e204904bc3 100644 --- a/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/src/Permissions.php +++ b/profiles/cr/modules/contrib/ds/modules/ds_switch_view_mode/src/Permissions.php @@ -1,10 +1,5 @@ $name) { $permissions['ds switch ' . $key] = array( - 'title' => $this->t('Switch view modes on :type', array(':type' => $name)) + 'title' => $this->t('Switch view modes on :type', array(':type' => $name)), ); } diff --git a/profiles/cr/modules/contrib/ds/src/Annotation/DsField.php b/profiles/cr/modules/contrib/ds/src/Annotation/DsField.php index d077562f34..d61c8bb628 100644 --- a/profiles/cr/modules/contrib/ds/src/Annotation/DsField.php +++ b/profiles/cr/modules/contrib/ds/src/Annotation/DsField.php @@ -1,10 +1,5 @@ moduleHandler()->moduleExists('field_ui'); if (!$field_ui_enabled) { $build['no_field_ui'] = array( - '#markup' => '

' . t('You need to enable Field UI to manage the displays of entities.') . '

', + '#markup' => '

' . $this->t('You need to enable Field UI to manage the displays of entities.') . '

', '#weight' => -10, ); } @@ -64,8 +59,8 @@ public function listDisplays() { $operations = array(); $row[] = array( 'data' => array( - '#plain_text' => $bundle['label'] - ) + '#plain_text' => $bundle['label'], + ), ); if ($field_ui_enabled) { @@ -73,7 +68,7 @@ public function listDisplays() { $route = FieldUI::getOverviewRouteInfo($entity_type, $bundle_type); if ($route) { $operations['manage_display'] = array( - 'title' => t('Manage display'), + 'title' => $this->t('Manage display'), 'url' => new Url("entity.entity_view_display.$entity_type.default", $route->getRouteParameters()), ); } @@ -100,8 +95,8 @@ public function listDisplays() { $header = array( array('data' => $info->getLabel()), array( - 'data' => $field_ui_enabled ? t('operations') : '', - 'class' => 'ds-display-list-options' + 'data' => $field_ui_enabled ? $this->t('operations') : '', + 'class' => 'ds-display-list-options', ), ); $build['list_' . $entity_type] = array( @@ -122,8 +117,10 @@ public function listDisplays() { * Adds a contextual tab to entities. * * @param RouteMatchInterface $route_match + * The route information. * * @return RedirectResponse + * A redirect response pointing to the corresponding display. */ public function contextualTab(RouteMatchInterface $route_match) { $parameter_name = $route_match->getRouteObject()->getOption('_ds_entity_type_id'); @@ -142,11 +139,11 @@ public function contextualTab(RouteMatchInterface $route_match) { // Get the manage display URI. $route = FieldUI::getOverviewRouteInfo($entity_type_id, $entity->bundle()); - /** @var $entity_display EntityDisplayBase */ + /* @var $entity_display EntityDisplayBase */ $entity_display = EntityViewDisplay::load($entity_type_id . '.' . $entity->bundle() . '.' . $view_mode); $route_parameters = $route->getRouteParameters(); - if ($entity_display && $entity_display->getThirdPartySetting('ds', 'layout')) { + if ($entity_display && $entity_display->status() && $entity_display->getThirdPartySetting('ds', 'layout')) { $route_parameters['view_mode_name'] = $view_mode; $admin_route_name = "entity.entity_view_display.$entity_type_id.view_mode"; } @@ -157,7 +154,7 @@ public function contextualTab(RouteMatchInterface $route_match) { $url = new Url($admin_route_name, $route_parameters, $route->getOptions()); - return new RedirectResponse($url->toString()); + return new RedirectResponse($url->setAbsolute(TRUE)->toString()); } } diff --git a/profiles/cr/modules/contrib/ds/src/Controller/FieldController.php b/profiles/cr/modules/contrib/ds/src/Controller/FieldController.php index 62f17a9bfb..7ed8ae644a 100644 --- a/profiles/cr/modules/contrib/ds/src/Controller/FieldController.php +++ b/profiles/cr/modules/contrib/ds/src/Controller/FieldController.php @@ -1,10 +1,5 @@ storage->listAll('ds.field.'); @@ -68,8 +63,8 @@ public function fieldList() { $row = array(); $row[] = array( 'data' => array( - '#plain_text' => $field_value['label'] - ) + '#plain_text' => $field_value['label'], + ), ); $row[] = isset($field_value['type_label']) ? $field_value['type_label'] : $this->t('Unknown'); $row[] = $field_value['id']; diff --git a/profiles/cr/modules/contrib/ds/src/Ds.php b/profiles/cr/modules/contrib/ds/src/Ds.php index 39db8e3d5c..8acc559cc3 100644 --- a/profiles/cr/modules/contrib/ds/src/Ds.php +++ b/profiles/cr/modules/contrib/ds/src/Ds.php @@ -1,13 +1,8 @@ getDefinitions() as $plugin_id => $plugin) { - // Needed to get derivatives working + // Needed to get derivatives working. $plugin['plugin_id'] = $plugin_id; $static_fields[$plugin['entity_type']][$plugin_id] = $plugin; } @@ -42,16 +37,17 @@ public static function getFields($entity_type) { /** * Gets the value for a Display Suite field. * - * @param $key + * @param string $key * The key of the field. - * @param $field + * @param array $field * The configuration of a DS field. - * @param $entity + * @param \Drupal\Core\Entity\EntityInterface $entity * The current entity. - * @param $view_mode + * @param string $view_mode * The name of the view mode. - * @param $build + * @param array $build * The current built of the entity. + * * @return \Drupal\ds\Plugin\DsField\DsFieldInterface * Field instance. */ @@ -65,10 +61,10 @@ public static function getFieldInstance($key, $field, EntityInterface $entity, $ ); // Load the plugin. - /** @var $field_instance \Drupal\ds\Plugin\DsField\DsFieldInterface */ + /* @var $field_instance \Drupal\ds\Plugin\DsField\DsFieldInterface */ $field_instance = \Drupal::service('plugin.manager.ds')->createInstance($field['plugin_id'], $configuration); - /** @var $display EntityDisplayInterface */ + /* @var $display \Drupal\Core\Entity\Display\EntityDisplayInterface */ if ($field_settings = $display->getThirdPartySetting('ds', 'fields')) { $settings = isset($field_settings[$key]['settings']) ? $field_settings[$key]['settings'] : array(); // Unset field template settings. @@ -98,19 +94,20 @@ public static function getLayouts() { /** * Gets a display for a given entity. * - * @param $entity_type + * @param string $entity_type * The name of the entity. - * @param $bundle + * @param string $bundle * The name of the bundle. - * @param $view_mode + * @param string $view_mode * The name of the view mode. * @param bool $fallback * Whether to fallback to default or not. * * @return array|bool $layout + * The display. */ public static function getDisplay($entity_type, $bundle, $view_mode, $fallback = TRUE) { - /** @var $entity_display EntityDisplayInterface */ + /* @var $entity_display \Drupal\Core\Entity\Display\EntityDisplayInterface */ $entity_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $view_mode); if ($entity_display) { $overridden = $entity_display->status(); @@ -126,7 +123,7 @@ public static function getDisplay($entity_type, $bundle, $view_mode, $fallback = // In case $view_mode is not found, check if we have a default layout, // but only if the view mode settings aren't overridden for this view mode. if ($view_mode != 'default' && !$overridden && $fallback) { - /** @var $entity_default_display EntityDisplayInterface */ + /* @var $entity_default_display \Drupal\Core\Entity\Display\EntityDisplayInterface */ $entity_default_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.default'); if ($entity_default_display) { return $entity_default_display; @@ -143,7 +140,7 @@ public static function getDisplay($entity_type, $bundle, $view_mode, $fallback = * which the same entity is available as well. This is simply not possible and * will lead to infinite loops, so you can temporarily disable DS completely * by setting this variable, either from code or visit the UI through - * * admin/structure/ds/emergency + * admin/structure/ds/emergency. */ public static function isDisabled() { if (\Drupal::state()->get('ds.disabled', FALSE)) { @@ -186,7 +183,8 @@ public static function getClasses($name = 'region') { $classes[$name][Html::escape($key)] = $friendly_name; } } - $name_clone = $name; // Prevent the name from being changed. + // Prevent the name from being changed. + $name_clone = $name; \Drupal::moduleHandler()->alter('ds_classes', $classes[$name], $name_clone); } diff --git a/profiles/cr/modules/contrib/ds/src/DsAttribute.php b/profiles/cr/modules/contrib/ds/src/DsAttribute.php index 4e733e4528..745d0076e7 100644 --- a/profiles/cr/modules/contrib/ds/src/DsAttribute.php +++ b/profiles/cr/modules/contrib/ds/src/DsAttribute.php @@ -1,10 +1,5 @@ contextRepository = $context_repository; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('config.factory'), + $container->get('entity_type.manager'), + $container->get('cache_tags.invalidator'), + $container->get('module_handler'), + $container->get('context.repository') + ); + } + /** * {@inheritdoc} */ @@ -27,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_ke $this->field = $field; // Create an instance of the block. - /** @var $block BlockPluginInterface */ + /* @var $block BlockPluginInterface */ $manager = \Drupal::service('plugin.manager.block'); $block_id = $field['properties']['block']; $block = $manager->createInstance($block_id); @@ -40,6 +72,11 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_ke // Get block config form. $form = $block->blockForm($form, $form_state); + // If the block is context aware, attach the mapping widget. + if ($block instanceof ContextAwarePluginInterface) { + $form['context_mapping'] = $this->addContextAssignmentElement($block, $this->contextRepository->getAvailableContexts()); + } + if (!$form) { return array('#markup' => $this->t("This block has no configuration options.")); } @@ -49,7 +86,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_ke $form['submit'] = array( '#type' => 'submit', - '#value' => t('Save'), + '#value' => $this->t('Save'), '#weight' => 100, ); @@ -63,7 +100,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $field = $this->field; // Create an instance of the block. - /** @var $block BlockPluginInterface */ + /* @var $block BlockPluginInterface */ $manager = \Drupal::service('plugin.manager.block'); $block_id = $field['properties']['block']; $block = $manager->createInstance($block_id); @@ -79,22 +116,29 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $field = $this->field; // Create an instance of the block. - /** @var $block BlockPluginInterface */ + /* @var $block BlockPluginInterface */ $manager = \Drupal::service('plugin.manager.block'); $block_id = $field['properties']['block']; $block = $manager->createInstance($block_id); // Process block config data using the block's submit handler. $block->blockSubmit($form, $form_state); + + // If the block is context aware, store the context mapping. + if ($block instanceof ContextAwarePluginInterface && $block->getContextDefinitions()) { + $context_mapping = $form_state->getValue('context_mapping', []); + $block->setContextMapping($context_mapping); + } + $block_config = $block->getConfiguration(); - // Clear cache tags + // Clear cache tags. $this->cacheInvalidator->invalidateTags($block->getCacheTags()); - // Save block config + // Save block config. $this->config('ds.field.' . $field['id'])->set('properties.config', $block_config)->save(); - // Clear caches and redirect + // Clear caches and redirect. $this->finishSubmitForm($form, $form_state); } diff --git a/profiles/cr/modules/contrib/ds/src/Form/BlockFieldForm.php b/profiles/cr/modules/contrib/ds/src/Form/BlockFieldForm.php index ea9e5ed397..e214b86bb8 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/BlockFieldForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/BlockFieldForm.php @@ -1,13 +1,8 @@ 'select', '#options' => $blocks, - '#title' => t('Block'), + '#title' => $this->t('Block'), '#required' => TRUE, '#default_value' => isset($field['properties']['block']) ? $field['properties']['block'] : '', ); @@ -77,7 +72,7 @@ public function getProperties(FormStateInterface $form_state) { $properties = $field['properties']; } - // Save title checkbox + // Save title checkbox. $properties['use_block_title'] = $form_state->getValue('use_block_title'); return $properties; @@ -105,7 +100,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Create an instance of the block to find out if it has a config form. // Redirect to the block config form if there is one. - /** @var $block BlockPluginInterface */ + /* @var $block BlockPluginInterface */ $manager = \Drupal::service('plugin.manager.block'); $block_id = $this->field['properties']['block']; $block = $manager->createInstance($block_id); diff --git a/profiles/cr/modules/contrib/ds/src/Form/ChangeLayoutForm.php b/profiles/cr/modules/contrib/ds/src/Form/ChangeLayoutForm.php index 8ff1abdf15..7ad22476fe 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/ChangeLayoutForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/ChangeLayoutForm.php @@ -1,13 +1,8 @@ t('You are changing from @old to @new layout for @bundle in @view_mode view mode.', array('@old' => $old_layout_info['label'], '@new' => $new_layout['label'], '@bundle' => $bundle, '@view_mode' => $display_mode)), + '#markup' => $this->t('You are changing from @old to @new layout for @bundle in @view_mode view mode.', + array( + '@old' => $old_layout_info['label'], + '@new' => $new_layout['label'], + '@bundle' => $bundle, + '@view_mode' => $display_mode, + ) + ), '#prefix' => "
", '#suffix' => "
", ); @@ -89,8 +91,8 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t $new_layout['regions'] = $region_info['region_options']; $form['#new_layout']['regions'] = $new_layout['regions']; - // Display the region options - $selectable_regions = array('' => t('- None -')) + $new_layout['regions']; + // Display the region options. + $selectable_regions = array('' => $this->t('- None -')) + $new_layout['regions']; $form['regions_pre']['#markup'] = '
'; foreach ($regions as $region => $region_title) { $form['region_' . $region] = array( @@ -107,7 +109,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t } $form['regions_post']['#markup'] = '
'; - // Show previews from old and new layouts + // Show previews from old and new layouts. $form['preview'] = array( '#type' => 'container', '#prefix' => '
', @@ -130,17 +132,17 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t ); $form['#attached']['library'][] = 'ds/admin'; - // Submit button + // Submit button. $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => t('Save'), + '#value' => $this->t('Save'), '#prefix' => '
', '#suffix' => '
', ); } else { - $form['nothing'] = array('#markup' => t('No valid configuration found.')); + $form['nothing'] = array('#markup' => $this->t('No valid configuration found.')); } return $form; @@ -159,7 +161,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $bundle = $form['#entity_bundle']; $display_mode = $form['#mode']; - // Create new third party settings + // Create new third party settings. $third_party_settings = $old_layout; $third_party_settings['layout']['id'] = $new_layout_key; if (!empty($new_layout['library'])) { @@ -168,7 +170,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $third_party_settings['layout']['path'] = $new_layout['path']; unset($third_party_settings['regions']); - // map old regions to new ones + // Map old regions to new ones. foreach ($old_layout_info['layout']['regions'] as $region => $region_title) { $new_region = $form_state->getValue('ds_' . $region); if ($new_region != '' && isset($old_layout['regions'][$region])) { @@ -182,7 +184,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } // Save configuration. - /** @var $entity_display EntityDisplayInterface*/ + /* @var $entity_display EntityDisplayInterface*/ $entity_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $display_mode); foreach (array_keys($third_party_settings) as $key) { $entity_display->setThirdPartySetting('ds', $key, $third_party_settings[$key]); diff --git a/profiles/cr/modules/contrib/ds/src/Form/ClassesForm.php b/profiles/cr/modules/contrib/ds/src/Form/ClassesForm.php index 28020bb852..64c9530595 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/ClassesForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/ClassesForm.php @@ -1,10 +1,5 @@ 'textarea', - '#title' => t('CSS classes for regions'), + '#title' => $this->t('CSS classes for regions'), '#default_value' => implode("\n", $config->get('classes.region')), - '#description' => t('Configure CSS classes which you can add to regions on the "manage display" screens. Add multiple CSS classes line by line.
If you want to have a friendly name, separate class and friendly name by |, but this is not required. eg:
class_name_1
class_name_2|Friendly name
class_name_3
') + '#description' => t('Configure CSS classes which you can add to regions on the "manage display" screens. Add multiple CSS classes line by line.
If you want to have a friendly name, separate class and friendly name by |, but this is not required. eg:
class_name_1
class_name_2|Friendly name
class_name_3
'), ); - // Only show field classes if DS extras module is enabled + // Only show field classes if DS extras module is enabled. if (\Drupal::moduleHandler()->moduleExists('ds_extras')) { $form['fields'] = array( '#type' => 'textarea', - '#title' => t('CSS classes for fields'), - '#default_value' => implode("\n", $config->get('classes.field')), - '#description' => t('Configure CSS classes which you can add to fields on the "manage display" screens. Add multiple CSS classes line by line.
If you want to have a friendly name, separate class and friendly name by |, but this is not required. eg:
class_name_1
class_name_2|Friendly name
class_name_3
') + '#title' => $this->t('CSS classes for fields'), + '#default_value' => implode("\n", $config->get('classes.field')), + '#description' => $this->t('Configure CSS classes which you can add to fields on the "manage display" screens. Add multiple CSS classes line by line.
If you want to have a friendly name, separate class and friendly name by |, but this is not required. eg:
class_name_1
class_name_2|Friendly name
class_name_3
'), ); } @@ -54,14 +49,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); - // Prepare region classes + // Prepare region classes. $region_classes = array(); $regions = $form_state->getValue('regions'); if (!empty($regions)) { $region_classes = explode("\n", str_replace("\r", '', $form_state->getValue('regions'))); } - // Prepare field classes + // Prepare field classes. $field_classes = array(); $fields = $form_state->getValue('fields'); if (!empty($fields)) { @@ -79,7 +74,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { */ protected function getEditableConfigNames() { return array( - 'ds.settings' + 'ds.settings', ); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Form/CopyFieldForm.php b/profiles/cr/modules/contrib/ds/src/Form/CopyFieldForm.php index 721ea8fa4c..f2a0e4131c 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/CopyFieldForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/CopyFieldForm.php @@ -1,10 +1,5 @@ 'select', '#options' => $fields, - '#title' => t('Fields'), + '#title' => $this->t('Fields'), '#required' => TRUE, '#default_value' => isset($field['properties']['ds_plugin']) ? $field['properties']['ds_plugin'] : '', ); diff --git a/profiles/cr/modules/contrib/ds/src/Form/EmergencyForm.php b/profiles/cr/modules/contrib/ds/src/Form/EmergencyForm.php index deed822e00..b80ac686f5 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/EmergencyForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/EmergencyForm.php @@ -1,13 +1,7 @@ get('module_handler'), $container->get('state') ); - } + } /** * {@inheritdoc} @@ -86,7 +80,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['ds_fields_error']['submit'] = array( '#type' => 'submit', - '#value' => ($this->state->get('ds.disabled', FALSE) ? t('Enable attaching fields') : t('Disable attaching fields')), + '#value' => ($this->state->get('ds.disabled', FALSE) ? $this->t('Enable attaching fields') : $this->t('Disable attaching fields')), '#submit' => array('::submitFieldAttach'), '#weight' => 1, ); @@ -127,7 +121,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - // empty + // empty. } /** @@ -139,7 +133,7 @@ public function submitFieldAttach(array &$form, FormStateInterface $form_state) } /** - * Submit callback for the region to block form + * Submit callback for the region to block form. */ public function submitRegionToBlock(array &$form, FormStateInterface $form_state) { if ($form_state->getValue('remove_block_region')) { @@ -150,12 +144,13 @@ public function submitRegionToBlock(array &$form, FormStateInterface $form_state if ($value !== 0 && $key == $value) { $save = TRUE; - // Make sure there is no active block instance for this ds block region. + // Make sure there is no active block instance for this ds block + // region. if (\Drupal::moduleHandler()->moduleExists('block')) { $ids = \Drupal::entityQuery('block') ->condition('plugin', 'ds_region_block:' . $key) ->execute(); - /** @var BlockInterface $block_storage */ + /* @var \Drupal\block\BlockInterface $block_storage */ $block_storage = \Drupal::service('entity_type.manager')->getStorage('block'); foreach ($block_storage->loadMultiple($ids) as $block) { $block->delete(); @@ -169,7 +164,7 @@ public function submitRegionToBlock(array &$form, FormStateInterface $form_state if ($save) { drupal_set_message(t('Block regions were removed.')); - // Clear cached block and ds plugin definitions + // Clear cached block and ds plugin definitions. \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); \Drupal::service('plugin.manager.ds')->clearCachedDefinitions(); @@ -186,7 +181,7 @@ public function submitRegionToBlock(array &$form, FormStateInterface $form_state */ protected function getEditableConfigNames() { return array( - 'ds_extras.settings' + 'ds_extras.settings', ); } diff --git a/profiles/cr/modules/contrib/ds/src/Form/FieldDeleteForm.php b/profiles/cr/modules/contrib/ds/src/Form/FieldDeleteForm.php index 28d6affc76..a86723f2c0 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/FieldDeleteForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/FieldDeleteForm.php @@ -1,13 +1,8 @@ cacheInvalidator = $cache_invalidator; } @@ -61,7 +54,7 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to delete @field ?', array('@field' => $this->field['label'])); + return $this->t('Are you sure you want to delete @field ?', array('@field' => $this->field['label'])); } /** @@ -103,7 +96,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('ds.field.' . $field['id'])->delete(); $this->cacheInvalidator->invalidateTags(array('ds_fields_info')); - // Also clear the ds plugin cache + // Also clear the ds plugin cache. \Drupal::service('plugin.manager.ds')->clearCachedDefinitions(); // Redirect. @@ -120,4 +113,5 @@ protected function getEditableConfigNames() { 'ds.field.' . $this->field['id'], ); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Form/FieldFormBase.php b/profiles/cr/modules/contrib/ds/src/Form/FieldFormBase.php index eed6190d3c..245649f371 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/FieldFormBase.php +++ b/profiles/cr/modules/contrib/ds/src/Form/FieldFormBase.php @@ -1,10 +1,5 @@ field = $field; $form['name'] = array( - '#title' => t('Label'), + '#title' => $this->t('Label'), '#type' => 'textfield', '#default_value' => isset($field['label']) ? $field['label'] : '', - '#description' => t('The human-readable label of the field.'), + '#description' => $this->t('The human-readable label of the field.'), '#maxlength' => 128, '#required' => TRUE, '#size' => 30, @@ -119,7 +113,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_ke '#type' => 'machine_name', '#default_value' => isset($field['id']) ? $field['id'] : '', '#maxlength' => 32, - '#description' => t('The machine-readable name of this field. This name must contain only lowercase letters and underscores. This name must be unique.'), + '#description' => $this->t('The machine-readable name of this field. This name must contain only lowercase letters and underscores. This name must be unique.'), '#disabled' => !empty($field['id']), '#machine_name' => array( 'exists' => array($this, 'uniqueFieldName'), @@ -135,8 +129,8 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_ke } } $form['entities'] = array( - '#title' => t('Entities'), - '#description' => t('Select the entities for which this field will be made available.'), + '#title' => $this->t('Entities'), + '#description' => $this->t('Select the entities for which this field will be made available.'), '#type' => 'checkboxes', '#required' => TRUE, '#options' => $entity_options, @@ -144,14 +138,15 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_ke ); $form['ui_limit'] = array( - '#title' => t('Limit field'), - '#description' => t('Limit this field on field UI per bundles and/or view modes. The values are in the form of $bundle|$view_mode, where $view_mode may be either a view mode set to use custom settings, or \'default\'. You may use * to select all, e.g article|*, *|full or *|*. Enter one value per line.'), '#type' => 'textarea', + '#title' => $this->t('Limit field'), + '#description' => $this->t('Limit this field on field UI per bundles and/or view modes. The values are in the form of $bundle|$view_mode, where $view_mode may be either a view mode set to use custom settings, or \'default\'. You may use * to select all, e.g article|*, *|full or *|*. Enter one value per line.'), + '#type' => 'textarea', '#default_value' => isset($field['ui_limit']) ? $field['ui_limit'] : '', ); $form['submit'] = array( '#type' => 'submit', - '#value' => t('Save'), + '#value' => $this->t('Save'), '#weight' => 100, ); @@ -178,13 +173,13 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } $field['entities'] = $entities; - // Save field to property + // Save field to property. $this->field = $field; - // Save field values + // Save field values. $this->config('ds.field.' . $field['id'])->setData($field)->save(); - // Clear caches and redirect + // Clear caches and redirect. $this->finishSubmitForm($form, $form_state); } @@ -203,7 +198,7 @@ protected function getEditableConfigNames() { } /** - * Returns the properties for the custom field + * Returns the properties for the custom field. */ public function getProperties(FormStateInterface $form_state) { return array(); @@ -217,13 +212,12 @@ public function getType() { } /** - * Returns the admin label for the field on the field overview page + * Returns the admin label for the field on the field overview page. */ public function getTypeLabel() { return ''; } - /** * Returns whether a field machine name is unique. */ @@ -237,7 +231,7 @@ public function uniqueFieldName($name) { } /** - * Finishes the submit + * Finishes the submit. */ public function finishSubmitForm(array &$form, FormStateInterface $form_state) { $field = $this->field; @@ -245,7 +239,7 @@ public function finishSubmitForm(array &$form, FormStateInterface $form_state) { // Save field and clear ds_fields_info cache. $this->cacheInvalidator->invalidateTags(array('ds_fields_info')); - // Also clear the ds plugin cache + // Also clear the ds plugin cache. \Drupal::service('plugin.manager.ds')->clearCachedDefinitions(); // Redirect. diff --git a/profiles/cr/modules/contrib/ds/src/Form/SettingsForm.php b/profiles/cr/modules/contrib/ds/src/Form/SettingsForm.php index a41cd5e0f4..ca556522c9 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/SettingsForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/SettingsForm.php @@ -1,10 +1,5 @@ 'details', - '#title' => t('Field Templates'), + '#title' => $this->t('Field Templates'), '#group' => 'additional_settings', + '#weight' => 1, '#tree' => TRUE, '#collapsed' => FALSE, ); $form['fs1']['field_template'] = array( '#type' => 'checkbox', - '#title' => t('Enable Field Templates'), - '#description' => t('Customize the labels and the HTML output of your fields.'), + '#title' => $this->t('Enable Field Templates'), + '#description' => $this->t('Customize the labels and the HTML output of your fields.'), '#default_value' => $config->get('field_template'), ); $theme_functions = Ds::getFieldLayoutOptions(); $url = new Url('ds.classes'); - $description = t('
Default will output the field as defined in Drupal Core.
' . + $description = $this->t('
Default will output the field as defined in Drupal Core.
' . 'Reset will strip all HTML.
' . 'Minimal adds a simple wrapper around the field.
' . 'There is also an Expert Field Template that gives full control over the HTML, but can only be set per field.

' . @@ -136,7 +132,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['fs1']['ft-default'] = array( '#type' => 'select', - '#title' => t('Default Field Template'), + '#title' =>$this->t('Default Field Template'), '#options' => $theme_functions, '#default_value' => $config->get('ft-default'), '#description' => $description, @@ -149,9 +145,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['fs1']['ft-show-colon'] = array( '#type' => 'checkbox', - '#title' => t('Show colon'), + '#title' => $this->t('Show colon'), '#default_value' => $config->get('ft-show-colon'), - '#description' => t('Show the colon on the reset field template.'), + '#description' => $this->t('Show the colon on the reset field template.'), '#states' => array( 'visible' => array( 'select[name="fs1[ft-default]"]' => array('value' => 'reset'), @@ -160,6 +156,20 @@ public function buildForm(array $form, FormStateInterface $form_state) { ), ); + $form['fs3'] = array( + '#type' => 'details', + '#title' => $this->t('Other'), + '#group' => 'additional_settings', + '#weight' => 3, + '#tree' => TRUE, + ); + $form['fs3']['use_field_names'] = array( + '#type' => 'checkbox', + '#title' => $this->t('Use field names in templates'), + '#default_value' => $config->get('use_field_names'), + '#description' => $this->t('Use field names in twig templates instead of the key'), + ); + return parent::buildForm($form, $form_state); } @@ -174,6 +184,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ->set('field_template', $values['fs1']['field_template']) ->set('ft-default', $values['fs1']['ft-default']) ->set('ft-show-colon', $values['fs1']['ft-show-colon']) + ->set('use_field_names', $values['fs3']['use_field_names']) ->save(); $this->entityFieldManager->clearCachedFieldDefinitions(); @@ -182,6 +193,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->routeBuilder->setRebuildNeeded(); \Drupal::cache('render')->deleteAll(); + if ($this->moduleHandler->moduleExists('dynamic_page_cache')) { + \Drupal::cache('dynamic_page_cache')->deleteAll(); + } } /** @@ -189,7 +203,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { */ protected function getEditableConfigNames() { return array( - 'ds.settings' + 'ds.settings', ); } diff --git a/profiles/cr/modules/contrib/ds/src/Form/TokenFieldForm.php b/profiles/cr/modules/contrib/ds/src/Form/TokenFieldForm.php index 9adf8eaf35..57d0bd550c 100644 --- a/profiles/cr/modules/contrib/ds/src/Form/TokenFieldForm.php +++ b/profiles/cr/modules/contrib/ds/src/Form/TokenFieldForm.php @@ -1,10 +1,5 @@ 'text_format', - '#title' => t('Field content'), + '#title' => $this->t('Field content'), '#default_value' => isset($field['properties']['content']['value']) ? $field['properties']['content']['value'] : '', '#format' => isset($field['properties']['content']['format']) ? $field['properties']['content']['format'] : 'plain_text', '#base_type' => 'textarea', @@ -45,7 +40,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_ke // Token support. if (\Drupal::moduleHandler()->moduleExists('token')) { $form['tokens'] = array( - '#title' => t('Tokens'), + '#title' => $this->t('Tokens'), '#type' => 'container', '#states' => array( 'invisible' => array( diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/BundleField.php b/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/BundleField.php new file mode 100644 index 0000000000..3499f4bb34 --- /dev/null +++ b/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/BundleField.php @@ -0,0 +1,78 @@ +basePluginId = $base_plugin_id; + $this->entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, $base_plugin_id) { + return new static( + $base_plugin_id, + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions($base_plugin_definition) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { + $base_table = $entity_type->getBaseTable(); + if ($entity_type->get('field_ui_base_route') && !empty($base_table)) { + $this->derivatives[$entity_type_id] = $base_plugin_definition; + $this->derivatives[$entity_type_id] += array( + 'provider' => $entity_type_id, + 'title' => 'Bundle name', + 'entity_type' => $entity_type_id, + ); + } + } + + return $this->derivatives; + } + +} diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsEntityRow.php b/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsEntityRow.php index 03ae8ffeda..91fd78dc34 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsEntityRow.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsEntityRow.php @@ -1,10 +1,5 @@ derivatives; } + } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsLocalTask.php b/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsLocalTask.php index 297f3bc1bb..dc3b37702d 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsLocalTask.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/Derivative/DsLocalTask.php @@ -1,10 +1,5 @@ getConfiguration(); + + $output = $this->entity()->label(); + + if (empty($output)) { + return array(); + } + + $output = Html::escape($output); + + // Wrapper and class. + if (!empty($config['wrapper'])) { + $wrapper = Html::escape($config['wrapper']); + $class = (!empty($config['class'])) ? ' class="' . Html::escape($config['class']) . '"' : ''; + $output = '<' . $wrapper . $class . '>' . $output . ''; + } + + return array( + '#markup' => $output, + ); + } + + /** + * {@inheritdoc} + */ + public function settingsForm($form, FormStateInterface $form_state) { + $config = $this->getConfiguration(); + + $settings['wrapper'] = array( + '#type' => 'textfield', + '#title' => 'Wrapper', + '#default_value' => $config['wrapper'], + '#description' => $this->t('Eg: h1, h2, p'), + ); + $settings['class'] = array( + '#type' => 'textfield', + '#title' => 'Class', + '#default_value' => $config['class'], + '#description' => $this->t('Put a class on the wrapper. Eg: block-title'), + ); + + return $settings; + } + + /** + * {@inheritdoc} + */ + public function settingsSummary($settings) { + $config = $this->getConfiguration(); + + $summary = array(); + $summary[] = 'Wrapper: ' . $config['wrapper']; + + if (!empty($config['class'])) { + $summary[] = 'Class: ' . $config['class']; + } + + return $summary; + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + + $configuration = array( + 'wrapper' => 'h2', + 'class' => '', + ); + + return $configuration; + } + + /** + * {@inheritdoc} + */ + protected function entityRenderKey() { + return 'label'; + } + +} diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/BlockBase.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/BlockBase.php index bebbbbd28b..75527574f7 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/BlockBase.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/BlockBase.php @@ -1,19 +1,19 @@ blockManager = $block_manager; + $this->contextHandler = $contextHandler; + $this->contextRepository = $contextRepository; + + parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('context.handler'), + $container->get('context.repository'), + $container->get('plugin.manager.block') + ); + } + /** * {@inheritdoc} */ public function build() { - // Get block + // Get block. $block = $this->getBlock(); // Apply block config. $block_config = $this->blockConfig(); $block->setConfiguration($block_config); - // Get render array. - $block_elements = $block->build(); + if ($block->access(\Drupal::currentUser())) { + // Inject context values. + if ($block instanceof ContextAwarePluginInterface) { + $contexts = $this->contextRepository->getRuntimeContexts(array_values($block->getContextMapping())); + $this->contextHandler->applyContextMapping($block, $contexts); + } - // Return an empty array if there is nothing to render. - return Element::isEmpty($block_elements) ? [] : $block_elements; + $block_elements = $block->build(); + + // Return an empty array if there is nothing to render. + return Element::isEmpty($block_elements) ? [] : $block_elements; + } + + return []; } /** @@ -59,16 +114,15 @@ protected function blockConfig() { */ protected function getBlock() { if (!$this->block) { - $manager = \Drupal::service('plugin.manager.block'); - // Create an instance of the block. - /** @var $block BlockPluginInterface */ + /* @var $block BlockPluginInterface */ $block_id = $this->blockPluginId(); - $block = $manager->createInstance($block_id); + $block = $this->blockManager->createInstance($block_id); $this->block = $block; } return $this->block; } + } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Book/BookNavigation.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Book/BookNavigation.php index 44b60a97db..4792eb375f 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Book/BookNavigation.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Book/BookNavigation.php @@ -1,10 +1,5 @@ viewMode() != 'full') { return FALSE; } - // Get all the allowed types + // Get all the allowed types. $types = \Drupal::config('book.settings')->get('allowed_types'); if (!empty($types)) { foreach ($types as $type) { - if ($type) - return TRUE; + if ($type) { + return TRUE; + } } } - // Return false when there where no displays + // Return false when there where no displays. return FALSE; } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/BundleField.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/BundleField.php new file mode 100644 index 0000000000..201f90394c --- /dev/null +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/BundleField.php @@ -0,0 +1,59 @@ +entityTypeManager = $entity_type_manager; + + parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function build() { + $config = $this->getConfiguration(); + $entity = $this->entity(); + $bundles_info = $this->entityTypeManager->getBundleInfo($config['field']['entity_type']); + $output = $bundles_info[$entity->bundle()]['label']; + + return array( + '#markup' => $output, + ); + } + +} diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentAuthor.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentAuthor.php index efb917ddbb..fc4831f6d2 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentAuthor.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentAuthor.php @@ -1,10 +1,5 @@ getEntityViewMode(); - /** @var $comment CommentInterface */ + /* @var $comment \Drupal\comment\CommentInterface */ $comment = $this->entity(); $uid = $comment->getOwnerId(); diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentUserSignature.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentUserSignature.php index 894e158f80..55b8c1c258 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentUserSignature.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Comment/CommentUserSignature.php @@ -1,10 +1,5 @@ entityTypeManager = $entity_type_manager; + $this->dateFormatter = $date_formatter; + + parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager'), + $container->get('date.formatter') + ); + } + /** * {@inheritdoc} */ @@ -23,7 +57,7 @@ public function build() { $render_key = $this->getRenderKey(); return array( - '#markup' => format_date($this->entity()->{$render_key}->value, $date_format), + '#markup' => $this->dateFormatter->format($this->entity()->{$render_key}->value, $date_format), ); } @@ -31,17 +65,16 @@ public function build() { * {@inheritdoc} */ public function formatters() { - $date_types = \Drupal::service('entity_type.manager') - ->getStorage('date_format') + $date_types = $this->entityTypeManager->getStorage('date_format') ->loadMultiple(); $date_formatters = array(); foreach ($date_types as $machine_name => $value) { - /** @var $value DateFormatInterface */ + /* @var $value \Drupal\Core\Datetime\DateFormatterInterface */ if ($value->isLocked()) { continue; } - $date_formatters['ds_post_date_' . $machine_name] = t($value->id()); + $date_formatters['ds_post_date_' . $machine_name] = $this->t($value->id()); } return $date_formatters; diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldBase.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldBase.php index 7beb1c4012..d56a886bd2 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldBase.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldBase.php @@ -1,15 +1,10 @@ configuration += $this->defaultConfiguration(); } + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition + ); + } + /** * {@inheritdoc} */ @@ -46,21 +53,20 @@ public function settingsSummary($settings) { } /** - * * {@inheritdoc} */ public function defaultConfiguration() { - return array(); + return array(); } - /** + /** * {@inheritdoc} - */ + */ public function getConfiguration() { return $this->configuration; } - /** + /** * {@inheritdoc} */ public function setConfiguration(array $configuration) { @@ -114,7 +120,7 @@ public function getEntityTypeId() { return $this->configuration['entity_type']; } elseif ($entity = $this->entity()) { - /** @var $entity EntityInterface */ + /* @var $entity EntityInterface */ return $entity->getEntityTypeId(); } else { @@ -158,11 +164,18 @@ public function getTitle() { } /** - * @inheritdoc + * {@inheritdoc} */ public function calculateDependencies() { - // By default there are no dependencies + // By default there are no dependencies. return array(); } + /** + * {@inheritdoc} + */ + public function isMultiple() { + return FALSE; + } + } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldInterface.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldInterface.php index 959367514d..634256be0d 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldInterface.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DsFieldInterface.php @@ -1,19 +1,15 @@ getBlock(); if ($block instanceof ViewsBlock) { @@ -58,7 +52,8 @@ public function getTitle() { if (!empty($block_build['#title'])) { $title = $block_build['#title']; } - } else { + } + else { $title = $block->label(); } } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicCopyField.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicCopyField.php index a946c96052..29e449ea37 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicCopyField.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicCopyField.php @@ -1,15 +1,13 @@ field_instance = $manager->createInstance($plugin_definition['properties']['ds_plugin'], $configuration); + $this->fieldInstance = $plugin_Manager->createInstance($plugin_definition['properties']['ds_plugin'], $configuration); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('plugin.manager.ds') + ); } /** * {@inheritdoc} */ public function build() { - return $this->field_instance->build(); + return $this->fieldInstance->build(); } /** * {@inheritdoc} */ public function settingsForm($form, FormStateInterface $form_state) { - return $this->field_instance->settingsForm($form, $form_state); + return $this->fieldInstance->settingsForm($form, $form_state); } /** * {@inheritdoc} */ public function settingsSummary($settings) { - return $this->field_instance->settingsSummary($settings); + return $this->fieldInstance->settingsSummary($settings); } /** * {@inheritdoc} */ public function getConfiguration() { - return $this->field_instance->getConfiguration(); + return $this->fieldInstance->getConfiguration(); } /** * {@inheritdoc} */ public function setConfiguration(array $configuration) { - return $this->field_instance->setConfiguration($configuration); + return $this->fieldInstance->setConfiguration($configuration); } /** @@ -81,7 +90,7 @@ public function defaultConfiguration() { * {@inheritdoc} */ public function formatters() { - return $this->field_instance->formatters(); + return $this->fieldInstance->formatters(); } } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicTokenField.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicTokenField.php index 3f40d51a7e..4ab6bb85a5 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicTokenField.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/DynamicTokenField.php @@ -1,10 +1,5 @@ entityDisplayRepository = $entity_display_repository; + + parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_display.repository') + ); + } + /** * {@inheritdoc} */ public function settingsForm($form, FormStateInterface $form_state) { $entity = $this->linkedEntity(); - $view_modes = \Drupal::service('entity_display.repository')->getViewModes($entity); + $view_modes = $this->entityDisplayRepository->getViewModes($entity); $options = array(); foreach ($view_modes as $id => $view_mode) { @@ -41,14 +67,14 @@ public function settingsForm($form, FormStateInterface $form_state) { */ public function settingsSummary($settings) { $entity = $this->linkedEntity(); - $view_modes = \Drupal::service('entity_display.repository')->getViewModes($entity); + $view_modes = $this->entityDisplayRepository->getViewModes($entity); - // When no view modes are found no summary is displayed + // When no view modes are found no summary is displayed. if (empty($view_modes)) { return ''; } - // Print the chosen view mode or the default one + // Print the chosen view mode or the default one. $config = $this->getConfiguration(); $entity_view_mode = $config['entity_view_mode']; $summary[] = 'View mode: ' . $view_modes[$entity_view_mode]['label']; @@ -61,7 +87,7 @@ public function settingsSummary($settings) { */ public function defaultConfiguration() { $entity = $this->linkedEntity(); - $view_modes = \Drupal::service('entity_display.repository')->getViewModes($entity); + $view_modes = $this->entityDisplayRepository->getViewModes($entity); reset($view_modes); $default_view_mode = key($view_modes); @@ -73,14 +99,14 @@ public function defaultConfiguration() { } /** - * Gets the wanted entity + * Gets the wanted entity. */ public function linkedEntity() { return ''; } /** - * Gets the view mode + * Gets the view mode. */ public function getEntityViewMode() { $config = $this->getConfiguration(); @@ -88,4 +114,3 @@ public function getEntityViewMode() { } } - diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Field.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Field.php index 44b6ef93c0..ddfa08a098 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Field.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Field.php @@ -1,14 +1,8 @@ getConfiguration(); - // Initialize output + // Initialize output. $output = ''; // Basic string. $entity_render_key = $this->entityRenderKey(); if (isset($config['link text'])) { - $output = t($config['link text']); + $output = $this->t($config['link text']); } elseif (!empty($entity_render_key) && isset($this->entity()->{$entity_render_key})) { if ($this->getEntityTypeId() == 'user' && $entity_render_key == 'name') { @@ -45,7 +39,7 @@ public function build() { // Link. if (!empty($config['link'])) { - /** @var $entity EntityInterface */ + /* @var $entity EntityInterface */ $entity = $this->entity(); $url_info = $entity->toUrl(); if (!empty($config['link class'])) { diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Link.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Link.php index 096ea0e918..0fe6d4b2ae 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Link.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Link.php @@ -1,11 +1,7 @@ 'textfield', '#title' => 'Link class', '#default_value' => $config['link class'], - '#description' => t('Put a class on the link. Eg: btn btn-default'), + '#description' => $this->t('Put a class on the link. Eg: btn btn-default'), ); $form['wrapper'] = array( '#type' => 'textfield', '#title' => 'Wrapper', '#default_value' => $config['wrapper'], - '#description' => t('Eg: h1, h2, p') + '#description' => $this->t('Eg: h1, h2, p'), ); $form['class'] = array( '#type' => 'textfield', '#title' => 'Class', '#default_value' => $config['class'], - '#description' => t('Put a class on the wrapper. Eg: block-title') + '#description' => $this->t('Put a class on the wrapper. Eg: block-title'), ); return $form; diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Markup.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Markup.php index 44946c670b..0e3af38b88 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Markup.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Markup.php @@ -1,10 +1,5 @@ entity(); - /** @var $user UserInterface */ + /* @var $user UserInterface */ $user = $node->getOwner(); // Users without a user name are anonymous users. These are never linked. @@ -45,8 +38,8 @@ public function build() { return array( '#markup' => $user->getUsername(), '#cache' => array( - 'tags' => $user->getCacheTags() - ) + 'tags' => $user->getCacheTags(), + ), ); } @@ -55,12 +48,12 @@ public function build() { '#theme' => 'username', '#account' => $user, '#cache' => array( - 'tags' => $user->getCacheTags() - ) + 'tags' => $user->getCacheTags(), + ), ); } - // Otherwise return an empty array + // Otherwise return an empty array. return array(); } @@ -70,8 +63,8 @@ public function build() { public function formatters() { $formatters = array( - 'author' => t('Author'), - 'author_linked' => t('Author linked to profile') + 'author' => $this->t('Author'), + 'author_linked' => $this->t('Author linked to profile'), ); return $formatters; diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeChangedDate.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeChangedDate.php index 8132ace37d..6c447d561a 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeChangedDate.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeChangedDate.php @@ -1,10 +1,5 @@ renderer = $renderer; + + parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $date_service); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager'), + $container->get('renderer'), + $container->get('date.formatter') + ); + } + /** * {@inheritdoc} */ public function build() { $field = $this->getFieldConfiguration(); - /** @var $node NodeInterface */ + /* @var $node \Drupal\node\NodeInterface */ $node = $this->entity(); - /** @var $account UserInterface */ + /* @var $account \Drupal\user\UserInterface */ $account = $node->getOwner(); - switch ($field['formatter']) { - default: - $date_format = str_replace('ds_post_date_', '', $field['formatter']); - $user_name = array( - '#theme' => 'username', - '#account' => $account, - ); - return array( - '#markup' => t('Submitted by @user on @date.', array( - '@user' => \Drupal::service('renderer')->render($user_name), - '@date' => \Drupal::service('date.formatter')->format($this->entity()->created->value, $date_format), - ':user_link' => Url::fromUri('entity:user/' . $account->id())->toString()) - ), - '#cache' => array( - 'tags' => $account->getCacheTags() - ), - ); - } + $date_format = str_replace('ds_post_date_', '', $field['formatter']); + $user_name = array( + '#theme' => 'username', + '#account' => $account, + ); + return array( + '#markup' => $this->t('Submitted by @user on @date.', + array( + '@user' => $this->renderer->render($user_name), + '@date' => $this->dateFormatter->format($this->entity()->created->value, $date_format), + ':user_link' => Url::fromUri('entity:user/' . $account->id())->toString(), + ) + ), + '#cache' => array( + 'tags' => $account->getCacheTags(), + ), + ); } } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeTitle.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeTitle.php index 7363d971ab..7174e9aafd 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeTitle.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/Node/NodeTitle.php @@ -1,10 +1,5 @@ 'textfield', '#title' => 'Wrapper', '#default_value' => $config['wrapper'], - '#description' => t('Eg: h1, h2, p') + '#description' => $this->t('Eg: h1, h2, p'), ); $settings['class'] = array( '#type' => 'textfield', '#title' => 'Class', '#default_value' => $config['class'], - '#description' => t('Put a class on the wrapper. Eg: block-title') + '#description' => $this->t('Put a class on the wrapper. Eg: block-title'), ); return $settings; @@ -71,7 +67,7 @@ public function defaultConfiguration() { $configuration = array( 'link' => 0, 'wrapper' => 'h2', - 'class' => '' + 'class' => '', ); return $configuration; diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/TokenBase.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/TokenBase.php index 1de86b69ee..66c1f415a9 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/TokenBase.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/TokenBase.php @@ -1,24 +1,51 @@ token = $token_service; + + parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('token') + ); + } + /** * {@inheritdoc} */ public function build() { $content = $this->content(); $format = $this->format(); - $value = \Drupal::service('token')->replace($content, array($this->getEntityTypeId() => $this->entity()), array('clear' => TRUE)); + $value = $this->token->replace($content, array($this->getEntityTypeId() => $this->entity()), array('clear' => TRUE)); return array( '#type' => 'processed_text', diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/User.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/User.php index 5cab67ef09..4bea846f32 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/User.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/User.php @@ -1,14 +1,8 @@ getEntityViewMode(); - /** @var $node NodeInterface */ + /* @var $node \Drupal\node\NodeInterface */ $node = $this->entity(); $uid = $node->getOwnerId(); diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/UserSignature.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/UserSignature.php index b1027956f8..cf272ee117 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/UserSignature.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/UserSignature.php @@ -1,10 +1,5 @@ get('signatures'); // We use this function to decide if we should show this field. diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/Username.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/Username.php index d2dbea4bcd..b3515daf7e 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/Username.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsField/User/Username.php @@ -1,10 +1,5 @@ 'textfield', - '#title' => t('Label'), + '#title' => $this->t('Label'), '#size' => '10', - '#default_value' =>$config['lb'], + '#default_value' => $config['lb'], ); $form['lb-col'] = array( '#type' => 'checkbox', - '#title' => t('Show label colon'), + '#title' => $this->t('Show label colon'), '#default_value' => $config['lb-col'], '#attributes' => array( 'class' => array('colon-checkbox'), @@ -72,7 +67,7 @@ public function alterForm(&$form) { '#type' => 'select', '#multiple' => TRUE, '#options' => $field_classes, - '#title' => t('Choose additional CSS classes for the field'), + '#title' => $this->t('Choose additional CSS classes for the field'), '#default_value' => $config['classes'], '#prefix' => '
', '#suffix' => '
', diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/DsFieldTemplateInterface.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/DsFieldTemplateInterface.php index 84ca9f0de4..eb9191a100 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/DsFieldTemplateInterface.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/DsFieldTemplateInterface.php @@ -1,10 +1,5 @@ getConfiguration(); - // Add prefix + // Add label. $form['lb'] = array( '#type' => 'textfield', - '#title' => t('Label'), + '#title' => $this->t('Label'), '#size' => '10', '#default_value' => $config['lb'], ); - // Add prefix + // Add prefix. $form['prefix'] = array( '#type' => 'textfield', - '#title' => t('Prefix'), + '#title' => $this->t('Prefix'), '#size' => '100', - '#description' => t('You can enter any html in here.'), + '#description' => $this->t('You can enter any html in here.'), '#default_value' => isset($config['prefix']) ? $config['prefix'] : '', '#prefix' => '
', '#suffix' => '
', ); $wrappers = array( - 'lbw' => array('title' => t('Label wrapper')), - 'ow' => array('title' => t('Outer wrapper')), - 'fis' => array('title' => t('Field items')), - 'fi' => array('title' => t('Field item')), + 'lbw' => array('title' => $this->t('Label wrapper')), + 'ow' => array('title' => $this->t('Outer wrapper')), + 'fis' => array('title' => $this->t('Field items')), + 'fi' => array('title' => $this->t('Field item')), ); foreach ($wrappers as $wrapper_key => $value) { @@ -61,38 +54,38 @@ public function alterForm(&$form) { ); $form[$wrapper_key . '-el'] = array( '#type' => 'textfield', - '#title' => t('Element'), + '#title' => $this->t('Element'), '#size' => '10', - '#description' => t('E.g. div, span, h2 etc.'), + '#description' => $this->t('E.g. div, span, h2 etc.'), '#default_value' => $config[$wrapper_key . '-el'], '#states' => array( 'visible' => array( ':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE), - ) + ), ), ); $form[$wrapper_key . '-cl'] = array( '#type' => 'textfield', - '#title' => t('Classes'), + '#title' => $this->t('Classes'), '#size' => '10', '#default_value' => $config[$wrapper_key . '-cl'], - '#description' => t('E.g.') .' field-expert', + '#description' => $this->t('E.g. field-expert'), '#states' => array( 'visible' => array( ':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE), - ) + ), ), ); $form[$wrapper_key . '-at'] = array( '#type' => 'textfield', - '#title' => t('Attributes'), + '#title' => $this->t('Attributes'), '#size' => '20', '#default_value' => $config[$wrapper_key . '-at'], - '#description' => t('E.g. name="anchor"'), + '#description' => $this->t('E.g. name="anchor"'), '#states' => array( 'visible' => array( ':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE), - ) + ), ), ); @@ -100,7 +93,7 @@ public function alterForm(&$form) { if ($wrapper_key == 'lbw') { $form['lb-col'] = array( '#type' => 'checkbox', - '#title' => t('Show label colon'), + '#title' => $this->t('Show label colon'), '#default_value' => $config['lb-col'], '#attributes' => array( 'class' => array('colon-checkbox'), @@ -108,20 +101,20 @@ public function alterForm(&$form) { '#states' => array( 'visible' => array( ':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE), - ) + ), ), ); } if ($wrapper_key != 'lbw') { $form[$wrapper_key . '-def-at'] = array( '#type' => 'checkbox', - '#title' => t('Add default attributes'), + '#title' => $this->t('Add default attributes'), '#default_value' => $config[$wrapper_key . '-def-at'], '#suffix' => ($wrapper_key == 'ow') ? '' : '
', '#states' => array( 'visible' => array( ':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE), - ) + ), ), ); } @@ -135,23 +128,23 @@ public function alterForm(&$form) { if ($wrapper_key == 'ow') { $form[$wrapper_key . '-def-cl'] = array( '#type' => 'checkbox', - '#title' => t('Add default classes'), + '#title' => $this->t('Add default classes'), '#default_value' => $config[$wrapper_key . '-def-cl'], '#suffix' => '
', '#states' => array( 'visible' => array( ':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE), - ) + ), ), ); } } - // Add suffix + // Add suffix. $form['suffix'] = array( '#type' => 'textfield', - '#title' => t('Suffix'), + '#title' => $this->t('Suffix'), '#size' => '100', - '#description' => t('You can enter any html in here.'), + '#description' => $this->t('You can enter any html in here.'), '#default_value' => isset($config['suffix']) ? $config['suffix'] : '', '#prefix' => '
', '#suffix' => '
', @@ -160,7 +153,7 @@ public function alterForm(&$form) { // Token support. if (\Drupal::moduleHandler()->moduleExists('token')) { $form['tokens'] = array( - '#title' => t('Tokens'), + '#title' => $this->t('Tokens'), '#type' => 'container', '#states' => array( 'invisible' => array( @@ -186,11 +179,11 @@ public function defaultConfiguration() { $config['lb-col'] = \Drupal::config('ds.settings')->get('ft-show-colon'); $wrappers = array( - 'lb' => array('title' => t('Label')), - 'lbw' => array('title' => t('Label wrapper')), - 'ow' => array('title' => t('Outer wrapper')), - 'fis' => array('title' => t('Field items')), - 'fi' => array('title' => t('Field item')), + 'lb' => array('title' => $this->t('Label')), + 'lbw' => array('title' => $this->t('Label wrapper')), + 'ow' => array('title' => $this->t('Outer wrapper')), + 'fis' => array('title' => $this->t('Field items')), + 'fi' => array('title' => $this->t('Field item')), ); foreach ($wrappers as $wrapper_key => $value) { $config[$wrapper_key] = FALSE; @@ -217,10 +210,10 @@ public function massageRenderValues(&$field_settings, $values) { } $wrappers = array( - 'lbw' => t('Label wrapper'), - 'ow' => t('Wrapper'), - 'fis' => t('Field items'), - 'fi' => t('Field item') + 'lbw' => $this->t('Label wrapper'), + 'ow' => $this->t('Wrapper'), + 'fis' => $this->t('Field items'), + 'fi' => $this->t('Field item'), ); foreach ($wrappers as $wrapper_key => $title) { @@ -240,9 +233,9 @@ public function massageRenderValues(&$field_settings, $values) { // Default attributes. $field_settings[$wrapper_key . '-def-at'] = !(empty($values[$wrapper_key . '-def-at'])) ? TRUE : FALSE; // Token replacement. - /** @var EntityInterface $entity */ + /* @var \Drupal\Core\Entity\EntityInterface $entity */ if ($entity = $this->getEntity()) { - // Tokens + // Tokens. $apply_to = array( 'prefix', $wrapper_key . '-el', @@ -264,4 +257,5 @@ public function massageRenderValues(&$field_settings, $values) { } } } + } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/Minimal.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/Minimal.php index 44133fea03..4b812f4b84 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/Minimal.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplate/Minimal.php @@ -1,10 +1,5 @@ 'textfield', - '#title' => t('Label'), + '#title' => $this->t('Label'), '#size' => '10', '#default_value' => $config['lb'], ); diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplatePluginManager.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplatePluginManager.php index 73669cd6a1..afd6daeb7e 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplatePluginManager.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsFieldTemplatePluginManager.php @@ -1,10 +1,5 @@ '', 'classes' => [ 'layout_class' => [], - ] + ], ]; } @@ -42,7 +37,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $configuration = $this->getConfiguration(); $regions = $this->getRegionDefinitions(); - // Add wrappers + // Add wrappers. $wrapper_options = array( 'div' => 'Div', 'span' => 'Span', @@ -51,13 +46,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta 'header' => 'Header', 'footer' => 'Footer', 'aside' => 'Aside', - 'figure' => 'Figure' + 'figure' => 'Figure', ); $form['region_wrapper'] = array( '#group' => 'additional_settings', '#type' => 'details', - '#title' => t('Custom wrappers'), - '#description' => t('Choose a wrapper. All Display Suite layouts support this option.'), + '#title' => $this->t('Custom wrappers'), + '#description' => $this->t('Choose a wrapper. All Display Suite layouts support this option.'), '#tree' => TRUE, ); @@ -65,22 +60,22 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['region_wrapper'][$region_name] = array( '#type' => 'select', '#options' => $wrapper_options, - '#title' => t('Wrapper for @region', array('@region' => $region_definition['label'])), - '#default_value' => !empty($configuration['wrappers'][$region_name]) ? $configuration['wrappers'][$region_name] : 'div', + '#title' => $this->t('Wrapper for @region', array('@region' => $region_definition['label'])), + '#default_value' => !empty($configuration['wrappers'][$region_name]) ? $configuration['wrappers'][$region_name] : 'div', ); } $form['region_wrapper']['outer_wrapper'] = array( '#type' => 'select', '#options' => $wrapper_options, - '#title' => t('Outer wrapper'), + '#title' => $this->t('Outer wrapper'), '#default_value' => $configuration['outer_wrapper'], '#weight' => 10, ); $form['region_wrapper']['attributes'] = array( '#type' => 'textfield', - '#title' => t('Layout attributes'), + '#title' => $this->t('Layout attributes'), '#description' => 'E.g. role|navigation,data-something|some value', '#default_value' => $configuration['attributes'], '#weight' => 11, @@ -89,33 +84,35 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['region_wrapper']['link_attribute'] = array( '#type' => 'select', '#options' => array( - '' => t('No link'), - 'content' => t('Link to content'), - 'custom' => t('Custom'), - 'tokens' => t('Tokens') + '' => $this->t('No link'), + 'content' => $this->t('Link to content'), + 'custom' => $this->t('Custom'), + 'tokens' => $this->t('Tokens'), ), - '#title' => t('Add link'), - '#description' => t('This will add an onclick attribute on the layout wrapper.'), + '#title' => $this->t('Add link'), + '#description' => $this->t('This will add an onclick attribute on the layout wrapper.'), '#default_value' => $configuration['link_attribute'], '#weight' => 12, ); $form['region_wrapper']['link_custom'] = array( '#type' => 'textfield', - '#title' => t('Custom link'), - '#description' => t('You may use tokens for this link if you selected tokens.'), + '#title' => $this->t('Custom link'), + '#description' => $this->t('You may use tokens for this link if you selected tokens.'), '#default_value' => $configuration['link_custom'], '#weight' => 13, '#states' => array( - 'visible' => array(array( - ':input[name="layout_configuration[region_wrapper][link_attribute]"]' => array(array("value" => "tokens"), array("value" => "custom")), - )), + 'visible' => array( + array( + ':input[name="layout_configuration[region_wrapper][link_attribute]"]' => array(array("value" => "tokens"), array("value" => "custom")), + ), + ), ), ); if (\Drupal::moduleHandler()->moduleExists('token')) { $form['region_wrapper']['tokens'] = array( - '#title' => t('Tokens'), + '#title' => $this->t('Tokens'), '#type' => 'container', '#weight' => 14, '#states' => array( @@ -136,7 +133,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['ds_classes'] = array( '#group' => 'additional_settings', '#type' => 'details', - '#title' => t('Custom classes'), + '#title' => $this->t('Custom classes'), '#tree' => TRUE, '#collapsible' => TRUE, '#collapsed' => TRUE, @@ -150,7 +147,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#type' => 'select', '#multiple' => TRUE, '#options' => $classes, - '#title' => t('Class for layout'), + '#title' => $this->t('Class for layout'), '#default_value' => !empty($configuration['classes']['layout_class']) ? $configuration['classes']['layout_class'] : [], ); @@ -159,7 +156,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#type' => 'select', '#multiple' => TRUE, '#options' => $classes, - '#title' => t('Class for @region', array('@region' => $region_definition['label'])), + '#title' => $this->t('Class for @region', array('@region' => $region_definition['label'])), '#default_value' => isset($configuration['classes'][$region_name]) ? $configuration['classes'][$region_name] : [], ); } @@ -175,7 +172,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $url = Url::fromRoute('ds.classes'); $destination = \Drupal::destination()->getAsArray(); $url->setOption('query', $destination); - $form['ds_classes']['info'] = array('#markup' => '

' . t('You have not defined any CSS classes which can be used on regions.') . '

' . \Drupal::l(t('Manage region and field CSS classes'), $url) . '

'); } + $form['ds_classes']['info'] = array('#markup' => '

' . $this->t('You have not defined any CSS classes which can be used on regions.') . '

' . \Drupal::l(t('Manage region and field CSS classes'), $url) . '

'); + } else { $form['ds_classes']['#access'] = FALSE; } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/DsPluginManager.php b/profiles/cr/modules/contrib/ds/src/Plugin/DsPluginManager.php index 7ed0bdf84a..3f27b02fb4 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/DsPluginManager.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/DsPluginManager.php @@ -1,10 +1,5 @@ _entity; $entity->view = $this->view; - /** @var $entity EntityInterface */ + /* @var $entity \Drupal\Core\Entity\EntityInterface */ $entity_id = $entity->id(); $langcode = $this->getLangcode($row); @@ -72,7 +66,7 @@ protected function dsPreRender(array $result, $translation = FALSE) { if ($this->view->rowPlugin->options['advanced_fieldset']['advanced']) { $modules = \Drupal::moduleHandler()->getImplementations('ds_views_row_render_entity'); foreach ($modules as $module) { - if ($content = \Drupal::moduleHandler()->invoke($module, 'ds_views_row_render_entity', array($entity, $view_mode))) { + if ($content = \Drupal::moduleHandler()->invoke($module, 'ds_views_row_render_entity', array($entity, $view_mode))) { if (!$translation) { $this->build[$entity_id] = $content; } diff --git a/profiles/cr/modules/contrib/ds/src/Plugin/views/Entity/Render/TranslationLanguageRenderer.php b/profiles/cr/modules/contrib/ds/src/Plugin/views/Entity/Render/TranslationLanguageRenderer.php index 5581957f6c..d14d8a51f7 100644 --- a/profiles/cr/modules/contrib/ds/src/Plugin/views/Entity/Render/TranslationLanguageRenderer.php +++ b/profiles/cr/modules/contrib/ds/src/Plugin/views/Entity/Render/TranslationLanguageRenderer.php @@ -1,10 +1,5 @@ entityType == 'node' && \Drupal::moduleHandler()->moduleExists('ds_switch_view_mode')) { $form['switch_fieldset'] = array( '#type' => 'details', - '#title' => t('Use view mode of display settings'), + '#title' => $this->t('Use view mode of display settings'), '#open' => $this->options['switch_fieldset']['switch'], - ); + ); $form['switch_fieldset']['switch'] = array( '#type' => 'checkbox', - '#title' => t('Use view mode of display settings'), + '#title' => $this->t('Use view mode of display settings'), '#default_value' => $this->options['switch_fieldset']['switch'], - '#description' => t('Use the alternative view mode selected in the display settings tab.') + '#description' => $this->t('Use the alternative view mode selected in the display settings tab.'), ); } // Alternating view modes. $form['alternating_fieldset'] = array( '#type' => 'details', - '#title' => t('Alternating view mode'), + '#title' => $this->t('Alternating view mode'), '#open' => $this->options['alternating_fieldset']['alternating'], ); $form['alternating_fieldset']['alternating'] = array( '#type' => 'checkbox', - '#title' => t('Use the changing view mode selector'), + '#title' => $this->t('Use the changing view mode selector'), '#default_value' => $this->options['alternating_fieldset']['alternating'], ); $form['alternating_fieldset']['allpages'] = array( '#type' => 'checkbox', - '#title' => t('Use this configuration on every page. Otherwhise the default view mode is used as soon you browse away from the first page of this view.'), + '#title' => $this->t('Use this configuration on every page. Otherwhise the default view mode is used as soon you browse away from the first page of this view.'), '#default_value' => (isset($this->options['alternating_fieldset']['allpages'])) ? $this->options['alternating_fieldset']['allpages'] : FALSE, ); - $pager = $this->view->display_handler->getPlugin('pager'); $limit = $pager->getItemsPerPage(); if ($limit == 0 || $limit > 20) { $form['alternating_fieldset']['disabled'] = array( - '#markup' => t('This option is disabled because you have unlimited items or listing more than 20 items.'), + '#markup' => $this->t('This option is disabled because you have unlimited items or listing more than 20 items.'), ); $form['alternating_fieldset']['alternating']['#disabled'] = TRUE; $form['alternating_fieldset']['allpages']['#disabled'] = TRUE; @@ -118,10 +112,15 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $a = 0; while ($limit != 0) { $form['alternating_fieldset']['item_' . $a] = [ - '#title' => t('Item @nr', array('@nr' => $i)), + '#title' => $this->t('Item @nr', array('@nr' => $i)), '#type' => 'select', '#default_value' => (isset($this->options['alternating_fieldset']['item_' . $a])) ? $this->options['alternating_fieldset']['item_' . $a] : 'teaser', '#options' => \Drupal::service('entity_display.repository')->getViewModeOptions($this->entityTypeId), + '#states' => array( + 'visible' => array( + ':input[name="row_options[alternating_fieldset][alternating]"]' => array('checked' => TRUE), + ), + ), ]; $limit--; $a++; @@ -129,18 +128,18 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { } } - // Grouping rows + // Grouping rows. $sorts = $this->view->display_handler->getOption('sorts'); $groupable = !empty($sorts) && $this->options['grouping_fieldset']['group']; $form['grouping_fieldset'] = array( '#type' => 'details', - '#title' => t('Group data'), + '#title' => $this->t('Group data'), '#open' => $groupable, ); $form['grouping_fieldset']['group'] = array( '#type' => 'checkbox', - '#title' => t('Group data on a field. The value of this field will be displayed too.'), + '#title' => $this->t('Group data on a field. The value of this field will be displayed too.'), '#default_value' => $groupable, ); @@ -165,19 +164,19 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { } else { $form['grouping_fieldset']['group']['#disabled'] = TRUE; - $form['grouping_fieldset']['group']['#description'] = t('Grouping is disabled because you do not have any sort fields.'); + $form['grouping_fieldset']['group']['#description'] = $this->t('Grouping is disabled because you do not have any sort fields.'); } // Advanced function. $form['advanced_fieldset'] = array( '#type' => 'details', - '#title' => t('Advanced view mode'), + '#title' => $this->t('Advanced view mode'), '#open' => $this->options['advanced_fieldset']['advanced'], ); $form['advanced_fieldset']['advanced'] = array( '#type' => 'checkbox', - '#title' => t('Use the advanced view mode selector'), - '#description' => t('This gives you the opportunity to have full control of a list for really advanced features.
There is no UI for this, you need to create a hook named like this: hook_ds_views_row_render_entity($entity, $view_mode).', array('@VIEWSNAME' => $this->view->storage->id())), + '#title' => $this->t('Use the advanced view mode selector'), + '#description' => $this->t('This gives you the opportunity to have full control of a list for really advanced features.
There is no UI for this, you need to create a hook named like this: hook_ds_views_row_render_entity($entity, $view_mode).', array('@VIEWSNAME' => $this->view->storage->id())), '#default_value' => $this->options['advanced_fieldset']['advanced'], ); } diff --git a/profiles/cr/modules/contrib/ds/src/Routing/RouteSubscriber.php b/profiles/cr/modules/contrib/ds/src/Routing/RouteSubscriber.php index e0c8ccf8c4..93fcb2549e 100644 --- a/profiles/cr/modules/contrib/ds/src/Routing/RouteSubscriber.php +++ b/profiles/cr/modules/contrib/ds/src/Routing/RouteSubscriber.php @@ -1,10 +1,5 @@ $entity_type_id, ), array( - '_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display' + '_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display', ), array( '_admin_route' => TRUE, diff --git a/profiles/cr/modules/contrib/ds/src/Tests/BlockFieldPluginTest.php b/profiles/cr/modules/contrib/ds/src/Tests/BlockFieldPluginTest.php index 673d6246e9..947faffc08 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/BlockFieldPluginTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/BlockFieldPluginTest.php @@ -1,14 +1,11 @@ 'Test block title field', 'id' => 'test_block_title_field', 'entities[node]' => '1', - 'block' => 'views_block:ds_testing-block_1' + 'block' => 'views_block:ds_testing-block_1', ); $this->dsCreateBlockField($edit); @@ -66,27 +77,62 @@ function testBlockFieldTitleOverride() { ); $this->dsSelectLayout(); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); // Create a node. $settings = array('type' => 'article', 'promote' => 1); $node = $this->drupalCreateNode($settings); - - // Look at node and verify the block title is overridden + // Look at node and verify the block title is overridden. $this->drupalGet('node/' . $node->id()); $this->assertRaw('Test block title field', t('Default field label.')); - // Update testing label + // Update testing label. $edit = array( - 'use_block_title' => '1' + 'use_block_title' => '1', ); $this->drupalPostForm('admin/structure/ds/fields/manage_block/test_block_title_field', $edit, t('Save')); $this->assertText(t('The field Test block title field has been saved'), t('Test field label override updated')); - // Look at node and verify the block title is overridden + // Look at node and verify the block title is overridden. $this->drupalGet('node/' . $node->id()); $this->assertRaw('Block title from view', t('Field label from view block display.')); + } + + /** + * Ensure block is not rendered if block disallows access. + */ + function testBlockAccess() { + $block_field_id = Unicode::strtolower($this->randomMachineName()); + $entity_type = 'node'; + + $edit = [ + 'name' => $this->randomString(), + 'id' => $block_field_id, + 'entities[' . $entity_type . ']' => TRUE, + 'block' => 'ds_test_block', + ]; + $this->dsCreateBlockField($edit); + + $fields['fields[dynamic_block_field:' . $entity_type . '-' . $block_field_id . '][region]'] = 'left'; + $this->dsSelectLayout(); + $this->dsConfigureUI($fields); + $settings['type'] = 'article'; + $node = $this->drupalCreateNode($settings); + + // Check block is not visible. + \Drupal::state()->set('ds_test_block__access', FALSE); + $this->drupalGet($node->toUrl()); + $this->assertNoRaw(DsTestBlock::BODY_TEXT); + + // Reset page cache. + $this->resetAll(); + + // Check block is visible. + \Drupal::state()->set('ds_test_block__access', TRUE); + $this->drupalGet($node->toUrl()); + $this->assertRaw(DsTestBlock::BODY_TEXT); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/BlockTest.php b/profiles/cr/modules/contrib/ds/src/Tests/BlockTest.php new file mode 100644 index 0000000000..cb62201963 --- /dev/null +++ b/profiles/cr/modules/contrib/ds/src/Tests/BlockTest.php @@ -0,0 +1,106 @@ +adminUser = $this->drupalCreateUser(array( + 'access content', + 'admin display suite', + 'admin fields', + 'administer blocks', + 'administer block_content display', + )); + $this->drupalLogin($this->adminUser); + } + + /** + * Test adding a block, modifying output. + */ + public function testBlock() { + + // Create basic block type. + $edit = array( + 'label' => 'Basic Block', + 'id' => 'basic', + ); + $this->drupalPostForm('admin/structure/block/block-content/types/add', $edit, t('Save'), array()); + $this->assertText('Custom block type Basic Block has been added.', 'Basic block type added'); + + // Create a basic block. + $edit = array(); + $edit['info[0][value]'] = 'Test Block'; + $edit['body[0][value]'] = $this->randomMachineName(16); + $this->drupalPostForm('block/add/basic', $edit, t('Save'), array()); + $this->assertText('Basic Block Test Block has been created.', 'Basic Block Test Block created'); + + // Place the block. + $instance = array( + 'id' => 'testblock', + 'settings[label]' => $edit['info[0][value]'], + 'region' => 'sidebar_first', + ); + $block = BlockContent::load(1); + $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default'); + $this->drupalPostForm($url, $instance, t('Save block')); + + // Change to a DS layout. + $url = 'admin/structure/block/block-content/manage/basic/display'; + $edit = array('layout' => 'ds_2col'); + $this->drupalPostForm($url, $edit, t('Save'), array()); + + $fields = array( + 'fields[block_description][region]' => 'left', + 'fields[body][region]' => 'right', + ); + $this->dsConfigureUi($fields, 'admin/structure/block/block-content/manage/basic/display'); + + // View the block. + $this->drupalGet(''); + $this->assertText('Test Block', 'Test block found'); + $xpath = $this->xpath('//div[@class="region region-sidebar-first"]/div/div[@class="block-content block-content--type-basic block-content--view-mode-full ds-2col clearfix"]/div[@class="group-left"]/div[@class="field field--name-block-description field--type-ds field--label-hidden field__item"]/h2'); + $this->assertEqual(count($xpath), 1, 'Description in group-left'); + $xpath = $this->xpath('//div[@class="region region-sidebar-first"]/div/div[@class="block-content block-content--type-basic block-content--view-mode-full ds-2col clearfix"]/div[@class="group-right"]/div[@class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"]/p'); + $this->assertEqual(count($xpath), 1, 'Body in group-right'); + } + +} diff --git a/profiles/cr/modules/contrib/ds/src/Tests/CacheTagsTest.php b/profiles/cr/modules/contrib/ds/src/Tests/CacheTagsTest.php index 467f143306..955a8393ea 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/CacheTagsTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/CacheTagsTest.php @@ -1,10 +1,5 @@ 'article', 'promote' => 1); @@ -43,13 +41,14 @@ public function testUserCacheTags() { 'fields[body][label]' => 'above', 'fields[node_submitted_by][region]' => 'header', ); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); $this->drupalGet('node/' . $node->id()); $headers = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue( - strpos($headers,'user:' . $node->getRevisionAuthor()->getOriginalId()), + strpos($headers, 'user:' . $node->getRevisionAuthor()->getOriginalId()), 'User cache tag found' ); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/CommentTest.php b/profiles/cr/modules/contrib/ds/src/Tests/CommentTest.php index 0af4c4543d..caf9b7c728 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/CommentTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/CommentTest.php @@ -1,10 +1,5 @@ 'left', 'fields[comment_body][region]' => 'left', ); - $this->dsConfigureUI($fields, 'admin/structure/comment/manage/comment/display'); + $this->dsConfigureUi($fields, 'admin/structure/comment/manage/comment/display'); - // Post comment + // Post comment. $comment1 = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName()); $this->assertRaw($comment1->comment_body->value, 'Comment1 found.'); - // Post comment + // Post comment. $comment2 = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName()); $this->assertRaw($comment2->comment_body->value, 'Comment2 found.'); - // Verify there are no double ID's + // Verify there are no double ID's. $xpath = $this->xpath('//a[@id="comment-1"]'); $this->assertEqual(count($xpath), 1, '1 ID found named comment-1'); + + // Test that hidden fields aren't exposed in the config. + $this->dsSelectLayout(); + + $fields = array( + 'fields[comment][region]' => 'hidden', + ); + $this->dsConfigureUi($fields); + + $display = entity_get_display('node', 'article', 'default'); + $content = $display->get('content'); + $hidden = $display->get('hidden'); + + $this->assertFalse(isset($content['comment']), 'Comment is not part of the content region'); + $this->assertTrue(isset($hidden['comment']), 'Comment is part of the hidden region'); } /** - * Test User custom display on a comment on a node + * Test User custom display on a comment on a node. */ public function testCommentUser() { // Create a node. $settings = array('type' => 'article', 'promote' => 1); $node = $this->drupalCreateNode($settings); - // User compact display settings + // User compact display settings. $this->dsSelectLayout(array(), array(), 'admin/config/people/accounts/display'); $fields = array( 'fields[username][region]' => 'left', 'fields[member_for][region]' => 'left', ); - $this->dsConfigureUI($fields, 'admin/config/people/accounts/display'); + $this->dsConfigureUi($fields, 'admin/config/people/accounts/display'); - // Comment display settings + // Comment display settings. $this->dsSelectLayout(array(), array(), 'admin/structure/comment/manage/comment/display'); $fields = array( @@ -126,13 +144,14 @@ public function testCommentUser() { 'fields[comment_user][region]' => 'left', 'fields[comment_body][region]' => 'left', ); - $this->dsConfigureUI($fields, 'admin/structure/comment/manage/comment/display'); + $this->dsConfigureUi($fields, 'admin/structure/comment/manage/comment/display'); - // Post comment + // Post comment. $comment = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName()); $this->assertRaw($comment->comment_body->value, 'Comment found.'); $this->assertRaw('Member for', 'Comment Member for found.'); $xpath = $this->xpath('//div[@class="field field--name-comment-user field--type-ds field--label-hidden field__item"]/div/div/div[@class="field field--name-username field--type-ds field--label-hidden field__item"]'); $this->assertEqual(count($xpath), 1, 'Username'); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/DsTestTrait.php b/profiles/cr/modules/contrib/ds/src/Tests/DsTestTrait.php index 151f7121f2..9ee47cda67 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/DsTestTrait.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/DsTestTrait.php @@ -1,10 +1,5 @@ "class_name_1\nclass_name_2|Friendly name" + 'regions' => "class_name_1\nclass_name_2|Friendly name", ); $this->drupalPostForm('admin/structure/ds/classes', $edit, t('Save configuration')); @@ -67,7 +62,7 @@ function dsSelectClasses($edit = array(), $url = 'admin/structure/types/manage/a /** * Configure Field UI. */ - function dsConfigureUI($edit, $url = 'admin/structure/types/manage/article/display') { + function dsConfigureUi($edit, $url = 'admin/structure/types/manage/article/display') { $this->drupalPostForm($url, $edit, t('Save')); } @@ -122,14 +117,16 @@ function dsCreateTokenField($edit = array(), $url = 'admin/structure/ds/fields/m ); $this->drupalPostForm($url, $edit, t('Save')); - $this->assertText(t('The field ' . $edit['name'] . ' has been saved'), t('@name field has been saved', array('@name' => $edit['name']))); + $this->assertText(t('The field @name has been saved', array('@name' => $edit['name'])), t('@name field has been saved', array('@name' => $edit['name']))); } /** * Create a block field. * - * @param $edit + * @param array $edit * An optional array of field properties. + * @param string $url + * The URL of the manage block page. */ function dsCreateBlockField($edit = array(), $url = 'admin/structure/ds/fields/manage_block') { $edit += array( @@ -140,13 +137,13 @@ function dsCreateBlockField($edit = array(), $url = 'admin/structure/ds/fields/m ); $this->drupalPostForm($url, $edit, t('Save')); - $this->assertText(t('The field ' . $edit['name'] . ' has been saved'), t('@name field has been saved', array('@name' => $edit['name']))); + $this->assertText(t('The field @name has been saved', array('@name' => $edit['name'])), t('@name field has been saved', array('@name' => $edit['name']))); } /** * Utility function to setup for all kinds of tests. * - * @param $label + * @param string $label * How the body label must be set. */ function entitiesTestSetup($label = 'above') { @@ -179,7 +176,7 @@ function entitiesTestSetup($label = 'above') { 'fields[body][label]' => $label, 'fields[node_submitted_by][region]' => 'header', ); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); return $node; } @@ -226,4 +223,5 @@ function entitiesSetLabelClass($label, $field_name, $text = '', $class = '', $sh } $this->dsEditFormatterSettings($edit); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/DynamicFieldPluginTest.php b/profiles/cr/modules/contrib/ds/src/Tests/DynamicFieldPluginTest.php index 462ecbfd8b..12220d1d88 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/DynamicFieldPluginTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/DynamicFieldPluginTest.php @@ -1,10 +1,5 @@ 'Test field', @@ -42,7 +37,7 @@ function testDSFields() { $this->drupalGet('admin/config/people/accounts/display'); $this->assertNoRaw('fields[dynamic_token_field:node-test_field][weight]', t('Test field not found on user.')); - // Update testing label + // Update testing label. $edit = array( 'name' => 'Test field 2', ); @@ -105,7 +100,7 @@ function testDSFields() { $this->drupalGet('admin/config/people/accounts/display'); $this->assertNoRaw('fields[dynamic_block_field:node-test_block_field][weight]', t('Test block field not found on user.')); - // Update testing label + // Update testing label. $edit = array( 'name' => 'Test block field 2', ); @@ -120,7 +115,7 @@ function testDSFields() { $this->drupalGet('admin/structure/types/manage/article/display'); $this->assertNoRaw('fields[dynamic_block_field:node-test_block_field][weight]', t('Test block field not found on node article.')); - // Create a configurable block field + // Create a configurable block field. $edit = array( 'name' => 'Configurable block', 'id' => 'test_block_configurable', @@ -130,7 +125,7 @@ function testDSFields() { $this->dsCreateBlockField($edit); - // Try to set the depth to 3, to ensure we can save the block + // Try to set the depth to 3, to ensure we can save the block. $edit = array( 'depth' => '3', ); @@ -144,27 +139,28 @@ function testDSFields() { $this->drupalGet('admin/config/people/accounts/display'); $this->assertNoRaw('fields[dynamic_block_field:node-test_block_configurable][weight]', t('Test configurable block field not found on user.')); - // Add block to display + // Add block to display. $fields = array( 'fields[dynamic_block_field:node-test_block_configurable][region]' => 'left', ); - $this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display'); + $this->dsConfigureUi($fields, 'admin/structure/types/manage/article/display'); - /** @var \Drupal\node\NodeInterface $node */ + /* @var \Drupal\node\NodeInterface $node */ $node = $this->entitiesTestSetup(); - // Look at node and verify the menu is visible + // Look at node and verify the menu is visible. $this->drupalGet('node/' . $node->id()); $this->assertRaw('Add content', t('Tools menu found.')); - // Try to set the depth to 3, to ensure we can save the block + // Try to set the depth to 3, to ensure we can save the block. $edit = array( 'level' => '2', ); $this->drupalPostForm('admin/structure/ds/fields/manage_block/test_block_configurable/block_config', $edit, t('Save')); - // Look at node and verify the menu is not visible + // Look at node and verify the menu is not visible. $this->drupalGet('node/' . $node->id()); $this->assertNoRaw('Add content', t('Tools menu not found.')); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/EntitiesTest.php b/profiles/cr/modules/contrib/ds/src/Tests/EntitiesTest.php index 6722f00db4..611480ed13 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/EntitiesTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/EntitiesTest.php @@ -1,10 +1,5 @@ getEditable('ds.settings') ->set('field_template', TRUE) ->save(); @@ -36,9 +40,9 @@ protected function setup() { /** * Test basic node display fields. */ - function testDSNodeEntity() { + public function testDsNodeEntity() { - /** @var \Drupal\node\NodeInterface $node */ + /* @var \Drupal\node\NodeInterface $node */ $node = $this->entitiesTestSetup(); // Test theme_hook_suggestions in ds_entity_variables(). @@ -50,13 +54,13 @@ function testDSNodeEntity() { 'ds_2col_stacked__node_full', 'ds_2col_stacked__node_article', 'ds_2col_stacked__node_article_full', - 'ds_2col_stacked__node__1' + 'ds_2col_stacked__node__1', ); $this->assertEqual($hook_suggestions, $expected_hook_suggestions); // Look at node and verify token and block field. $this->drupalGet('node/' . $node->id()); - $this->assertRaw('view-mode-full', 'Template file found (in full view mode)'); + $this->assertRaw('node--view-mode-full', 'Template file found (in full view mode)'); $this->assertRaw('
', t('Token field found')); $xpath = $this->xpath('//div[@class="field field--name-dynamic-token-fieldnode-token-field field--type-ds field--label-hidden field__item"]'); $this->assertEqual((string) $xpath[0]->p, $node->getTitle(), 'Token field content found'); @@ -85,12 +89,12 @@ function testDSNodeEntity() { 'fields[body][region]' => 'right', 'fields[node_links][region]' => 'right', ); - $this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/teaser'); + $this->dsConfigureUi($fields, 'admin/structure/types/manage/article/display/teaser'); // Switch view mode on full node page. $edit = array('ds_switch' => 'teaser'); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); - $this->assertRaw('view-mode-teaser', 'Switched to teaser mode'); + $this->assertRaw('node--view-mode-teaser', 'Switched to teaser mode'); $this->assertRaw('group-left', 'Template found (region left)'); $this->assertRaw('group-right', 'Template found (region right)'); $this->assertNoRaw('group-header', 'Template found (no region header)'); @@ -98,7 +102,7 @@ function testDSNodeEntity() { $edit = array('ds_switch' => ''); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); - $this->assertRaw('view-mode-full', 'Switched to full mode again'); + $this->assertRaw('node--view-mode-full', 'Switched to full mode again'); // Test all options of a block field. $block = array( @@ -111,20 +115,20 @@ function testDSNodeEntity() { 'fields[body][region]' => 'hidden', 'fields[node_links][region]' => 'hidden', ); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); $this->drupalGet('node/' . $node->id()); $this->assertRaw('field--name-dynamic-block-fieldnode-test-block-field'); - // Test revisions. Enable the revision view mode + // Test revisions. Enable the revision view mode. $edit = array( - 'display_modes_custom[revision]' => '1' + 'display_modes_custom[revision]' => '1', ); $this->drupalPostForm('admin/structure/types/manage/article/display', $edit, t('Save')); - // Enable the override revision mode and configure it + // Enable the override revision mode and configure it. $edit = array( 'fs3[override_node_revision]' => TRUE, - 'fs3[override_node_revision_view_mode]' => 'revision' + 'fs3[override_node_revision_view_mode]' => 'revision', ); $this->drupalPostForm('admin/structure/ds/settings', $edit, t('Save configuration')); @@ -144,7 +148,7 @@ function testDSNodeEntity() { 'fields[node_link][region]' => 'right', 'fields[node_author][region]' => 'right', ); - $this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display/revision'); + $this->dsConfigureUi($edit, 'admin/structure/types/manage/article/display/revision'); // Create revision of the node. $edit = array( @@ -153,7 +157,7 @@ function testDSNodeEntity() { ); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); - // Verify the revision is created + // Verify the revision is created. $this->drupalGet('node/' . $node->id() . '/revisions'); $this->assertText('Test revision'); @@ -176,7 +180,7 @@ function testDSNodeEntity() { 'fields[field_tags][region]' => 'right', 'fields[field_tags][type]' => 'entity_reference_label', ); - $this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display'); + $this->dsConfigureUi($edit, 'admin/structure/types/manage/article/display'); $this->drupalGet('node/' . $node->id()); $this->assertText('Tag 1'); $this->assertText('Tag 2'); @@ -188,11 +192,12 @@ function testDSNodeEntity() { $this->assertText('Tag 1'); $this->assertNoText('Tag 2'); - // Test \Drupal\Component\Utility\Html::escape() on ds_render_field() with the title field. + // Test \Drupal\Component\Utility\Html::escape() on ds_render_field() with + // the title field. $edit = array( 'fields[node_title][region]' => 'right', ); - $this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display'); + $this->dsConfigureUi($edit, 'admin/structure/types/manage/article/display'); $edit = array( 'title[0][value]' => 'Hi, I am an article ', ); diff --git a/profiles/cr/modules/contrib/ds/src/Tests/ExportablesTest.php b/profiles/cr/modules/contrib/ds/src/Tests/ExportablesTest.php index 4004ed887f..a6125449c3 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/ExportablesTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/ExportablesTest.php @@ -1,10 +1,5 @@ delete(); \Drupal::service('module_installer')->install(array('ds_exportables_test')); } - // Test layout and field settings configuration. - function testDSExportablesLayoutFieldsettings() { + /** + * Test layout and field settings configuration. + */ + public function testDsExportablesLayoutFieldsettings() { $this->dsExportablesSetup(); // Look for default custom field. @@ -38,7 +35,7 @@ function testDSExportablesLayoutFieldsettings() { $settings = array( 'type' => 'article', - 'title' => 'Exportable' + 'title' => 'Exportable', ); $node = $this->drupalCreateNode($settings); $this->drupalGet('node/' . $node->id()); @@ -77,7 +74,7 @@ function testDSExportablesLayoutFieldsettings() { ); $this->dsSelectLayout($layout, $assert); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); $this->drupalGet('node/' . $node->id()); $this->assertRaw('group-left', 'Left region found'); diff --git a/profiles/cr/modules/contrib/ds/src/Tests/FastTestBase.php b/profiles/cr/modules/contrib/ds/src/Tests/FastTestBase.php index 3fc9d0177c..74b69f50d3 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/FastTestBase.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/FastTestBase.php @@ -1,10 +1,5 @@ drupalLogin($this->adminUser); @@ -112,8 +120,16 @@ protected function setUp() { $this->fieldName = 'field_' . $this->fieldNameInput; // Create Article node type. - $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article', 'revision' => TRUE)); - $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page', 'revision' => TRUE)); + $this->drupalCreateContentType(array( + 'type' => 'article', + 'name' => 'Article', + 'revision' => TRUE, + )); + $this->drupalCreateContentType(array( + 'type' => 'page', + 'name' => 'Page', + 'revision' => TRUE, + )); // Create a vocabulary named "Tags". $this->vocabulary = Vocabulary::create(array( @@ -160,4 +176,5 @@ protected function assertTrimEqual($first, $second, $message = '', $group = 'Oth return $this->assertEqual(trim($first), trim($second), $message, $group); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/FieldGroupTest.php b/profiles/cr/modules/contrib/ds/src/Tests/FieldGroupTest.php index d60a6d8eca..e871673325 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/FieldGroupTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/FieldGroupTest.php @@ -1,10 +1,5 @@ 'article', 'promote' => 1); - /** @var \Drupal\node\NodeInterface $node */ + /* @var \Drupal\node\NodeInterface $node */ $node = $this->drupalCreateNode($settings); // Configure layout. @@ -56,19 +51,18 @@ function testFieldPlugin() { 'fields[' . $group->group_name . '][region]' => 'right', 'fields[body][region]' => 'right', ); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); $fields = array( 'fields[body][parent]' => $group->group_name, ); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); - //$groups = field_group_info_groups('node', 'article', 'view', 'default', TRUE); $this->drupalGet('node/' . $node->id()); // Test group ids and classes. - $this->assertFieldByXPath("//div[contains(@class, 'group-right')]/div[contains(@id, 'wrapper-id')]", NULL, t('Wrapper id set on wrapper div')); - $this->assertFieldByXPath("//div[contains(@class, 'group-right')]/div[contains(@class, 'test-class')]", NULL, t('Test class set on wrapper div') . 'class="' . $group->group_name . ' test-class'); + $this->assertFieldByXPath("//div[contains(@class, 'group-right')]/div[contains(@id, 'wrapper-id')]", NULL, 'Wrapper id set on wrapper div'); + $this->assertFieldByXPath("//div[contains(@class, 'group-right')]/div[contains(@class, 'test-class')]", NULL, 'Test class set on wrapper div' . 'class="' . $group->group_name . ' test-class'); } } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/FieldPermissionsTest.php b/profiles/cr/modules/contrib/ds/src/Tests/FieldPermissionsTest.php index 823e655400..16a1f49371 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/FieldPermissionsTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/FieldPermissionsTest.php @@ -1,10 +1,5 @@ 'right', @@ -32,7 +41,7 @@ function testFieldPermissions() { \Drupal::moduleHandler()->resetImplementations(); $this->dsSelectLayout(); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); // Create a node. $settings = array('type' => 'article'); @@ -51,4 +60,5 @@ function testFieldPermissions() { $this->assertRaw('group-left', 'Template found (region left)'); $this->assertText('Test field plugin on node ' . $node->id(), 'Test field plugin found'); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/FieldPluginTest.php b/profiles/cr/modules/contrib/ds/src/Tests/FieldPluginTest.php index ed2c65eac0..b9cf807dbd 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/FieldPluginTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/FieldPluginTest.php @@ -1,14 +1,9 @@ dsSelectLayout(); @@ -44,6 +39,7 @@ function testFieldPlugin() { 'fields[node_links][region]' => 'left', 'fields[body][region]' => 'right', 'fields[test_field][region]' => 'right', + 'fields[test_multiple_field][region]' => 'right', 'fields[test_field_empty_string][region]' => 'right', 'fields[test_field_empty_string][label]' => 'inline', 'fields[test_field_false][region]' => 'right', @@ -61,7 +57,7 @@ function testFieldPlugin() { ); $this->dsSelectLayout(); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); // Create a node. $settings = array('type' => 'article'); @@ -71,6 +67,8 @@ function testFieldPlugin() { $this->assertRaw('group-left', 'Template found (region left)'); $this->assertRaw('group-right', 'Template found (region right)'); $this->assertText('Test field plugin on node ' . $node->id(), 'Test field plugin found'); + $this->assertText('Test row one of multiple field plugin on node ' . $node->id(), 'First item of multiple field plugin found'); + $this->assertText('Test row two of multiple field plugin on node ' . $node->id(), 'Second item of multiple field plugin found'); $this->assertText('Test field plugin that returns an empty string', 'Test field plugin that returns an empty string is visible.'); $this->assertNoText('Test field plugin that returns FALSE', 'Test field plugin that returns FALSE is not visible.'); $this->assertNoText('Test field plugin that returns NULL', 'Test field plugin that returns NULL is not visible.'); diff --git a/profiles/cr/modules/contrib/ds/src/Tests/FieldTemplateTest.php b/profiles/cr/modules/contrib/ds/src/Tests/FieldTemplateTest.php index 4c9b36427b..9ddfaf41ee 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/FieldTemplateTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/FieldTemplateTest.php @@ -1,10 +1,5 @@ getEditable('ds.settings') ->set('field_template', TRUE) ->save(); @@ -31,14 +26,12 @@ protected function setup() { /** * Tests on field templates. */ - function testDSFieldTemplate() { + public function testDsFieldTemplate() { // Get a node. $node = $this->entitiesTestSetup('hidden'); $body_field = $node->body->value; - // ------------------------- // Default theming function. - // ------------------------- $this->drupalGet('node/' . $node->id()); $xpath = $this->xpath('//div[@class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"]'); $this->assertTrimEqual($xpath[0]->p, $body_field); @@ -66,20 +59,19 @@ function testDSFieldTemplate() { /** * Tests on field templates. */ - function testDSFieldTemplate2() { + public function testDsFieldTemplate2() { // Get a node. $node = $this->entitiesTestSetup('hidden'); $body_field = $node->body->value; - // ----------------------- // Reset theming function. - // ----------------------- $edit = array( 'fs1[ft-default]' => 'reset', ); $this->drupalPostForm('admin/structure/ds/settings', $edit, t('Save configuration')); - // As long as we don't change anything in the UI, the default template will be used + // As long as we don't change anything in the UI, the default template will + // be used. $this->drupalGet('node/' . $node->id()); $xpath = $this->xpath('//div[@class="group-right"]'); $this->assertTrimEqual($xpath[0]->div->p, $body_field); @@ -116,7 +108,7 @@ function testDSFieldTemplate2() { 'fs1[ft-show-colon]' => 'reset', ); $this->drupalPostForm('admin/structure/ds/settings', $edit, t('Save configuration')); - // Clear node cache to get the colon + // Clear node cache to get the colon. $tags = $node->getCacheTags(); Cache::invalidateTags($tags); @@ -135,16 +127,12 @@ function testDSFieldTemplate2() { /** * Tests on field templates. */ - function testDSFieldTemplate3() { + public function testDsFieldTemplate3() { // Get a node. $node = $this->entitiesTestSetup('hidden'); $body_field = $node->body->value; - // ---------------------- - // Custom field function. - // ---------------------- - - // With outer wrapper. + // Custom field function with outer wrapper. $edit = array( 'fields[body][settings_edit_form][third_party_settings][ds][ft][id]' => 'expert', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1', @@ -153,7 +141,8 @@ function testDSFieldTemplate3() { $this->dsEditFormatterSettings($edit); drupal_flush_all_caches(); - // As long as we don't change anything in the UI, the default template will be used + // As long as we don't change anything in the UI, the default template will + // be used. $this->drupalGet('node/' . $node->id()); $xpath = $this->xpath('//div[@class="group-right"]'); $this->assertTrimEqual($xpath[0]->div->p, $body_field); @@ -162,7 +151,7 @@ function testDSFieldTemplate3() { $edit = array( 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div', - 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class' + 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class', ); $this->dsEditFormatterSettings($edit); drupal_flush_all_caches(); @@ -175,7 +164,7 @@ function testDSFieldTemplate3() { $edit = array( 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'span', - 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class-2' + 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class-2', ); $this->dsEditFormatterSettings($edit); drupal_flush_all_caches(); @@ -188,7 +177,7 @@ function testDSFieldTemplate3() { /** * Tests on field templates. */ - function testDSFieldTemplate4() { + public function testDsFieldTemplate4() { // Get a node. $node = $this->entitiesTestSetup('hidden'); @@ -200,7 +189,7 @@ function testDSFieldTemplate4() { 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1', - 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'div' + 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'div', ); $this->dsEditFormatterSettings($edit); @@ -215,7 +204,7 @@ function testDSFieldTemplate4() { 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'div', - 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class' + 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class', ); $this->dsEditFormatterSettings($edit); $this->drupalGet('node/' . $node->id()); @@ -228,7 +217,7 @@ function testDSFieldTemplate4() { 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'span', - 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class' + 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class', ); $this->dsEditFormatterSettings($edit); $this->drupalGet('node/' . $node->id()); @@ -242,7 +231,7 @@ function testDSFieldTemplate4() { 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'span', - 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class' + 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class', ); $this->dsEditFormatterSettings($edit); $this->drupalGet('node/' . $node->id()); @@ -256,7 +245,7 @@ function testDSFieldTemplate4() { 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'span', - 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class-2' + 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class-2', ); $this->dsEditFormatterSettings($edit); $this->drupalGet('node/' . $node->id()); @@ -267,7 +256,7 @@ function testDSFieldTemplate4() { /** * Tests on field templates. */ - function testDSFieldTemplate5() { + public function testDsFieldTemplate5() { // Get a node. $node = $this->entitiesTestSetup('hidden'); $body_field = $node->body->value; @@ -428,7 +417,8 @@ function testDSFieldTemplate5() { $this->assertTrimEqual($xpath[0]->p, $body_field); // Test default classes on outer wrapper. - // @todo figure out a way to actually test this as the default cases don't have classes anymore + // @todo figure out a way to actually test this as the default cases don't + // have classes anymore. $edit = array( 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div', @@ -473,7 +463,7 @@ function testDSFieldTemplate5() { /** * Tests XSS on field templates. */ - function testDSFieldTemplateXSS() { + public function testDsFieldTemplateXss() { // Get a node. $node = $this->entitiesTestSetup('hidden'); @@ -483,7 +473,7 @@ function testDSFieldTemplateXSS() { ); $this->dsEditFormatterSettings($edit); - // Inject XSS everywhere and see if it brakes + // Inject XSS everywhere and see if it brakes. $edit = array( 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][prefix]' => '
', 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][suffix]' => '
', @@ -506,7 +496,7 @@ function testDSFieldTemplateXSS() { $this->drupalGet('node/' . $node->id()); $this->assertNoRaw('', 'Harmful tags are escaped when viewing a ds field template.'); - // Verify the prefix/suffix is filtered but not escaped + // Verify the prefix/suffix is filtered but not escaped. $xpath = $this->xpath('//div[@class="not-stripped"]'); $this->assertEqual(count($xpath), 1, 'Stripped but not escaped'); } @@ -514,7 +504,7 @@ function testDSFieldTemplateXSS() { /** * Tests multiple field items. */ - function testDSMultipleFieldItems() { + public function testDsMultipleFieldItems() { // Get a node. $node = $this->entitiesTestSetup('hidden'); @@ -522,9 +512,9 @@ function testDSMultipleFieldItems() { 'fields[field_tags][region]' => 'right', 'fields[field_tags][type]' => 'entity_reference_label', ); - $this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display'); + $this->dsConfigureUi($edit, 'admin/structure/types/manage/article/display'); - // Set expert field on + // Set expert field on. $edit = array( 'fields[field_tags][settings_edit_form][third_party_settings][ds][ft][id]' => 'expert', 'fields[field_tags][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1', @@ -535,23 +525,23 @@ function testDSMultipleFieldItems() { $this->dsEditFormatterSettings($edit, 'field_tags'); drupal_flush_all_caches(); - // Add multiple tags + // Add multiple tags. $edit = array( 'field_tags[0][target_id]' => 'Tag 1', 'field_tags[1][target_id]' => 'Tag 2', ); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); - // Count the found tags + // Count the found tags. $this->drupalGet('node/' . $node->id()); $xpath = $this->xpath('//div[@class="group-right"]/div[@class="tags"]/div[@class="tag"]'); $this->assertEqual(count($xpath), 2, '2 tags found'); } /** - * Tests minimal template functionality + * Tests minimal template functionality. */ - function testFieldTemplateMinimal() { + public function testFieldTemplateMinimal() { // Get a node. $node = $this->entitiesTestSetup('hidden'); $body_field = $node->body->value; @@ -559,7 +549,7 @@ function testFieldTemplateMinimal() { $edit = array( 'fields[body][region]' => 'right', ); - $this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display'); + $this->dsConfigureUi($edit, 'admin/structure/types/manage/article/display'); // Set minimal template on. $edit = array( @@ -572,10 +562,10 @@ function testFieldTemplateMinimal() { $xpath = $this->xpath('//div[@class="group-right"]/div[@class="field field-name-body"]'); $this->assertTrimEqual($xpath[0]->p, $body_field); - // Choose field classes + // Choose field classes. $classes = array( 'test_field_class', - '[node:nid]' + '[node:nid]', ); $edit = array( 'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][classes][]' => $classes, @@ -588,4 +578,5 @@ function testFieldTemplateMinimal() { $xpath = $this->xpath('//div[@class="group-right"]/div[@class="' . $classes . '"]'); $this->assertTrimEqual($xpath[0]->p, $body_field); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/HiddenRegionTest.php b/profiles/cr/modules/contrib/ds/src/Tests/HiddenRegionTest.php index 9c9562e475..4ff1686675 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/HiddenRegionTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/HiddenRegionTest.php @@ -1,10 +1,5 @@ TRUE + 'fs3[hidden_region]' => TRUE, ); $this->drupalPostForm('admin/structure/ds/settings', $edit, t('Save configuration')); @@ -27,26 +25,27 @@ function testHiddenRegion() { $settings = array('type' => 'article'); $node = $this->drupalCreateNode($settings); - // Configure fields + // Configure fields. $fields = array( 'fields[body][region]' => 'right', 'fields[test_field][region]' => 'ds_hidden', ); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); - // Test field not printed + // Test field not printed. $this->drupalGet('node/' . $node->id()); $this->assertNoText('Test field plugin on node ' . $node->id(), 'Test code field not found'); - // Configure fields + // Configure fields. $fields = array( 'fields[body][region]' => 'right', 'fields[test_field][region]' => 'right', ); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); - // Test field printed + // Test field printed. $this->drupalGet('node/' . $node->id()); $this->assertText('Test field plugin on node ' . $node->id(), 'Test code field not found'); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/LayoutClassesTest.php b/profiles/cr/modules/contrib/ds/src/Tests/LayoutClassesTest.php index 7ab9922f6f..00e9644c62 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/LayoutClassesTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/LayoutClassesTest.php @@ -1,10 +1,5 @@ getEditable('ds_extras.settings') ->set('region_to_block', TRUE) ->set('fields_extra', TRUE) @@ -35,8 +30,9 @@ protected function setup() { /** * Test selecting layouts, classes, region to block and fields. */ - function testDStestLayouts() { - // Check that the ds_3col_equal_width layout is not available (through the alter). + public function testDsTestLayouts() { + // Check that the ds_3col_equal_width layout is not available (through the + // alter). $this->drupalGet('admin/structure/types/manage/article/display'); $this->assertNoRaw('ds_3col_stacked_equal_width', 'ds_3col_stacked_equal_width not available'); @@ -72,7 +68,7 @@ function testDStestLayouts() { $this->dsSelectLayout($layout, $assert); $this->dsConfigureClasses(); $this->dsSelectClasses(); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); // Assert the two extra fields are found. $this->drupalGet('admin/structure/types/manage/article/display'); @@ -103,6 +99,9 @@ function testDStestLayouts() { $node = $this->drupalCreateNode($settings); $this->drupalGet('node/' . $node->id()); + // Assert default classes. + $this->assertRaw('node node--type-article node--view-mode-full', 'Default node classes are added'); + // Assert regions. $this->assertRaw('group-header', 'Template found (region header)'); $this->assertRaw('class_name_1 group-header', 'Class found (class_name_1)'); @@ -118,7 +117,7 @@ function testDStestLayouts() { $this->assertRaw('Submitted by', t('Submitted field found')); $this->assertText('This is an extra field made available through "Extra fields" functionality.'); - // Test HTML5 wrappers + // Test HTML5 wrappers. $this->assertNoRaw('
assertNoRaw(' 'footer', 'layout_configuration[region_wrapper][outer_wrapper]' => 'article', ); - $this->dsConfigureUI($wrappers); + $this->dsConfigureUi($wrappers); $this->drupalGet('node/' . $node->id()); $this->assertRaw('
assertRaw(' 'no_classes'); + $this->drupalPostForm('admin/structure/types/manage/article/display', $edit, t('Save')); + $this->drupalGet('node/' . $node->id()); + + // Assert that there are no entity classes. + $this->assertNoRaw('node node--type-article node--view-mode-full', 'Default node classes are not added'); + + // Only show view mode (deprecated). + $edit = array('entity_classes' => 'old_view_mode'); + $this->drupalPostForm('admin/structure/types/manage/article/display', $edit, t('Save')); + $this->drupalGet('node/' . $node->id()); + + // Assert that the old view mode class name is added (deprecated). + $this->assertRaw('view-mode-full', 'Only view mode is printed'); + // Let's create a block field, enable the full mode first. $edit = array('display_modes_custom[full]' => '1'); $this->drupalPostForm('admin/structure/types/manage/article/display', $edit, t('Save')); @@ -158,30 +173,14 @@ function testDStestLayouts() { $this->drupalPostForm('admin/structure/types/manage/article/display/full', $edit, t('Save')); $this->assertRaw('' . t('Block region') . '', 'Block region found'); - // Configure fields + // Configure fields. $fields = array( 'fields[node_author][region]' => 'left', 'fields[node_links][region]' => 'left', 'fields[body][region]' => 'right', 'fields[dynamic_token_field:node-test_field][region]' => 'block_region', ); - $this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/full'); - - // Set block in sidebar - - // @todo fix this - - /* - $edit = array( - 'blocks[ds_extras_block_region][region]' => 'sidebar_first', - ); - $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks')); - - // Assert the block is on the node page. - $this->drupalGet('node/' . $node->id()); - $this->assertRaw('Block region', 'Block region found'); - $this->assertText('Test code field on node ' . $node->id(), 'Post date in block'); - */ + $this->dsConfigureUi($fields, 'admin/structure/types/manage/article/display/full'); // Change layout via admin/structure/ds/layout-change. // First verify that header and footer are not here. @@ -211,7 +210,8 @@ function testDStestLayouts() { $this->assertTrue(in_array('body', $data['regions']['footer']), t('Body field is in footer')); $this->assertTrue(in_array('dynamic_token_field:node-test_field', $data['regions']['footer']), t('Test field is in footer')); - // Test that a default view mode with no layout is not affected by a disabled view mode. + // Test that a default view mode with no layout is not affected by a + // disabled view mode. $edit = array( 'layout' => '', 'display_modes_custom[full]' => FALSE, @@ -220,4 +220,5 @@ function testDStestLayouts() { $this->drupalGet('node/' . $node->id()); $this->assertNoText('Test code field on node 1', 'No ds field from full view mode layout'); } + } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/LayoutFluidTest.php b/profiles/cr/modules/contrib/ds/src/Tests/LayoutFluidTest.php index 78e0403b69..bf2cf14020 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/LayoutFluidTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/LayoutFluidTest.php @@ -1,14 +1,9 @@ drupalGet('admin/structure/types/manage/article/display'); $this->assertRaw('Test Fluid two column', 'Test Fluid two column layout found'); @@ -40,7 +35,7 @@ function testFluidLayout() { ); $this->dsSelectLayout($layout, $assert); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); // Create a node. $settings = array('type' => 'article'); @@ -52,7 +47,7 @@ function testFluidLayout() { $this->assertRaw('group-one-column', 'Group one column class set'); $this->assertRaw('dstest-2col-fluid.css', 'Css file included'); - // Add fields to the right column + // Add fields to the right column. $fields = array( 'fields[node_author][region]' => 'left', 'fields[node_links][region]' => 'left', @@ -60,14 +55,14 @@ function testFluidLayout() { ); $this->dsSelectLayout($layout, $assert); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); $this->drupalGet('node/' . $node->id()); $this->assertRaw('group-left', 'Template found (region left)'); $this->assertRaw('group-right', 'Template found (region right)'); $this->assertNoRaw('group-one-column', 'Group one column class not set'); - // Move all fields to the right column + // Move all fields to the right column. $fields = array( 'fields[node_author][region]' => 'right', 'fields[node_links][region]' => 'right', @@ -76,7 +71,7 @@ function testFluidLayout() { ); $this->dsSelectLayout($layout, $assert); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); $this->drupalGet('node/' . $node->id()); $this->assertNoRaw('group-left', 'Empty region left hidden'); diff --git a/profiles/cr/modules/contrib/ds/src/Tests/LayoutPluginTest.php b/profiles/cr/modules/contrib/ds/src/Tests/LayoutPluginTest.php index 9aeab17103..fdde4b4d78 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/LayoutPluginTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/LayoutPluginTest.php @@ -1,14 +1,9 @@ drupalGet('admin/structure/types/manage/article/display'); $this->assertRaw('Test One column', 'Test One column layout found'); @@ -41,7 +36,7 @@ function testFieldPlugin() { ); $this->dsSelectLayout($layout, $assert); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); // Create a node. $settings = array('type' => 'article'); @@ -52,7 +47,7 @@ function testFieldPlugin() { $this->assertRaw('group-right', 'Template found (region right)'); $this->assertRaw('dstest-2col.css', 'Css file included'); - // Alter a region + // Alter a region. $settings = array( 'type' => 'article', 'title' => 'Alter me!', @@ -63,9 +58,9 @@ function testFieldPlugin() { } /** - * Test reset layout + * Test reset layout. */ - function testResetLayout() { + public function testResetLayout() { $layout = array( 'layout' => 'ds_reset', ); @@ -81,13 +76,31 @@ function testResetLayout() { ); $this->dsSelectLayout($layout, $assert); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); + + // Create a node. + $settings = array('type' => 'article'); + $node = $this->drupalCreateNode($settings); + $this->drupalGet('node/' . $node->id()); + } + + /** + * Tests settings default wrappers. + */ + public function testDefaultWrappers() { // Create a node. $settings = array('type' => 'article'); $node = $this->drupalCreateNode($settings); + // Select a layout. + $this->dsSelectLayout(); + + // Go to the node. $this->drupalGet('node/' . $node->id()); + + // Check we don't have empty wrappers. + $this->assertNoRaw('<>', 'No empty wrappers found'); } } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/ManageDisplayTabTest.php b/profiles/cr/modules/contrib/ds/src/Tests/ManageDisplayTabTest.php index 0bee725ad7..caa11063e1 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/ManageDisplayTabTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/ManageDisplayTabTest.php @@ -1,10 +1,5 @@ entitiesTestSetup(); - // Verify we can see the manage display tab on a node and can click on it + // Verify we can see the manage display tab on a node and can click on it. $this->drupalGet('node/' . $node->id()); $this->assertRaw('Manage display', 'Manage display tab title found on node'); - $this->assertRaw('node/' . $node->id() . '/display', 'Manage display tab link found on node'); - // @todo figure out why this crashes - //$this->drupalGet('node/' . $node->id() . '/display'); + $this->assertRaw('node/' . $node->id() . '/manage_display', 'Manage display tab link found on node'); + $this->drupalGet('node/' . $node->id() . '/manage_display'); - // Verify we can see the manage display tab on a user and can click on it + // Verify we can see the manage display tab on a user and can click on it. $this->drupalGet('user/' . $this->adminUser->id()); $this->assertRaw('Manage display', 'Manage display tab title found on user'); - $this->assertRaw('user/' . $this->adminUser->id() . '/display', 'Manage display tab link found on user'); - // @todo figure out why this crashes - //$this->drupalGet('user/' . $this->adminUser->id() . '/display'); + $this->assertRaw('user/' . $this->adminUser->id() . '/manage_display', 'Manage display tab link found on user'); + $this->drupalGet('user/' . $this->adminUser->id() . '/manage_display'); - // Verify we can see the manage display tab on a taxonomy term and can click on it + // Verify we can see the manage display tab on a taxonomy term and can click + // on it. $this->drupalGet('taxonomy/term/1'); $this->assertRaw('Manage display', 'Manage display,title tab found on term'); - $this->assertRaw('taxonomy/term/1/display', 'Manage display tab link found on term'); - // @todo figure out why this crashes - //$this->drupalGet('taxonomy/term/1/display'); - + $this->assertRaw('taxonomy/term/1/manage_display', 'Manage display tab link found on term'); + $this->drupalGet('taxonomy/term/1/manage_display'); } } diff --git a/profiles/cr/modules/contrib/ds/src/Tests/TwigRenderTest.php b/profiles/cr/modules/contrib/ds/src/Tests/TwigRenderTest.php new file mode 100644 index 0000000000..8ac245d5d8 --- /dev/null +++ b/profiles/cr/modules/contrib/ds/src/Tests/TwigRenderTest.php @@ -0,0 +1,53 @@ + 'article', 'promote' => 1); + /* @var \Drupal\node\NodeInterface $node */ + $node = $this->drupalCreateNode($settings); + + // Configure layout. + $layout = array( + 'layout' => 'dstest_1col_title', + ); + $layout_assert = array( + 'regions' => array( + 'ds_content' => '' . t('Content') . '', + ), + ); + $this->dsSelectLayout($layout, $layout_assert); + + $fields = array( + 'fields[node_title][region]' => 'ds_content', + ); + $this->dsConfigureUi($fields); + + $this->drupalGet('node/' . $node->id()); + + // Assert that the title is visible. + $this->assertText($node->getTitle()); + + $edit = array( + 'fs3[use_field_names]' => FALSE, + ); + $this->drupalPostForm('admin/structure/ds/settings', $edit, t('Save configuration')); + + $this->drupalGet('node/' . $node->id()); + + // Assert that the title is not visible anymore. + $this->assertNoText($node->getTitle()); + } + +} diff --git a/profiles/cr/modules/contrib/ds/src/Tests/ViewsTest.php b/profiles/cr/modules/contrib/ds/src/Tests/ViewsTest.php index 0507df2bb9..ae377bd761 100644 --- a/profiles/cr/modules/contrib/ds/src/Tests/ViewsTest.php +++ b/profiles/cr/modules/contrib/ds/src/Tests/ViewsTest.php @@ -1,10 +1,5 @@ createTerm($this->vocabulary); $tag2 = $this->createTerm($this->vocabulary); @@ -94,7 +102,7 @@ function testDSViews() { ), ); $this->dsSelectLayout($layout, $assert, 'admin/structure/types/manage/article/display/teaser'); - $this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/teaser'); + $this->dsConfigureUi($fields, 'admin/structure/types/manage/article/display/teaser'); $layout = array( 'layout' => 'ds_4col', ); @@ -113,7 +121,7 @@ function testDSViews() { ), ); $this->dsSelectLayout($layout, $assert); - $this->dsConfigureUI($fields); + $this->dsConfigureUi($fields); // Get default teaser view. $this->drupalGet('ds-testing'); @@ -126,7 +134,15 @@ function testDSViews() { // Get alternating view. $this->drupalGet('ds-testing-2'); - foreach (array('group-left', 'group-right', 'first', 'second', 'third', 'fourth') as $region) { + $regions = array( + 'group-left', + 'group-right', + 'first', + 'second', + 'third', + 'fourth', + ); + foreach ($regions as $region) { $this->assertRaw($region, t('Region @region found', array('@region' => $region))); } $this->assertNoRaw('Article 1'); @@ -161,4 +177,5 @@ function testDSViews() { $this->assertRaw('Advanced display for id 2'); $this->assertRaw('Advanced display for id 3'); } + } diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/config/install/core.entity_view_display.node.article.default.yml b/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/config/install/core.entity_view_display.node.article.default.yml index 7dee65313e..cec077f8fe 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/config/install/core.entity_view_display.node.article.default.yml +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/config/install/core.entity_view_display.node.article.default.yml @@ -17,6 +17,7 @@ third_party_settings: path: modules/ds library: ds/layout.2col disable_css: FALSE + entity_classes: all_classes settings: classes: { } wrappers: diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/ds_exportables_test.info.yml b/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/ds_exportables_test.info.yml index 5acdfdb7c8..2ab09a8168 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/ds_exportables_test.info.yml +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_exportables_test/ds_exportables_test.info.yml @@ -5,8 +5,8 @@ package: 'Display Suite' # core: 8.x hidden: TRUE -# Information added by Drupal.org packaging script on 2016-05-23 -version: '8.x-2.4' +# Information added by Drupal.org packaging script on 2016-09-29 +version: '8.x-2.6' core: '8.x' project: 'ds' -datestamp: 1464029046 +datestamp: 1475152442 diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col-fluid.css b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col-fluid.css index d9ba3bea5e..daba4a68e2 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col-fluid.css +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col-fluid.css @@ -1,4 +1,3 @@ - .group-left { float: left; width: 50%; diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col.css b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col.css index 28b230cf74..daba4a68e2 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col.css +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/css/dstest-2col.css @@ -1,10 +1,9 @@ - .group-left { float: left; width: 50%; } .group-right { - float: left; + float: left; width: 50%; } diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.info.yml b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.info.yml index 031f7601c6..28fad567e1 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.info.yml +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.info.yml @@ -6,8 +6,8 @@ type: module dependencies: - ds_extras -# Information added by Drupal.org packaging script on 2016-05-23 -version: '8.x-2.4' +# Information added by Drupal.org packaging script on 2016-09-29 +version: '8.x-2.6' core: '8.x' project: 'ds' -datestamp: 1464029046 +datestamp: 1475152442 diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.layouts.yml b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.layouts.yml index 3ca331e8e0..2cac02c84f 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.layouts.yml +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/ds_test.layouts.yml @@ -7,6 +7,15 @@ dstest_1col: regions: ds_content: label: Content +dstest_1col_title: + label: Test one column only title + category: Display Suite + class: '\Drupal\ds\Plugin\DsLayout' + type: partial + template: templates/dstest-1col-title + regions: + ds_content: + label: Content dstest_2col: label: Test Two column category: Display Suite diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/Block/DsTestBlock.php b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/Block/DsTestBlock.php new file mode 100644 index 0000000000..69a2631b30 --- /dev/null +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/Block/DsTestBlock.php @@ -0,0 +1,42 @@ +get('ds_test_block__access', FALSE)); + } + + /** + * {@inheritdoc} + */ + public function build() { + $build = []; + $build[]['#markup'] = $this::BODY_TEXT; + return $build; + } + + public function getCacheMaxAge() { + return 0; + } + +} diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsField/TestField.php b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsField/TestField.php index 09e3af2786..586b61a2af 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsField/TestField.php +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsField/TestField.php @@ -1,10 +1,5 @@ array( + '#markup' => 'Test row one of multiple field plugin on node ' . $this->entity()->id(), + ), + 1 => array( + '#markup' => 'Test row two of multiple field plugin on node ' . $this->entity()->id(), + ), + ); + } + + /** + * {@inheritdoc} + */ + public function isMultiple() { + return TRUE; + } + +} diff --git a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsFieldTemplate/TestLayout.php b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsFieldTemplate/TestLayout.php index c3511319af..9e277b9658 100644 --- a/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsFieldTemplate/TestLayout.php +++ b/profiles/cr/modules/contrib/ds/tests/modules/ds_test/src/Plugin/DsFieldTemplate/TestLayout.php @@ -1,10 +1,5 @@ + +{{ title_suffix.contextual_links }} + + {{ ds_content.node_title }} + + diff --git a/profiles/cr/modules/contrib/ds/tests/src/FunctionalJavascript/JavascriptTest.php b/profiles/cr/modules/contrib/ds/tests/src/FunctionalJavascript/JavascriptTest.php new file mode 100644 index 0000000000..63f6f9a9bc --- /dev/null +++ b/profiles/cr/modules/contrib/ds/tests/src/FunctionalJavascript/JavascriptTest.php @@ -0,0 +1,81 @@ +adminUser = $this->drupalCreateUser(array( + 'access content', + 'admin display suite', + 'admin fields', + 'administer nodes', + 'administer content types', + 'administer node fields', + 'administer node form display', + 'administer node display', + )); + $this->drupalLogin($this->adminUser); + + $this->drupalCreateContentType(array( + 'type' => 'article', + 'name' => 'Article', + )); + + } + + /** + * Test DS settings. + */ + public function testSettings() { + // Go to the article manage display page. + $this->drupalGet('admin/structure/types/manage/article/display'); + $page = $this->getSession()->getPage(); + + // Change the layout to 2 column layout and wait for it to be changed, see + // if the new template is displayed. + $page->selectFieldOption('layout', 'ds_2col'); + $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->pageTextContains('ds-2col--node.html.twig'); + $page->pressButton('Save'); + + // Check that all settings are saved. + /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */ + $display = EntityViewDisplay::load('node.article.default'); + $settings = $display->getThirdPartySetting('ds', 'layout'); + $this->assertSame($settings['id'], 'ds_2col'); + } + +}