You are here

public function FacebookBoxesLikeBlock::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/FacebookBoxesLikeBlock.php, line 117
Contains \Drupal\facebook_boxes\Plugin\Block\FacebookBoxesLikeBlock

Class

FacebookBoxesLikeBlock
Provides the Facebook Like block.

Namespace

Drupal\facebook_boxes\Plugin\Block

Code

public function build() {
  $url = urlencode($this->configuration['fb_like_url']);
  $width = $this->configuration['fb_like_width'];
  $height = $this->configuration['fb_like_height'];
  $colorscheme = urlencode($this->configuration['fb_like_colorscheme']);
  $border = urlencode($this->configuration['fb_like_border']);
  $opts = $this->configuration['fb_like_toggles'];
  return array(
    '#type' => 'markup',
    '#markup' => sprintf('<iframe src="//www.facebook.com/plugins/likebox.php?href=%s&amp;width=%u&amp;height=%u&amp;colorscheme=%s&amp;show_faces=%s&amp;border_color=%s&amp;stream=%s&amp;header=%s" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:%spx; height:%spx;" allowTransparency="true"></iframe>', $url, $width, $height, $colorscheme, in_array('fb_faces', $opts) ? 'true' : 'false', $border, in_array('fb_stream', $opts) ? 'true' : 'false', in_array('fb_header', $opts) ? 'true' : 'false', $width, $height),
  );
}