class ToolbarItemDependencyConstraintValidator

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/Validation/Constraint/ToolbarItemDependencyConstraintValidator.php \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator
  2. 10 core/modules/ckeditor5/src/Plugin/Validation/Constraint/ToolbarItemDependencyConstraintValidator.php \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator

Toolbar item dependency constraint validator.

@internal

Hierarchy

Expanded class hierarchy of ToolbarItemDependencyConstraintValidator

File

core/modules/ckeditor5/src/Plugin/Validation/Constraint/ToolbarItemDependencyConstraintValidator.php, line 17

Namespace

Drupal\ckeditor5\Plugin\Validation\Constraint
View source
class ToolbarItemDependencyConstraintValidator extends ConstraintValidator implements ContainerInjectionInterface {
    use PluginManagerDependentValidatorTrait;
    
    /**
     * {@inheritdoc}
     *
     * @throws \Symfony\Component\Validator\Exception\UnexpectedTypeException
     *   Thrown when the given constraint is not supported by this validator.
     */
    public function validate($toolbar_item, Constraint $constraint) : void {
        if (!$constraint instanceof ToolbarItemDependencyConstraint) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\\ToolbarItemDependency');
        }
        $toolbar_items = $this->context
            ->getRoot()
            ->get('settings.toolbar.items')
            ->toArray();
        if (!in_array($constraint->toolbarItem, $toolbar_items, TRUE)) {
            $this->context
                ->buildViolation($constraint->message)
                ->setParameter('%toolbar_item', $constraint->toolbarItem)
                ->addViolation();
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
PluginManagerDependentValidatorTrait::$pluginManager protected property The CKEditor 5 plugin manager.
PluginManagerDependentValidatorTrait::create public static function 1
PluginManagerDependentValidatorTrait::getEnableableDisabledPlugins private function Gets all disabled CKEditor 5 plugin definitions the user can enable.
PluginManagerDependentValidatorTrait::getOtherEnabledPlugins private function Gets all other enabled CKEditor 5 plugin definitions.
PluginManagerDependentValidatorTrait::__construct public function Constructs a CKEditor5ConstraintValidatorTrait object. 1
ToolbarItemDependencyConstraintValidator::validate public function

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