Displays add custom block links for available types.
array A render array for a list of the custom block types that can be added or if there is only one custom block type defined for the site, the function returns the custom block add page for that custom block type.
public function add() {
$options = array();
if (($theme = $this->request->attributes
->get('theme')) && in_array($theme, array_keys(list_themes()))) {
// We have navigated to this page from the block library and will keep track
// of the theme for redirecting the user to the configuration page for the
// newly created block in the given theme.
$options = array(
'query' => array(
'theme' => $theme,
),
);
}
$types = $this->entityManager
->getStorageController('custom_block_type')
->load();
if ($types && count($types) == 1) {
$type = reset($types);
// @todo convert this to OO once block/add/%type uses a Controller. Will
// be fixed in http://drupal.org/node/1978166.
$this->moduleHandler
->loadInclude('custom_block', 'pages.inc');
return custom_block_add($type);
}
return array(
'#theme' => 'custom_block_add_list',
'#content' => $types,
);
}