This repository was archived by the owner on Feb 6, 2020. It is now read-only.
This repository was archived by the owner on Feb 6, 2020. It is now read-only.
Factories created by generate-factory-for-class have fully-qualified namespace for classes pulled from the container #172
Open
Description
@weierophinney, here is the issue, as requested.
As I was researching generate-factory-for-class
today to create a tutorial on it, I noticed that while most classes referenced in the factory classes it generates were relative, with their fully qualified namespaces included via use
statements, classes which were pulled from the container were not.
Here's an example of what I mean:
<?php
namespace App\ServiceManager\TableGateway;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use App\ServiceManager\TableGateway\JournalTable;
class JournalTableFactory implements FactoryInterface
{
/**
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
* @return JournalTable
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
// Note that \Zend\Db\TableGateway\TableGateway is fully qualified
return new JournalTable(
$container->get(\Zend\Db\TableGateway\TableGateway::class)
);
}
}
I'm not sure if there's something that I've missed; but to me, for consistency's sake if nothing else, it makes sense to have classes retrieved from the container be relative as well.
Metadata
Metadata
Assignees
Labels
No labels