LinkTestBaseFieldHooks.php
Namespace
Drupal\link_test_base_field\HookFile
-
core/
modules/ link/ tests/ modules/ link_test_base_field/ src/ Hook/ LinkTestBaseFieldHooks.php
View source
<?php
declare (strict_types=1);
namespace Drupal\link_test_base_field\Hook;
use Drupal\link\LinkItemInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for link_test_base_field.
*/
class LinkTestBaseFieldHooks {
/**
* Implements hook_entity_base_field_info().
*/
public function entityBaseFieldInfo(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type->id() === 'entity_test') {
$fields['links'] = BaseFieldDefinition::create('link')->setLabel(t('Links'))
->setRevisionable(TRUE)
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setDescription(t('Add links to the entity.'))
->setRequired(FALSE)
->setSettings([
'link_type' => LinkItemInterface::LINK_GENERIC,
'title' => DRUPAL_REQUIRED,
])
->setDisplayOptions('form', [
'type' => 'link_default',
'weight' => 49,
]);
}
return $fields;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
LinkTestBaseFieldHooks | Hook implementations for link_test_base_field. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.