You are here

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

Class

FacebookBoxesFollowBlock
Provides the Facebook Follow block.

Namespace

Drupal\facebook_boxes\Plugin\Block

Code

public function build() {
  $url = $this->configuration['fb_follow_url'];
  $layout = $this->configuration['fb_follow_layout'];
  $showfaces = $this->configuration['fb_follow_showface'] ? 'TRUE' : 'FALSE';
  $width = preg_replace('/[^\\d\\s]/', '', $this->configuration['fb_follow_width']);
  $out = array();
  $out[] = '<iframe src="http://www.facebook.com/plugins/follow.php?href=' . $url;
  $out[] = '&amp;layout=' . $layout;
  if ($layout == 'standard') {
    $out[] = '&amp;show_faces=' . $showfaces;
  }
  $out[] = '&amp;colorscheme=' . $this->configuration['fb_follow_color'];
  $out[] = '&amp;font=' . $this->configuration['fb_follow_font'];
  $out[] = '&amp;width=' . $width;
  $out[] = '&amp;height=80" scrolling="no" frameborder="0" ';
  $out[] = 'style="border:none; overflow:hidden; width:' . $width;
  $out[] = ';height:80px; "allowTransparency="true"></iframe>';
  return array(
    '#type' => 'markup',
    '#markup' => implode('', $out),
  );
}