Actions

API16

JPlugin/ construct

From Joomla! Documentation

< API16:JPlugin
Revision as of 05:17, 30 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Constructor

[Edit Descripton]

Description:JPlugin/ construct

Syntax

__construct(&$subject, $config=array())
Parameter Name Default Value Description
&$subject $subject The object to observe
$config array() $config An optional associative array of configuration settings. Recognized key values include 'name', 'group', 'params' (this list is not meant to be comprehensive).

Defined in

libraries/joomla/plugin/plugin.php

Importing

jimport( 'joomla.plugin.plugin' );

Source Body

public function __construct(&$subject, $config = array())
{
        // Get the parameters.
        if (isset($config['params']))
        {
                if ($config['params'] instanceof JParameter) {
                        $this->params = $config['params'];
                } else {
                        $this->params = new JParameter($config['params']);
                }
        }
 
        // Get the plugin name.
        if (isset($config['name'])) {
                $this->_name = $config['name'];
        }
 
        // Get the plugin type.
        if (isset($config['type'])) {
                $this->_type = $config['type'];
        }
        $events = get_class_methods($this);
        foreach($events as $event)
        {
                $method = array('event' => $event, 'handler' => array($this, 'onFireEvent'));
                $subject->attach($method);
        }
        parent::__construct($subject);
}

[Edit See Also] SeeAlso:JPlugin/ construct

Examples

<CodeExamplesForm />