marm/yamm

Installs: 15 400

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 2

Open Issues: 0

Type:oxid-module

2.0.2 2018-11-07 10:52 UTC

This package is not auto-updated.

Last update: 2024-09-09 06:06:00 UTC


README

English

This meta module provides generally desired functionality, like:

  • A reusable Dependency Injection Container

  • Sensible logging facilities

DIC Usage

The DIC is an extension of Pimple which allows service tagging and is integrated with Oxid eSales.

To use the DIC just put a dic.php in the root of yourproject and register all your services in there. A variable $dic will be available in this fileyou can operate with:

/** @var \Marm\Yamm\DIC $dic */
$dic['acme_module_service'] = function (\Marm\Yamm\DIC $dic) {
    return new Acme\Module\Service(/* ... */);
};

On top of that we allow tagging of services and receiving of all services which are tagged with a defined tag when constructing services:

/** @var \Marm\Yamm\DIC $dic */
$dic->tag('acme_module_service', 'acme:tag');
$dic['acme_module_service'] = function (\Marm\Yamm\DIC $dic) {
    return new Acme\Module\Service(/* ... */);
};

// Somewhere else or later
$dic['acme_module_aggregator'] = function (\Marm\Yamm\DIC $dic) {
    return new Acme\Module\Aggregator(
        // Array of all services tagged with "acme:tag"
        $dic->getTagged('acme:tag')
    );
};

To get the DIC anywhere else in your project, just fetch it from oxRegistry:

/** @var \Marm\Yamm\DIC $dic */
$dic = oxRegistry::get('yamm_dic');

Licence Terms

YAMM is released under MIT.

Use this module in your project but keep the author notice. Thank you!

Authors