You are here

function ccl_blocks_ccl_link_info in Custom Contextual Links 8

Same name and namespace in other branches
  1. 7 ccl_blocks/ccl_blocks.module \ccl_blocks_ccl_link_info()

Hook function to provide link option information for the link list page.

File

ccl_blocks/ccl_blocks.module, line 187
Implments support for CCL on blocks.

Code

function ccl_blocks_ccl_link_info($record) {
  if ($record->type == 'block') {

    // @FIXME
    // l() expects a Url object, created from a route name or external URI.
    // $options_return = array(
    //       'desc' => '',
    //       'op' => l(t('Edit'), 'admin/config/user-interface/ccl/' . $record->clid . '/edit') . ' | ' . l(t('Delete'), 'admin/config/user-interface/ccl/' . $record->clid . '/delete'),
    //     );
    $options = unserialize($record->options);
    if ($options['block_global']) {
      $options_return['desc'] = t('Attached to all blocks.');
    }
    else {
      $blocks = _ccl_blocks_get_info();
      $options_return['desc'] = \Drupal::translation()
        ->formatPlural(count($options['block_select']), 'Attached to block: %block', 'Attached to blocks: %block', array(
        '%block' => implode(', ', array_intersect_key($blocks, $options['block_select'])),
      ));
    }
    return $options_return;
  }
  else {
    return "";
  }
}