You are here

function shurly_service_block_view in ShURLy 8

Same name and namespace in other branches
  1. 7 shurly_service/shurly_service.module \shurly_service_block_view()

Implements hook_block_view().

File

shurly_service/shurly_service.module, line 72
Link ShURLy functionalities to services module. @todo add option to rate limit requests @todo add option for user api keys

Code

function shurly_service_block_view($delta = '') {
  $block = [];

  // don't show the block when user is on the callback page.
  switch ($delta) {
    case 'api_key':
      $user = \Drupal::currentUser();
      if ($user->uid > 0 && \Drupal::currentUser()
        ->hasPermission('Create short URLs')) {
        $block['subject'] = t('API key');
        $block['content'] = \Drupal::formBuilder()
          ->getForm('shurly_api_key_form');
      }
      break;
  }
  return $block;
}