Back to WorkflowPluginTrait class

Method checkAllowedAndForbiddenlist

protected bool
checkAllowedAndForbiddenlist
(mixed $context)
Check if the context is listed in the allowed of forbidden lists and return the result.
Parameters
  • string $context Context to check
Returns
  • bool

Method checkAllowedAndForbiddenlist - Source code

/**
 * Check if the context is listed in the allowed of forbidden lists and return the result.
 *
 * @param   string $context Context to check
 *
 * @return  boolean
 */
protected function checkAllowedAndForbiddenlist($context)
{
    $allowedlist = \array_filter((array) $this->params->get('allowedlist', []));
    $forbiddenlist = \array_filter((array) $this->params->get('forbiddenlist', []));
    if (!empty($allowedlist)) {
        foreach ($allowedlist as $allowed) {
            if ($context === $allowed) {
                return true;
            }
        }
        return false;
    }
    foreach ($forbiddenlist as $forbidden) {
        if ($context === $forbidden) {
            return false;
        }
    }
    return true;
}