class RecentCalendarPublicationsBlock in Content Planner 8
Provides a block with recent calendar publications for Content Planner Dashboard.
Plugin annotation
@DashboardBlock(
id = "recent_calendar_content_block",
name = @Translation("Recent Calendar Publications Widget")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\content_planner\DashboardBlockBase implements DashboardBlockInterface, ContainerFactoryPluginInterface uses ConfigFormBaseTrait
- class \Drupal\content_calendar\Plugin\DashboardBlock\RecentCalendarPublicationsBlock
- class \Drupal\content_planner\DashboardBlockBase implements DashboardBlockInterface, ContainerFactoryPluginInterface uses ConfigFormBaseTrait
Expanded class hierarchy of RecentCalendarPublicationsBlock
File
- modules/
content_calendar/ src/ Plugin/ DashboardBlock/ RecentCalendarPublicationsBlock.php, line 18
Namespace
Drupal\content_calendar\Plugin\DashboardBlockView source
class RecentCalendarPublicationsBlock extends DashboardBlockBase {
/**
*
*/
public function build() {
$config = $this
->getConfiguration();
$contentService = new ContentService();
// Last publications.
$last_publications_limit_config = $this
->getCustomConfigByKey($config, 'last_publications_limit', 3);
$last_nodes = $contentService
->getRecentContent($last_publications_limit_config);
// Next publications.
$next_publications_limit_config = $this
->getCustomConfigByKey($config, 'next_publications_limit', 3);
$next_nodes = $contentService
->getFollowingContent($next_publications_limit_config);
return [
'#theme' => 'recent_calendar_content',
'#last_nodes' => $last_nodes,
'#next_nodes' => $next_nodes,
];
}
/**
* {@inheritdoc}
*/
public function getConfigSpecificFormFields(FormStateInterface &$form_state, Request &$request, array $block_configuration) {
$form = [];
// Last publications limit.
$last_publications_limit_default_value = $this
->getCustomConfigByKey($block_configuration, 'last_publications_limit', 3);
$form['last_publications_limit'] = [
'#type' => 'number',
'#title' => t('Limit number of recently published nodes'),
'#required' => FALSE,
'#default_value' => $last_publications_limit_default_value,
];
// Next publications limit.
$next_publications_limit_default_value = $this
->getCustomConfigByKey($block_configuration, 'next_publications_limit', 3);
$form['next_publications_limit'] = [
'#type' => 'number',
'#title' => t('Limit number of nodes to be published'),
'#required' => FALSE,
'#default_value' => $next_publications_limit_default_value,
];
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DashboardBlockBase:: |
protected | property | The route match. | |
DashboardBlockBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
2 |
DashboardBlockBase:: |
public static | function | Get basic configuration structure for the block configuration. | |
DashboardBlockBase:: |
public | function |
Get Configuration passed in by Plugin Manager. Overrides DashboardBlockInterface:: |
|
DashboardBlockBase:: |
protected | function | Get custom config. | |
DashboardBlockBase:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
DashboardBlockBase:: |
public | function |
Return the name of the block. Overrides DashboardBlockInterface:: |
|
DashboardBlockBase:: |
public | function |
Determines if the plugin is configurable. Overrides PluginBase:: |
|
DashboardBlockBase:: |
public | function |
Submit form handler. Overrides DashboardBlockInterface:: |
|
DashboardBlockBase:: |
public | function |
Validates teh plugin config form. Overrides DashboardBlockInterface:: |
|
DashboardBlockBase:: |
public | function |
Constructs a new UserLoginBlock instance. Overrides PluginBase:: |
2 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
RecentCalendarPublicationsBlock:: |
public | function |
Build the block and return a renderable array. Overrides DashboardBlockBase:: |
|
RecentCalendarPublicationsBlock:: |
public | function |
Add additonal form elements specific to the Plugin. Overrides DashboardBlockBase:: |