ExpressionEngine / ExpressionEngine-User-Guide

The source for the HTML ExpressionEngine user guides found at https://docs.expressionengine.com
Apache License 2.0
21 stars 79 forks source link

Add-ons: Extensions, their Hooks, and Installation #198

Closed RK311y closed 1 year ago

RK311y commented 3 years ago

Problem Overview

ExpressionEngine 6.0 introduced the Add-on Installer which helps improve Module and Extensions installation.

The documentation for the Module Installer class includes a $methods (array) property.

// defines an extension's methods and hooks that should be installed
public $methods = [
    [
        'method' => 'run', // will default to same as hook if not defined
        'hook' => 'template_fetch_template' // required
        'priority' => ""
        'enabled' => "" // y/n
    ],
    [
        'method' => 'cleanup', // will default to same as hook if not defined
        'hook' => 'template_post_parse' // required
    ]
];

This exact same property is also defined for Extension Installer.

I believe that in order to maintain the separation of functionality during installation, only the Extention installer should have the ability to install extension hooks through ExpressionEngine\Service\Addon\Installer class inheritance. That is, unless Extension Hooks and Methods can be related to classes that do not follow the file/class name schema (./addon/ext.addon.php::class Addon_ext) - But I have yet to see this.

What Likely Happened

This snippet of code was accidentally copied into the Module Installer code example.

If this is not true, the above concern should be addressed. (i.e. the ability of Module Installers to handle extension hooks/methods installation)

Solution

Check out the pull request I have made in my own fork to see the changes I am suggesting: https://github.com/RK311y/ExpressionEngine-User-Guide/pull/1/files

RK311y commented 3 years ago

PS: I haven't actually tested to see if extension hook data from the $methods property of a Module Installer class actually does anything... I am typically using an ext.addon.php class/file. This is just something I noticed in the documentation.