function paragraphs_library_entity_bundle_field_info_alter in Paragraphs 8
Implements hook_entity_bundle_field_info_alter().
File
- modules/
paragraphs_library/ paragraphs_library.module, line 277 - Main module file for the Paragraphs Library module.
Code
function paragraphs_library_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) {
// Ensure that Paragraph fields that only allow certain Paragraphs types
// cannot have this restriction bypassed by the use of library items.
/** @var \Drupal\Core\Field\FieldDefinitionInterface[] $fields */
foreach ($fields as $name => $definition) {
if ($definition
->getType() != 'entity_reference_revisions') {
continue;
}
if ($definition
->getSetting('target_type') != 'paragraph') {
continue;
}
$fields[$name]
->addConstraint('ParagraphsLibraryItemHasAllowedParagraphsType');
}
}