public function AddToHomeScreenBlock::build in Progressive Web App 8
Builds and returns the renderable array for this block plugin.
If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).
Return value
array A renderable array representing the content of the block.
Overrides BlockPluginInterface::build
See also
\Drupal\block\BlockViewBuilder
File
- modules/
pwa_a2hs/ src/ Plugin/ Block/ AddToHomeScreenBlock.php, line 60
Class
- AddToHomeScreenBlock
- Provides an Add to Home Screen block.
Namespace
Drupal\pwa_a2hs\Plugin\BlockCode
public function build() {
return [
'#attached' => [
'library' => [
'pwa_a2hs/pwa_a2hs_prompt',
],
'drupalSettings' => [
'pwaA2hs' => [
'pwaA2hsPrompt' => [
'button_text' => $this->configuration['button_text'],
],
],
],
],
'#theme' => 'pwa_add_to_home_screen',
'#intro_text' => [
'#type' => 'processed_text',
'#text' => $this->configuration['intro_text']['value'],
'#format' => $this->configuration['intro_text']['format'],
],
'#button_text' => [
'#markup' => $this->configuration['button_text'],
],
];
}