GithubHelp home page GithubHelp logo

godfather's People

Contributors

claudio-dalicandro avatar liuggio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

godfather's Issues

[symfony-bundle] Multiple instances

Could be great have a way to configure the bundle in order to have multiple instances of the service, this is useful when you want to separate concern.

godfather:
    death:
        contexts:
            manager:
                interface: \ABInterface
    life:
        default: true
        contexts:   
            manager: 
                interface: \ABInterface

the strategies:

services:
    manager.entity_life:
        class: EntityProductManager
       arguments:    ['life']
        tags:
            -  { name: godfather.strategy, instance:'life', context_name: 'manager', context_key: %product.show.class% }

      manager.entity_death:
        class: EntityProductManager
       arguments:    ['death']
        tags:
            -  { name: godfather.strategy, instance:'death', context_name: 'manager', context_key: %product.show.class% }

and then the code with multiple instances

$this->getContainer('godfather.life')->getManager($entity);
$this->getContainer('godfather.death')->getManager($entity);

cons

this will introduce a BC

[Symfony bundle][easy-pick] Avoid recreate another container of classes

Is very bad practice recreate the container.

Should be great if the symfony bundle could use the container of the framework, instead of a personal array of services.

The step should be:

  1. create a class that extends Godfather
  2. inject into this new class the container
  3. replacing the getStrategy with something like:
    /**
     * Get the strategy for the key ($contextName, $context).
     *
     * @param string $contextName
     * @param mixed $context
     *
     * @return mixed
     */
    public function getStrategy($contextName, $context)
    {
        $contexts = $this->getContext();
        $serviceId = $contexts[$contextName]->getStrategy($context);

        return $this->container->get($serviceId);
    }

Another option could be not inject the container and uses the getStrategy in order to retrieve the name of the service not the service itself
eg

$strategyServiceId = $this->container->get('godfather')->getStrategy('xyz', $class);
$this->container->get($strategyServiceId)->doSomething();

Move hardcoding into configuration

In order to not recreate a new definition and use instead the alias on standard contexts, the FQCN is harcoded on non standard context.

A cleaner solution would be using the Configuration.

the defahttps://github.com/PUGX/godfather/blob/master/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php#L72

Strategy discrimination on abstract class or interface

The context_key that works as discriminator for a strategy is a concrete class. Would it be useful extending this discrimination to abstract classes and interfaces?

services:
    manager.standard:
        class: StandardProductManager

    manager.shoe:
        class: ShoeProductManager
        tags:
            -  { name: godfather.strategy, context_name: 'manager', context_key: PUGX\CartBundle\FootWear\AbstractShoe }

thus I can treat Sneakers, HighHeels and HikingBoots with a single strategy.
Does it make sense? do you see any dangerous side effect ?

[sf2] improve usability

Add name as key into the dependency injection.

The goal is remove the name key from the configuration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.