Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OEL-1543: Rename block templates to target plugin ids instead of block ids. #137

Merged
merged 5 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public function testBlockRendering(): void {
$render = $this->container->get('renderer')->renderRoot($build);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to rename the variables here, but I then decided to rather not touch this part.
E.g. $render -> $markup, $entity -> $block_entity.
We can do this another day.

$crawler = new Crawler($render->__toString());

// Assert the form rendering.
$block = $crawler->filter('#block-whitelabel-search-block');
$this->assertCount(1, $block);
$form = $block->filter('#oe-whitelabel-search-form');
// Select the search form in the block.
// The block template removes the block wrapper, so the form is the root
// element.
$form = $crawler->filter('body > form#oe-whitelabel-search-form');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it adds clarity to also have form in the selector.

$this->assertCount(1, $form);
$this->assertSame('d-flex mt-3 mt-lg-0', $form->attr('class'));
// Assert the field wrapper rendering.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{#
/**
* @file
* Override for blocks with plugin id = 'language_block:language_interface'.
*
* @see \Drupal\language\Plugin\Block\LanguageBlock
*/
#}
{% block content %}
<div class="language-switcher-block nav-link">
{{ content }}
</div>
{% endblock %}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{#
/**
* @file
* icon.
* Override for blocks with plugin id = 'oe_authentication_login_block'.
*
* @see \Drupal\oe_authentication\Plugin\Block\LoginBlock
*/
#}
{% set extra_attributes = create_attribute() %}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{#
/**
* @file
* Theme override for a branding block.
* Override for blocks with plugin id = 'system_branding_block'.
*
* Each branding element variable (logo, name, slogan) is only available if
* enabled in the block configuration.
*
* Available variables:
* - site_logo: Logo for site as defined in Appearance or theme settings.
* - site_name: Name for site as defined in Site information settings.
* - site_slogan: Slogan for site as defined in Site information settings.
* @see build/core/modules/system/templates/block--system-branding-block.html.twig
* @see \Drupal\system\Plugin\Block\SystemBrandingBlock
*/
#}
{% set light = bcl_header_style == 'light' %}
Expand Down
5 changes: 2 additions & 3 deletions templates/overrides/search/block--facets-form.html.twig
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{#
/**
* @file
* Theme block implementation to display facet form.
* Override for blocks with plugin id = 'facets_form'.
*
* @see ./core/themes/stable/templates/block/block.html.twig
* @see \Drupal\facets_form\Plugin\Block\FacetsFormBlock
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments had changed in 1.x since before last rebase.
Please decide if my version or the 1.x version is preferable.

*/
#}

{% if content.actions.reset['#type'] == 'link' %}
{% set extra_attributes = create_attribute() %}
{% set reset = pattern('link', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{#
/**
* @file
* Theme block implementation to display facets summary.
* Override for blocks with plugin id = 'facets_summary_block'.
*
* @see ./core/themes/stable/templates/block/block.html.twig
* @see \Drupal\facets_summary\Plugin\Block\FacetsSummaryBlock
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments had changed in 1.x since before last rebase.
Please decide if my version or the 1.x version is preferable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, think their better, since the location of the indicated block template should have been the block module not the stable theme

*/
#}
{% if label and content['#items'][0]['#theme'] is defined and content['#items'][0]['#theme'] == 'facets_summary_count' %}
Expand Down
11 changes: 0 additions & 11 deletions templates/search/block--oe-whitelabel-search-form.html.twig

This file was deleted.

13 changes: 13 additions & 0 deletions templates/search/block--whitelabel-search-block.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{#
/**
* @file
* Override for blocks with plugin id = 'whitelabel_search_block'.
*
* Removes outer wrapper div and block label.
*
* @see \Drupal\oe_whitelabel_search\Plugin\Block\SearchBlock
*/
#}
{% block content %}
{{ content }}
{% endblock %}
6 changes: 4 additions & 2 deletions templates/search/form--oe-whitelabel-search-form.html.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{#
/**
* @file
* Theme override for a 'form' element.
* @see ./core/themes/stable/templates/form/form.html.twig
* Override for forms with form id = 'oe_whitelabel_search_form'.
*
* @see ./core/modules/system/templates/form.html.twig
* @see \Drupal\oe_whitelabel_search\Form\SearchForm
*/
#}
<form{{ attributes.addClass('d-flex', 'mt-3', 'mt-lg-0') }}>
Expand Down