filterChain = new AttributeFilterChain; if (isset($options)) { foreach ($options as $optionName => $optionValue) { $this->__set($optionName, $optionValue); } } } /** * Return whether this attribute is safe to be used in given context * * @param string $context Either 'AsURL', 'InCSS' or 'InJS' * @return bool */ protected function isSafe($context) { // Test this attribute's filters $methodName = 'isSafe' . $context; foreach ($this->filterChain as $filter) { if ($filter->$methodName()) { // If any filter makes it safe, we consider it safe return true; } } return !empty($this->markedSafe[$context]); } /** * {@inheritdoc} */ public function asConfig() { $vars = get_object_vars($this); unset($vars['markedSafe']); return ConfigHelper::toArray($vars) + ['filterChain' => []]; } }