This package has been deprecated

Author message:

there is no replacement, please check @chubbyts/chubbyts-dic-config

@chubbyjs/chubbyjs-laminas-config-factory

1.0.1 • Public • Published

chubbyjs-laminas-config-factory

CI Coverage Status Infection MSI npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

An abstract service factory for chubbyjs/chubbyjs-laminas-config or any other similar implementation.

Requirements

Installation

Through NPM as @chubbyjs/chubbyjs-laminas-config-factory.

npm i @chubbyjs/chubbyjs-laminas-config-factory@1.0.1

Usage

import ServiceA from './ServiceA';
import ServiceB from './ServiceB';
import ServiceC from './ServiceC';
import ServiceBFactory from './ServiceBFactory';
import AbstractBaseFactory, { Invokable } from '@chubbyjs/chubbyjs-laminas-config-factory/dist/BaseFactory';
import ContainerInterface from '@chubbyjs/psr-container/dist/ContainerInterface';

const ServiceAFactory = Invokable(class extends AbstractBaseFactory {
    public __invoke(container: ContainerInterface): ServiceA {
        return new ServiceA(
            this.resolveConfig(container.get('config').serviceA ?? {}),
            this.resolveDependency<ServiceB>(container, ServiceB.name,  ServiceBFactory),
            this.resolveDependency<ServiceC>(container, ServiceC.name,  ServiceCFactory),
        );
    }
});

// ContainerInterface
const container = ...;

// without name
const serviceA = ServiceAFactory()(container);

// with name
const serviceA = ServiceAFactory('default')(container);

Copyright

Dominik Zogg 2021

Package Sidebar

Install

npm i @chubbyjs/chubbyjs-laminas-config-factory

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

10.4 kB

Total Files

7

Last publish

Collaborators

  • dominikzogg