3

I have a plugin that looks like this:

class plgExtensionLogInstall extends JPlugin
{

    function onExtensionAfterInstall($installer, $extensionId) 
    {
        JLog::add("Extension installed: ".$extensionId, JLog::DEBUG, 'plg_extension_log_install);
    }
}

This installs correctly and I can enable it, but when I install another extension it is never triggered.

Putting some extra logging in /libraries/joomla/event/dispatcher.php I can see two event listeners hooked to onextensionafterinstall but neither of them is mine. The Extension XML file only contains the standard extension description and a files section like this:

<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="extension">
    <name>Plugin Logger</name>
    <version>0.0.1</version>
    <files>
        <filename plugin="installer_log">installer_log.php</filename>
        <filename>index.html</filename>
    </files>
</extension>

The event is never triggered, but if the code is broken it does crash when the installer would run. What is missing from my class or configuration?

5

Plugin class name must match the plugin name defined in manifest file.

If you have this in the manifest:

<filename plugin="installer_log">installer_log.php</filename>

Then class name should be PlgExtensionInstaller_Log.

Other way around, if class is PlgExtensionLogInstall, then manifest should contain this:

<filename plugin="loginstall">loginstall.php</filename>
  • 1
    That was it! One of the problems with design by convention is that it can be very hard to figure out which parts are design-critical. – glenatron Jul 8 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.