background image

return

 htmlentities(

$value

); 


}
</PRE><PRE 

class

=php name="code"> 

/** 

* The Mediator. We avoid referencing it from ConcreteColleagues 
* and so the need for an interface. We leave the implementation 
* of a bidirectional channel for the Observer pattern's example. 
* This class responsibility is to store the value and coordinate 
* filters computation when they have to be applied to the value. 
* Filtering responsibilities are obviously a concern of 
* the Colleagues, which are Filter implementations. 
*/

 

class

 InputElement 

protected

 

$_filters

protected

 

$_value

 

public

 

function

 addFilter(Filter 

$filter

$this

->_filters[] = 

$filter

return

 

$this


 

public

 

function

 setValue(

$value

$this

->_value = 

$this

->_filter(

$value

); 


 

protected

 

function

 _filter(

$value

foreach

 (

$this

->_filters 

as

 

$filter

) { 

$value

 = 

$filter

->filter(

$value

); 

return

 

$value


 

public

 

function

 getValue()