Giter Site home page Giter Site logo

bazzline / php_component_locator_generator Goto Github PK

View Code? Open in Web Editor NEW
1.0 5.0 0.0 829 KB

free as in freedom free software php locator generator component to easy up locator generation

License: GNU Lesser General Public License v3.0

PHP 100.00%
bazzline php builder php56 php7 generator locator free-as-in-freedom lgplv3

php_component_locator_generator's People

Contributors

stevleibelt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php_component_locator_generator's Issues

generate locator has to implement "LocatorInterface" if at least one "is_factory" is true

If you add a "is_factory" => true, you get the following error.

Argument 1 passed to BlaBlaFactory::setLocator() must be an instance of Net\Bazzline\Component\Locator\LocatorInterface, instance of BlaBlaLocator given

Whenever "is_factory" is configure to "true", the "implements" configuration section has to be extended by "Net\Bazzline\Component\Locator\LocatorInterface" automatically.

last entry in "class_name" is used everywhere to generate new instance

example generated locator

//....

    /**
     * @return \Net\Bazzline\Component\Cli\Arguments\Arguments
     */
    public function getCliArguments()
    {
        return $this->fetchFromSharedInstancePool('\Net\Bazzline\Component\CommandCollection\Filesystem\Remove');
    }

    /**
     * @return \Net\Bazzline\Component\ApiDocumentBuilder\Builder\Apigen
     */
    public function getApigenBuilder()
    {
        return $this->fetchFromSharedInstancePool('\Net\Bazzline\Component\CommandCollection\Filesystem\Remove');
    }
//...

method "isNotInFactoryInstancePool" and "addToFactoryInstancePool" are not created if configuration is set to "'is_factory' => false,"

    'instances' => array(
        array(
            //...
            'is_factory'    => false,
            'is_shared'     => true,

Configuration above will generate locator method like:

    final protected function fetchFromSharedInstancePool($className)
    {
        if ($this->isNotInFactoryInstancePool($className)) {
            if (!class_exists($className)) {
                throw new InvalidArgumentException(
                    'class "' . $className . '" does not exist'
                );
            }

            $instance = new $className();
            $this->addToFactoryInstancePool($className, $instance);
        }

        return $this->getFromSharedInstancePool($className);
    }

'addToSharedInstancePool' and 'isNotInSharedInstancePool' should be used.

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.