Skip to content

Instantly share code, notes, and snippets.

@xtfer
Created August 5, 2014 03:21
Show Gist options
  • Save xtfer/83444a9ed503a4feb826 to your computer and use it in GitHub Desktop.
Save xtfer/83444a9ed503a4feb826 to your computer and use it in GitHub Desktop.
Ghost: Block Plugin example
<?php
/**
* @file
* Contains a BlockPluginExample
*
* @license GPL v2 http://www.fsf.org/licensing/licenses/gpl.html
* @author Chris Skene chris at previousnext dot com dot au
* @copyright Copyright(c) 2014 Previous Next Pty Ltd
*/
namespace Drupal\ghost_examples\Block;
use Drupal\ghost\Block\Plugin\BlockPluginInterface;
use Drupal\ghost\Block\Plugin\BlockPluginBase;
$plugin = array(
'title' => t('Example block'),
'description' => t('Block plugin example block'),
'class' => 'Drupal\ghost_examples\Block\BlockPluginExample',
// Remove this line in your own plugins...
'hidden' => TRUE,
);
/**
* Class BlockPluginExample
*
* @package Drupal\ghost\Block\Plugin
*/
class BlockPluginExample
extends BlockPluginBase
implements BlockPluginInterface {
/**
* Local implementation of hook_block_info().
*
* @see hook_block_info()
*
* @return array
* An array of block information for this block.
*/
public function blockInfo() {
return array(
'info' => t('Example block'),
'cache' => DRUPAL_NO_CACHE,
);
}
/**
* Return the human readable block subject.
*
* This is the 'subject' key from hook_block_view().
*
* @see hook_block_view()
*
* @return string
* The subject.
*/
public function blockSubject() {
return t('Example block');
}
/**
* Return the content for the block.
*
* This is the 'content' key from hook_block_view().
*
* @see hook_block_view()
*
* @return mixed
* A view implementation.
*/
public function blockContent() {
return 'Some content';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment