class Rule implements RuleInterface, ConfigurableRuleInterface (View source)

A single rule for the web server.

Properties

protected string|callable $code The code of the rule.
protected bool|callable $enabled Is this rule enabled (should be present in the configuration) or disabled (should not be present in the configuration)?
protected string $commentsBefore Optional comments to be placed before the rule itself.
protected string $commentsAfter Optional comments to be placed after the rule itself.
protected Option[] $options The rule options.

Methods

__construct(string|callable $code, bool|callable $enabled, string $commentsBefore = '', string $commentsAfter = '')

Intializes the instance.

string
getCode()

Return the code of the rule.

isEnabled()

Is this rule enabled (should be present in the configuration) or disabled (should not be present in the configuration)?

string
getCommentsBefore()

Return optional comments to be placed before the rule itself.

string
getCommentsAfter()

Return optional comments to be placed after the rule itself.

addOption(string $handle, Option $option)

Add an option to this rule.

Option[]
getOptions()

Get all the rule options.

Option|null
getOption(string $handle)

Get an option given its handle.

Details

__construct(string|callable $code, bool|callable $enabled, string $commentsBefore = '', string $commentsAfter = '')

Intializes the instance.

Parameters

string|callable $code The code of the rule.
bool|callable $enabled Is this rule enabled (should be present in the configuration) or disabled (should not be present in the configuration)?
string $commentsBefore Optional comments to be placed before the rule itself.
string $commentsAfter Optional comments to be placed after the rule itself.

string getCode()

Return the code of the rule.

Return Value

string

See also

RuleInterface::getCode()

isEnabled()

Is this rule enabled (should be present in the configuration) or disabled (should not be present in the configuration)?

See also

RuleInterface::isEnabled()

string getCommentsBefore()

Return optional comments to be placed before the rule itself.

Return Value

string

See also

RuleInterface::getCommentsBefore()

string getCommentsAfter()

Return optional comments to be placed after the rule itself.

Return Value

string

See also

RuleInterface::getCommentsAfter()

addOption(string $handle, Option $option)

Add an option to this rule.

Parameters

string $handle The option handle.
Option $option The option to add.

See also

\Concrete\Core\Service\Rule\ConfigurableRuleInterface::addOption()

Option[] getOptions()

Get all the rule options.

Return Value

Option[]

See also

\Concrete\Core\Service\Rule\RuleInterface::getOptions()

Option|null getOption(string $handle)

Get an option given its handle.

Parameters

string $handle The option handle.

Return Value

Option|null

See also

\Concrete\Core\Service\Rule\ConfigurableRuleInterface::getOption()