7.22. Opt_Component_Interface
7.22.1. __construct()
7.22. Opt_Component_Interface
« Previous
7.22.2. defined()
Next »

7.22.1. __construct()

ConstructClass constructor
Visibilitypublic
Reference__construct([string $name = ''])
Argument list
$name - string
The component name.

The component constructor. For user convenience, it might take an optional argument called $name that can be used to initialize one of the component parameters. For example, you can use the following constructor:

class myComponent implements Opt_Component_Interface
{
    private $_params = array();
 
    public function __construct($name = '')
    {
        if($name != '')
        {
            $this->set('name', $name);
        }
    } // end __construct();
 
    // Other code...
} // end myComponent;

Now, to specify the component name, we can pass it directly in the constructor:

// You can write
$component = new myComponent('someName');
 
// or
$component = new myComponent();
$component->set('name', 'someName');
7.22.1. __construct()
7.22. Opt_Component_Interface
« Previous
7.22. Opt_Component_Interface
Next »
7.22.2. defined()