src/IrcConnection.php
protected function realLoadModule(
        $module,
        $chan,
        $flags,
        &$plainModules,
        &$channelModules
    ) {
        if ($chan !== null) {
            if (isset($channelModules[$chan][$module])) {
                return $channelModules[$chan][$module];
            }
        } elseif (isset($plainModules[$module])) {
            return $plainModules[$module];
        }

        if (!class_exists($module, true)) {
            throw new \Erebot\InvalidValueException("No such class '$module'");
        }

        if (!is_subclass_of($module, '\\Erebot\\Module\\Base')) {
            throw new \Erebot\InvalidValueException(
                "Invalid module! Not a subclass of \\Erebot\\Module\\Base."
            );
        }

        $reflector = new \ReflectionClass($module);
        $instance = new $module($chan);
        if ($chan === null) {
            $plainModules[$module] = $instance;
        } else {
            $channelModules[$chan][$module] = $instance;
        }

        $instance->reloadModule($this, $flags);
        $logger = \Plop\Plop::getInstance();
        $logger->info(
            $this->bot->gettext("Successfully loaded module '%(module)s' [%(source)s]"),
            array(
                'module' => $module,
                'source' => (substr($reflector->getFileName(), 0, 7) == 'phar://')
                            ? $this->bot->gettext('PHP archive')
                            : $this->bot->gettext('regular file'),
            )
        );
        return $instance;
    }
protected function realLoadModule(
        $module,
        $chan,
        $flags,
        &$plainModules,
        &$channelModules
    ) {
        if ($chan !== null) {
            if (isset($channelModules[$chan][$module])) {
                return $channelModules[$chan][$module];
            }
        } elseif (isset($plainModules[$module])) {
            return $plainModules[$module];
        }

        if (!class_exists($module, true)) {
            throw new \Erebot\InvalidValueException("No such class '$module'");
        }

        if (!is_subclass_of($module, '\\Erebot\\Module\\Base')) {
            throw new \Erebot\InvalidValueException(
                "Invalid module! Not a subclass of \\Erebot\\Module\\Base."
            );
        }

        $reflector = new \ReflectionClass($module);
        $instance = new $module($chan);
        if ($chan === null) {
            $plainModules[$module] = $instance;
        } else {
            $channelModules[$chan][$module] = $instance;
        }

        $instance->reloadModule($this, $flags);
        $logger = \Plop\Plop::getInstance();
        $logger->info(
            $this->bot->gettext("Successfully loaded module '%(module)s' [%(source)s]"),
            array(
                'module' => $module,
                'source' => (substr($reflector->getFileName(), 0, 7) == 'phar://')
                            ? $this->bot->gettext('PHP archive')
                            : $this->bot->gettext('regular file'),
            )
        );
        return $instance;
    }
protected function realLoadModule ( $ module , $ chan , $ flags , & $ plainModules , & $ channelModules ) { if ( $ chan !== null ) { if ( isset ( $ channelModules [ $ chan ] [ $ module ] ) ) { return $ channelModules [ $ chan ] [ $ module ] ; } } elseif ( isset ( $ plainModules [ $ module ] ) ) { return $ plainModules [ $ module ] ; } if ( ! class_exists ( $ module , true ) ) { throw new \ Erebot \ InvalidValueException ( "No such class '$module'" ) ; } if ( ! is_subclass_of ( $ module , '\\Erebot\\Module\\Base' ) ) { throw new \ Erebot \ InvalidValueException ( "Invalid module! Not a subclass of \\Erebot\\Module\\Base." ) ; } $ reflector = new \ ReflectionClass ( $ module ) ; $ instance = new $ module ( $ chan ) ; if ( $ chan === null ) { $ plainModules [ $ module ] = $ instance ; } else { $ channelModules [ $ chan ] [ $ module ] = $ instance ; } $ instance -> reloadModule ( $ this , $ flags ) ; $ logger = \ Plop \ Plop :: getInstance ( ) ; $ logger -> info ( $ this -> bot -> gettext ( "Successfully loaded module '%(module)s' [%(source)s]" ) , array ( 'module' => $ module , 'source' => ( substr ( $ reflector -> getFileName ( ) , 0 , 7 ) == 'phar://' ) ? $ this -> bot -> gettext ( 'PHP archive' ) : $ this -> bot -> gettext ( 'regular file' ) , ) ) ; return $ instance ; }
Load a single module for this connection.

\param string $module
Name of the module to load. If the module
is already loaded, nothing will happen.

\param string|null $chan
Name of the IRC channel for which this module
is being loaded. Pass \b null to load a module
globally (for the whole connection) rather than
for a specific IRC channel.

\param opaque $flags
Bitwise-OR combination of flags to pass to
the module's initialization method.

\param array $plainModules
An associative array containing the global modules
currently loaded. This array will be updated if it
needs to be once the module has been successfully
loaded.

\param array $channelModules
An associative array containing the modules currently
loaded for the given IRC channel. This array will be
updated if it needs to be once the module has been
successfully loaded.

\retval Erebot::Module::Base
An instance of the module with the given name.
Load a single module for this connection .