mixerapi/core

MixerAPI Core libraries

v1.0.0 2022-01-16 15:18 UTC

This package is auto-updated.

Last update: 2022-01-16 15:18:47 UTC


README

Latest Version on Packagist Build Coverage Status MixerApi CakePHP Minimum PHP Version

Core library for easily sharing commonly used classes and utilities across MixerAPI plugins.

Installation

composer require mixerapi/core

Event Listener Loader

The Event Listener Loader will automatically load all listeners which implement Cake\Event\EventListenerInterface within a given namespace. Example:

# src/Application.php
use Cake\Http\BaseApplication;
use MixerApi\Core\Event\EventListenerLoader;

class Application extends BaseApplication
{
    public function bootstrap(): void
    {
        // ...other code
        (new EventListenerLoader())->load();
        // other code...
    }
}

The default behavior loads all listeners in App\Event. You can pass a different namespace argument as load($namespace) if your listeners are located elsewhere.

Namespace Utility

Returns one or more classes in a given namespace.

use MixerApi\Core\Utility\NamespaceUtility;

$controllers = NamespaceUtility::findClasses('\App\Controller');
$controller = NamespaceUtility::findClasses('\App\Controller', 'ActorsController');