diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..c6cd69aa31ead90c957c72ffb8038a791f62dd1f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,29 @@ +################ +# GitLabCI template for Drupal projects. +# +# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. +# It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained. +# As long as you include the project, ref and three files below, any future updates added by the Drupal Association will be used in your +# pipelines automatically. However, you can modify this template if you have additional needs for your project. +# The full documentation is on https://project.pages.drupalcode.org/gitlab_templates/ +################ + +# For information on alternative values for 'ref' see https://project.pages.drupalcode.org/gitlab_templates/info/templates-version/ +# To test a Drupal 7 project, change the first include filename from .main.yml to .main-d7.yml +include: + - project: $_GITLAB_TEMPLATES_REPO + ref: $_GITLAB_TEMPLATES_REF + file: + - '/includes/include.drupalci.main.yml' + - '/includes/include.drupalci.variables.yml' + - '/includes/include.drupalci.workflows.yml' +# +################ +# Pipeline configuration variables are defined with default values and descriptions in the file +# https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml +# Uncomment the lines below if you want to override any of the variables. The following is just an example. +################ +# variables: +# SKIP_ESLINT: '1' +# OPT_IN_TEST_NEXT_MAJOR: '1' +# _CURL_TEMPLATES_REF: 'main' diff --git a/list_inline_block.module b/list_inline_block.module index 217b61ebfcdd4ffaa255c5a3454f6d491f64a53e..4043d5b982f9e43548c8ef9a0f59a053692fb3e2 100644 --- a/list_inline_block.module +++ b/list_inline_block.module @@ -27,7 +27,7 @@ function list_inline_block_help($route_name, RouteMatchInterface $route_match) { return $output; case 'list_inline_block.get_block': - $output = '<p>' . t('Blocks belong to <a href="/block-content/types">Custom block types</a>, but Inline Blocks are those added through Layout Builder.') . '</p>'; + $output = '<p>' . t('Blocks belong to <a href="/admin/structure/block-content">Custom block types</a>, but Inline Blocks are those added through Layout Builder.') . '</p>'; return $output; } diff --git a/src/Controller/ListBlock.php b/src/Controller/ListBlock.php index e9b49da5cbc9f6626083bcea8332a4f88aaf7539..2a7e6ce863a63ea4514c703a83ac7fa5db0626f6 100644 --- a/src/Controller/ListBlock.php +++ b/src/Controller/ListBlock.php @@ -80,56 +80,64 @@ class ListBlock extends ControllerBase { ]); $result = $query->execute()->fetchAll(); - $header = [ - [ - 'data' => $this->t('Block Type'), - 'field' => 'blockType', - 'sort' => 'asc', - ], - 'Title' => $this->t('Title'), - 'url' => $this->t('Link'), - ]; - $output = []; - - // Use the PagerManager to handle pagination. - $pager = $this->pagerManager->createPager(count($result), 25); - $pager->getCurrentPage(); - $chunks = array_chunk($result, 25); - $current_page_items = $chunks[$pager->getCurrentPage()]; - $k = 0; - foreach ($current_page_items as $record) { - $block = $this->entityTypeManager->getStorage('block_content')->load($record->block_content_id); - $blockType = $block->type->entity->label(); - $node = $this->entityTypeManager->getStorage('node')->load($record->layout_entity_id); - $link = $this->t('<a href=/@type/@id/layout>Edit</a> (@title)', [ - '@type' => $record->layout_entity_type, - '@id' => $record->layout_entity_id, - '@title' => $node->label(), - ]); - $title = $this->t('<a href=/@type/@id>@title</a>', [ - '@type' => $record->layout_entity_type, - '@id' => $record->layout_entity_id, - '@title' => $block->info->value, - ]); - $output[$k] = [ - 'blockType' => $blockType, - 'Title' => $title, - 'url' => $link, + if (!empty($result)) { + $header = [ + [ + 'data' => $this->t('Block Type'), + 'field' => 'blockType', + 'sort' => 'asc', + ], + 'Title' => $this->t('Title'), + 'url' => $this->t('Link'), + ]; + $output = []; + + // Use the PagerManager to handle pagination. + $pager = $this->pagerManager->createPager(count($result), 25); + $pager->getCurrentPage(); + $chunks = array_chunk($result, 25); + $current_page_items = $chunks[$pager->getCurrentPage()]; + $k = 0; + foreach ($current_page_items as $record) { + $block = $this->entityTypeManager->getStorage('block_content')->load($record->block_content_id); + $blockType = $block->type->entity->label(); + $node = $this->entityTypeManager->getStorage('node')->load($record->layout_entity_id); + $link = $this->t('<a href=/@type/@id/layout>Edit</a> (@title)', [ + '@type' => $record->layout_entity_type, + '@id' => $record->layout_entity_id, + '@title' => $node->label(), + ]); + $title = $this->t('<a href=/@type/@id>@title</a>', [ + '@type' => $record->layout_entity_type, + '@id' => $record->layout_entity_id, + '@title' => $block->info->value, + ]); + $output[$k] = [ + 'blockType' => $blockType, + 'Title' => $title, + 'url' => $link, + ]; + $k = $k + 1; + } + $output = $this->sortList($output, $header, $request); + + $form['table'] = [ + '#type' => 'table', + '#header' => $header, + '#rows' => $output, + '#empty' => $this->t('No blocks found'), + ]; + + $form['pager'] = [ + '#type' => 'pager', + ]; + } + else { + $form['not-found'] = [ + '#type' => 'markup', + '#markup' => $this->t('<h4>There is no Layout Builder Blocks created. Please create one in any Layout Builder page.</h4>') ]; - $k = $k + 1; } - $output = $this->sortList($output, $header, $request); - - $form['table'] = [ - '#type' => 'table', - '#header' => $header, - '#rows' => $output, - '#empty' => $this->t('No blocks found'), - ]; - - $form['pager'] = [ - '#type' => 'pager', - ]; return $form; }