Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ langcode: en
status: true
dependencies:
module:
- localgov_core
- node
- paragraphs_library
label: Default
Expand All @@ -17,7 +18,7 @@ matchers:
group_by_bundle: true
substitution_type: canonical
limit: 100
include_unpublished: false
include_unpublished: true
weight: -10
c3257417-fce9-4307-8251-58672edf88be:
id: email
Expand Down
34 changes: 34 additions & 0 deletions src/Plugin/Linkit/Matcher/EntityMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Drupal\localgov_core\Plugin\Linkit\Matcher;

use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityInterface;
use Drupal\linkit\Plugin\Linkit\Matcher\EntityMatcher as LinkitEntityMatcher;

/**
* Provides default linkit matchers for all entity types.
*
* @Matcher(
* id = "entity",
* label = @Translation("Entity"),
* deriver = "\Drupal\linkit\Plugin\Derivative\EntityMatcherDeriver"
* )
*/
class EntityMatcher extends LinkitEntityMatcher {

/**
* {@inheritdoc}
*/
protected function buildLabel(EntityInterface $entity) {
$label = Html::escape($entity->label());

// Prepend "Unpublished: " for unpublished entities.
if (method_exists($entity, 'isPublished') && !$entity->isPublished()) {
$label = 'Unpublished: ' . $label;
}

return $label;
}

}
35 changes: 35 additions & 0 deletions src/Plugin/Linkit/Matcher/NodeMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Drupal\localgov_core\Plugin\Linkit\Matcher;

use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityInterface;
use Drupal\linkit\Plugin\Linkit\Matcher\NodeMatcher as LinkitNodeMatcher;

/**
* Provides specific linkit matchers for the node entity type.
*
* @Matcher(
* id = "entity:node",
* label = @Translation("Node"),
* target_entity = "node",
* provider = "node"
* )
*/
class NodeMatcher extends LinkitNodeMatcher {

/**
* {@inheritdoc}
*/
protected function buildLabel(EntityInterface $entity) {
$label = Html::escape($entity->label());

// Prepend "Unpublished: " for unpublished nodes.
if (method_exists($entity, 'isPublished') && !$entity->isPublished()) {
$label = 'Unpublished: ' . $label;
}

return $label;
}

}