Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior in getRegisteredNames() #1355

Closed
jimsafley opened this issue Dec 9, 2018 · 1 comment
Closed

Unexpected behavior in getRegisteredNames() #1355

jimsafley opened this issue Dec 9, 2018 · 1 comment

Comments

@jimsafley
Copy link
Member

Omeka\ServiceManager\AbstractPluginManager::getRegisteredNames()

The method says it "returns only the names that are registered in configuration as invokable classes and factories," but, if aliases are present in the configuration, their keys overwrite the corresponding factory keys.

Take the following:

'my_service' => [
    'factories' => [
        'foo' => 'bar',
    ],
    'aliases' => [
        'baz' => 'foo',
    ],
],

I expect $manager->getRegisteredNames() to return ['foo'] but instead it returns ['baz'].

@jimsafley
Copy link
Member Author

For a practical example:

    'extract_text_extractors' => [
        'factories' => [
            'catdoc' => ExtractText\Service\Extractor\CatdocFactory::class,
            'docx2txt' => ExtractText\Service\Extractor\Docx2txtFactory::class,
            'lynx' => ExtractText\Service\Extractor\LynxFactory::class,
            'pdftotext' => ExtractText\Service\Extractor\PdftotextFactory::class,
        ],
        'invokables' => [
            'filegetcontents' => ExtractText\Extractor\Filegetcontents::class,
        ],
        'aliases' => [
            'application/msword' => 'catdoc',
            'application/pdf' => 'pdftotext',
            'application/rtf' => 'catdoc',
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx2txt',
            'text/html' => 'lynx',
            'text/plain' => 'filegetcontents',
        ],
    ],

$manager->getRegisteredNames() returns:

[
    'application/msword',
    'application/pdf',
    'application/rtf',
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'text/html',
    'text/plain',
    'filegetcontents',
]

but I expect:

[
    'catdoc',
    'docx2txt',
    'lynx',
    'pdftotext',
    'filegetcontents',
]

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

No branches or pull requests

2 participants