/** @test */ public function disallowKeys() { $context = new Context(array('foo' => 'bar', 'xxx' => 'yyy')); $filter = new FilterContext(); $filter->setKeys('foo')->setMode(FilterContext::DISALLOW_KEYS)->perform($context); $this->assertFalse($context->offsetExists('foo')); $this->assertTrue($context->offsetExists('xxx')); }
/** {@inheritdoc} */ public function parse(\DOMElement $actionElement, Rule $rule, \DOMXPath $xpath) { $action = new FilterContext(); if ($actionElement->hasAttribute('allow-keys')) { $keys = $actionElement->getAttribute('allow-keys'); $action->setMode(FilterContext::ALLOW_KEYS); } else { $keys = $actionElement->getAttribute('disallow-keys'); $action->setMode(FilterContext::DISALLOW_KEYS); } $action->setKeys(array_filter(preg_split('/\\s+/', $keys))); $rule->appendAction($action, $actionElement->getAttribute('stage')); return $action; }