root/trunk/patForms/Observer/ErrorAttributes.php

Revision 82, 1.4 kB (checked in by schst, 5 years ago)

added first draft of the observers that allow very flexible error handling (happy documenting, mr. argh!)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * patForms observer base class
4  *
5  * $Id$
6  *
7  * @access        protected
8  * @package        patForms
9  * @subpackage    Observers
10  */
11
12 /**
13  * patForms observer base class
14  *
15  * @access        protected
16  * @package        patForms
17  * @subpackage    Observers
18  * @author        Stephan Schmidt <schst@php-tools.net>
19  * @license        LGPL, see license.txt for details
20  * @link        http://www.php-tools.net
21  */
22 class patForms_Observer_ErrorAttributes extends patForms_Observer
23 {
24    /**
25     * attributes that will be set if the status is 'error'
26     *
27     * @access    private
28     * @param    array
29     */
30     var $_errorAttributes = array();
31
32    /**
33     * set the attributes that should be used on error
34     *
35     * @access    public
36     * @param    array        new attributes
37     */
38     function setAttributes( $atts )
39     {
40         $this->_errorAttributes = $atts;
41     }
42
43    /**
44     * method called by patForms or any patForms_Element to signalise
45     * an event
46     *
47     * @access    public
48     * @param    object        Either a patForms or patForms_Element object
49     * @param    string        Property, that has changed (currently only 'status' is possible)
50     * @param    mixed        new value of the property
51     * @return    boolean     should always return true
52     */
53     function notify( &$container, $property, $value )
54     {
55         /**
56          * act only on a status change
57          */
58         if( $property != 'status' )
59             return true;
60
61         if( $value != 'error' )
62             return true;
63             
64         $container->setAttributes( $this->_errorAttributes );
65         return true;
66     }
67 }
68 ?>
Note: See TracBrowser for help on using the browser.