-
Notifications
You must be signed in to change notification settings - Fork 13
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
OPENEUROPA-1747: Add social sharing block. #46
Conversation
'system', | ||
'user', | ||
'oe_webtools_social_share', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line please
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static $modules = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent of this is protected so this one should be as well.
$render = $this->buildBlock('social_share', $config); | ||
$html = (string) $this->container->get('renderer')->renderRoot($render); | ||
$crawler = new Crawler($html); | ||
// Make sure that search form block is present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a search form.
/** @var \Drupal\Core\Block\BlockBase $plugin */ | ||
$plugin = $this->container->get('plugin.manager.block')->createInstance($block_id, $config); | ||
// Inject runtime contexts. | ||
if ($plugin instanceof ContextAwarePluginInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need any of the contexts to be injected as we dont use contexts in this block. So this entire method is overkill, you can just get the plugin directly in testSearchBlockRendering()
* category = @Translation("Webtools"), | ||
* ) | ||
*/ | ||
class SocialShare extends BlockBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocks typically have their name suffixed with Block
: SocialShareBlock
], | ||
'stats' => TRUE, | ||
]; | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason why this widget is showing up when placing the block is because the other webtools submodules are enabled. Each widget needs to also attach the smart loaders library. Check for example oe_webtools_laco_widget_page_attachments()
and attach it also here.
* Implements hook_page_attachments(). | ||
*/ | ||
function oe_webtools_social_share_attachments(array &$attachments) { | ||
$attachments['#attached']['library'][] = 'oe_webtools/drupal.webtools-smartloader'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to the block render array itself, so that it is included only when the block is rendered.
runner.yml.dist
Outdated
@@ -24,6 +24,7 @@ drupal: | |||
- "./vendor/bin/drush en oe_webtools oe_webtools_laco_service -y" | |||
- "./vendor/bin/drush en oe_webtools oe_webtools_laco_widget -y" | |||
- "./vendor/bin/drush en oe_webtools oe_webtools_cookie_consent -y" | |||
- "./vendor/bin/drush en oe_webtools oe_webtools_social_share -y" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "./vendor/bin/drush en oe_webtools oe_webtools_social_share -y" | |
- "./vendor/bin/drush en oe_webtools_social_share -y" |
It should be fixed in all lines except the first 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Let's put all our modules in one line
Actually my review should have been of "Request changes" type but i misclicked. |
OPENEUROPA-1747
Description
Add social sharing block.
Change log
Commands