public function FacebookBoxesRecommendsBlock::build in Facebook Boxes 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
- src/
Plugin/ Block/ FacebookBoxesRecommendsBlock.php, line 127 - Contains \Drupal\facebook_boxes\Plugin\Block\FacebookBoxesRecommendsBlock
Class
- FacebookBoxesRecommendsBlock
- Provides the Facebook Recommends block.
Namespace
Drupal\facebook_boxes\Plugin\BlockCode
public function build() {
$height = $this->configuration['fb_rec_height'];
$width = $this->configuration['fb_rec_width'];
$opts = $this->configuration['fb_rec_toggles'];
return array(
'#type' => 'markup',
'#markup' => sprintf('<iframe src="//www.facebook.com/plugins/recommendations.php?site=%s&action&width=%u&height=%u&colorscheme=%s&&border_color=%s&header=%s&font&linktarget=%s" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:%upx; height:%upx;" allowTransparency="true"></iframe>', urlencode($this->configuration['fb_rec_domain']), $width, $height, urlencode($this->configuration['fb_rec_colorscheme']), urlencode($this->configuration['fb_rec_border']), in_array('fb_header', $opts) ? 'true' : 'false', in_array('fb_target', $opts) ? '_blank' : '_top', $width, $height),
);
}