CoolCMS API

AdvertParameterPolicyTrait

Parameter rules of an advert save (Bazaar, Comcat) that the front form enforces, also for the Api: a value longer than `max_length` (editor: visible text), a URL with `throw_error_on_url`, a blacklisted word of the page language with `throw_error_on_blacklisted_word`, an empty required value and a choice option the form would not offer.

Required and offered options follow the parameter rules exactly as the form does (ParameterRuleEvaluator): a parameter targeted by a display rule is required only while the rule's conditions hold, an option controlled by a reveal rule is allowed only while its rule's conditions hold. Uploaders and hidden fields are not required here (their files are not parameter values).

Like AdvertCategoryPolicyTrait, only a non-privileged caller is checked (by FieldAudienceContext); an administrator and calls without an Api caller (cron, CLI) are not. All reads are scalar (save hook).

Requires in the host class: $this->fieldAudienceContext (?FieldAudienceContext), $this->blacklistedWordManager (?BlacklistedWordManager) and parameterRuleContextFor().

Tags
phpstan-import-type

Rule from ParameterRuleEvaluator

Item from ParameterRuleEvaluator

Table of Contents

Methods

parameterRuleContextFor()  : Rule>, options: array>}
guardParameterValues()  : Result|null
Value and option rules apply to every save; required ones only when the save carries the parameters (`$checkRequired`: insert, or the form marked them as sent), since an update without them does not hold the full set.
parameterRefusal()  : Result

Methods

parameterRuleContextFor()

protected abstract parameterRuleContextFor(array<int, int> $categoryIds) : Rule>, options: array>}
Parameters
$categoryIds : array<int, int>
Return values
Rule>, options: array>}

guardParameterValues()

Value and option rules apply to every save; required ones only when the save carries the parameters (`$checkRequired`: insert, or the form marked them as sent), since an update without them does not hold the full set.

private guardParameterValues(object $advert, array<int, int> $categoryIds, bool $checkRequired) : Result|null
Parameters
$advert : object
$categoryIds : array<int, int>
$checkRequired : bool
Return values
Result|null
On this page

Search results