You are here

class ParagraphsLibraryItemHasAllowedParagraphsTypeConstraint in Paragraphs 8

Checks that the library does not bypass Paragraphs type restrictions.

A common usecase is to have a "From library" Paragraphs type with an entity reference field to Paragraphs library items. The Paragraphs type of library item that the "From library" Paragraph references must be allowed in the field that holds "From library" Paragraph, if that field has this constraint.

Plugin annotation


@Constraint(
  id = "ParagraphsLibraryItemHasAllowedParagraphsType",
  label = @Translation("Paragraphs type of Paragraphs library item's root is allowed in the parent field.", context = "Validation"),
  type = {"entity"}
)

Hierarchy

Expanded class hierarchy of ParagraphsLibraryItemHasAllowedParagraphsTypeConstraint

File

modules/paragraphs_library/src/Plugin/Validation/Constraint/ParagraphsLibraryItemHasAllowedParagraphsTypeConstraint.php, line 22

Namespace

Drupal\paragraphs_library\Plugin\Validation\Constraint
View source
class ParagraphsLibraryItemHasAllowedParagraphsTypeConstraint extends Constraint {

  /**
   * The default violation message.
   *
   * @var string
   */
  public $message = 'The @library_item_field_label field cannot contain a @paragraphs_type_label paragraph, because the parent @paragraph_field_label field disallows it.';

}

Members