gisostallenberg/velpon-loader

There is no license information available for the latest version (0.1.0) of this package.

Dynamic glue for classes in a stack

0.1.0 2018-10-29 17:12 UTC

This package is auto-updated.

Last update: 2024-10-24 05:13:21 UTC


README

Velpon loader glues classes defined in a variable stack together. See https://nl.wikipedia.org/wiki/Ceta-Bever for the origin of the name.

Please not that this package is able to initialize an arbitrary class stack for a variable defined stack. It is not able to change already initialized (constructed) classes.

This package is meant to be used in a BC manner for existing projects implementing this style of loading. WARNING: It is strongly discouraged to use this for any new projects. Please use services, events and the like to be able to 'plug' into behavior.

Installation

composer require gisostallenberg/velpon-loader

Usage example

use GisoStallenberg\VelponLoader\VelponLoader;

// Note that the stack order is reversed (ClassToPlug extends ClassToPlugPluginOne extends ClassToPlugPluginTwo)
VelponLoader::register([
    'plugin_two' => [
        'ClassToPlug' => 'ClassToPlugPluginTwo'
    ],
    'plugin_one' => [
        'ClassToPlug' => 'ClassToPlugPluginOne'
    ],
]);

Files:

// ClassToPlug.php
class ClassToPlugPluggable {}

// ClassToPlugPluginOne.php
class ClassToPlugPluginOne extends ClassToPlugPluginOneVelpon {} 

// ClassToPlugPluginTwo.php
class ClassToPlugPluginTwo extends ClassToPlugPluginTwoVelpon {} 

Todo

Protect abstract classes from constructing without a non abstract parent