ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Switch.php
Go to the documentation of this file.
1<?php
2
7{
8
12 protected $tag;
13
17 protected $withTag;
18
22 protected $withoutTag;
23
29 public function __construct($tag, $with_tag, $without_tag)
30 {
31 $this->tag = $tag;
32 $this->withTag = $with_tag;
33 $this->withoutTag = $without_tag;
34 }
35
42 public function validate($string, $config, $context)
43 {
44 $token = $context->get('CurrentToken', true);
45 if (!$token || $token->name !== $this->tag) {
46 return $this->withoutTag->validate($string, $config, $context);
47 } else {
48 return $this->withTag->validate($string, $config, $context);
49 }
50 }
51}
52
53// vim: et sw=4 sts=4
Decorator that, depending on a token, switches between two definitions.
Definition: Switch.php:7
$withTag
@type HTMLPurifier_AttrDef
Definition: Switch.php:17
$withoutTag
@type HTMLPurifier_AttrDef
Definition: Switch.php:22
__construct($tag, $with_tag, $without_tag)
Definition: Switch.php:29
validate($string, $config, $context)
Definition: Switch.php:42