Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Created tool to inject factory maps into configuration #161

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

weierophinney
Copy link
Member

This patch adds a new tool, create-factory-map, which will map a given class to a given factory in the specified configuration file, under the provided configuration key (defaulting to service_manager).

Usage:

  ./vendor/zendframework/zend-servicemanager/bin/create-factory-map [-h|--help|help] <configFile> <className> <factoryName> [<key>]

Arguments:

  -h|--help|help    This usage message
  <configFile>      Path to an config file in which to map the factory.
                    If the file does not exist, it will be created. If
                    it does exist, it must return an array.
  <className>       Name of the class to map to a factory.
  <factoryName>     Name of the factory class to use with <className>.
  [<key>]           (Optional) The top-level configuration key under which
                    the factory map should appear; defaults to
                    "service_manager".

As part of this work, I moved the methods for dumping configuration files into a trait; this trait is now composed by both the ConfigDumper and FactoryMapperCommand.

This patch adds a new tool, `create-factory-map`, which will map a given
class to a given factory in the specified configuration file, under the
provided configuration key (defaulting to `service_manager`).

```
Usage:

  ./vendor/zendframework/zend-servicemanager/bin/create-factory-map [-h|--help|help] <configFile> <className> <factoryName> [<key>]

Arguments:

  -h|--help|help    This usage message
  <configFile>      Path to an config file in which to map the factory.
                    If the file does not exist, it will be created. If
                    it does exist, it must return an array.
  <className>       Name of the class to map to a factory.
  <factoryName>     Name of the factory class to use with <className>.
  [<key>]           (Optional) The top-level configuration key under which
                    the factory map should appear; defaults to
                    "service_manager".
```

As part of this work, I moved the methods for dumping configuration files
into a trait; this trait is now composed by both the `ConfigDumper` and
`FactoryMapperCommand`.
@weierophinney weierophinney added this to the 3.2.0 milestone Sep 22, 2016
@weierophinney
Copy link
Member Author

@GeeH I think this completes the pieces we need for the 3.2 release; can you review?

@svycka
Copy link
Contributor

svycka commented Dec 6, 2016

ping @GeeH would be great to have this can you review? just a reminder in case you forgot :)

@GeeH
Copy link
Contributor

GeeH commented Dec 6, 2016

I spoke to @weierophinney in person which is naughty and I should have commented on here. @weierophinney I suggest we release 3.2 as it is and make further improvements in this area for 3.3.

@weierophinney weierophinney modified the milestones: 3.2.0, 3.2.1 Dec 19, 2016
*/
private function parseArgs(array $args)
{
if (! count($args)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be if (! $args) { like in #199

@Ocramius Ocramius modified the milestones: 3.2.1, 3.4.0 Jan 9, 2018
@Ocramius
Copy link
Member

Ocramius commented Jan 9, 2018

Moved target milestone to 3.4.0

require $a;
} elseif (file_exists($a = __DIR__ . '/../vendor/autoload.php')) {
require $a;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$autoload = array_filter(
    [
        getcwd() . '/autoload.php',
        __DIR__ . '/../../../autoload.php',
        __DIR__ . '/../vendor/autoload.php',
    ],
    'is_file'
);

<?php
/**
* @link http://github.com/zendframework/zend-servicemanager for the canonical source repository
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be 2018?

/**
* @link http://github.com/zendframework/zend-servicemanager for the canonical source repository
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May use https?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney
Copy link
Member Author

This repository has been closed and moved to laminas/laminas-servicemanager; a new issue has been opened at laminas/laminas-servicemanager#21.

@weierophinney
Copy link
Member Author

This repository has been moved to laminas/laminas-servicemanager. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:

  • Squash all commits in your branch (git rebase -i origin/{branch})
  • Make a note of all changed files (`git diff --name-only origin/{branch}...HEAD
  • Run the laminas/laminas-migration tool on the code.
  • Clone laminas/laminas-servicemanager to another directory.
  • Copy the files from the second bullet point to the clone of laminas/laminas-servicemanager.
  • In your clone of laminas/laminas-servicemanager, commit the files, push to your fork, and open the new PR.
    We will be providing tooling via laminas/laminas-migration soon to help automate the process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants