HTMLEditorAttributeRule
class HTMLEditorAttributeRule (View source)
Rules used to define whether a given attribute or regex pattern of attributes is allowed in the content of an HTMLEditorField.
Each attribute rule is applied to a single HTMLEditorElementRule matching an element or a regex patter of elements.
Constants
| VALUE_DEFAULT | 
 | 
| VALUE_FORCED | 
 | 
| VALUE_VALID | 
 | 
Methods
Returns a HTMLEditorAttributeRule based on an associative array defining the rule.
No description
Returns true if the value returned from getName() is a regex pattern.
Get the default value the attribute(s) this rule applies to will be set to, if any.
Get the value the attribute(s) this rule applies to will be forced to, if any.
Get whether this attribute rule has a forced or default value.
Get the set of values the attribute(s) this rule applies to is allowed to be set to.
Set whether the attribute(s) this rule applies to must be present for the element to be allowed.
Get whether the attribute(s) this rule applies to must be present for the element to be allowed.
Check wither the given attribute is allowed or not according to this rule.
Details
        
                static            HTMLEditorAttributeRule
    fromArray(string $name, array $ruleArray)
        
    
    Returns a HTMLEditorAttributeRule based on an associative array defining the rule.
If the rule array is empty, the defaults apply.
        
                            
    __construct(string $name, bool $nameIsPattern = false, null|array|string $value = null, string $valueType = HTMLEditorAttributeRule::VALUE_VALID)
        
    
    No description
        
                            string
    getName()
        
    
    Get the name of the attribute(s) this rule applies to.
This can also be a regex pattern - in which case getNameIsPattern() should return true.
        
                            bool
    getNameIsPattern()
        
    
    Returns true if the value returned from getName() is a regex pattern.
        
                            string|null
    getDefaultValue()
        
    
    Get the default value the attribute(s) this rule applies to will be set to, if any.
        
                            string|null
    getForcedValue()
        
    
    Get the value the attribute(s) this rule applies to will be forced to, if any.
A forced value will override any user-provided value.
        
                            bool
    hasForcedOrDefaultValue()
        
    
    Get whether this attribute rule has a forced or default value.
        
                            array
    getValidValues()
        
    
    Get the set of values the attribute(s) this rule applies to is allowed to be set to.
If the array is empty, any value is valid.
        
                            HTMLEditorAttributeRule
    setIsRequired(bool $isRequired)
        
    
    Set whether the attribute(s) this rule applies to must be present for the element to be allowed.
        
                            bool
    getIsRequired()
        
    
    Get whether the attribute(s) this rule applies to must be present for the element to be allowed.
        
                            bool
    isAttributeAllowed(DOMAttr $attribute)
        
    
    Check wither the given attribute is allowed or not according to this rule.
Note that this method assumes this rule applies to the attribute - it does not check the name of the attribute as part of its conditional logic.