function DeletedWorkspaceConstraintValidator::validate

Same name in other branches
  1. 9 core/modules/workspaces/src/Plugin/Validation/Constraint/DeletedWorkspaceConstraintValidator.php \Drupal\workspaces\Plugin\Validation\Constraint\DeletedWorkspaceConstraintValidator::validate()
  2. 10 core/modules/workspaces/src/Plugin/Validation/Constraint/DeletedWorkspaceConstraintValidator.php \Drupal\workspaces\Plugin\Validation\Constraint\DeletedWorkspaceConstraintValidator::validate()
  3. 11.x core/modules/workspaces/src/Plugin/Validation/Constraint/DeletedWorkspaceConstraintValidator.php \Drupal\workspaces\Plugin\Validation\Constraint\DeletedWorkspaceConstraintValidator::validate()

File

core/modules/workspaces/src/Plugin/Validation/Constraint/DeletedWorkspaceConstraintValidator.php, line 45

Class

DeletedWorkspaceConstraintValidator
Checks if data still exists for a deleted workspace ID.

Namespace

Drupal\workspaces\Plugin\Validation\Constraint

Code

public function validate($value, Constraint $constraint) {
    
    /** @var \Drupal\Core\Field\FieldItemListInterface $value */
    // This constraint applies only to newly created workspace entities.
    if (!isset($value) || !$value->getEntity()
        ->isNew()) {
        return;
    }
    if ($this->workspaceAssociation
        ->getTrackedEntities($value->getEntity()
        ->id())) {
        $this->context
            ->addViolation($constraint->message);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.