Skip to content
This repository has been 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
settermjd opened this issue Jan 13, 2017 · 2 comments

Comments

@settermjd
Copy link

@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.

@settermjd
Copy link
Author

fwiw, great job on the class. The generated classes are excellently formatted, with proper docblock comments, etc. Thanks for making this happen.

@settermjd settermjd changed the title Factories created by generate-factory-for-class specify a fully-qualified namespace for classes pulled from the container Factories created by generate-factory-for-class have fully-qualified namespace for classes pulled from the container Jan 13, 2017
@weierophinney
Copy link
Member

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

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

No branches or pull requests

2 participants