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

Mandatory Value Parameters can not be parsed #27

Open
zf2timo opened this issue Aug 23, 2016 · 3 comments
Open

Mandatory Value Parameters can not be parsed #27

zf2timo opened this issue Aug 23, 2016 · 3 comments

Comments

@zf2timo
Copy link

zf2timo commented Aug 23, 2016

I tried to create a route where a group of Value Parameters is mandatory like this example:

<?php
return [
// ....
        'console-export-prepared-products' => [
            'options' => [
                'route' => 'export prepared products (--from-file=|--model=)',
                'defaults' => [
                    'controller' => \Controller\PreparedProductsController::class,
                    'action' => 'export',
                    'verbose' => false,
                ]
            ]
        ],
        //...
  ];

But this results into a InvalidArgumentException:

Fatal error: Uncaught exception 'Zend\Console\Exception\InvalidArgumentException' with message 'Cannot understand Console route at "(--from-file=|--model=)"' in /var/www/mw/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 946
Zend\Console\Exception\InvalidArgumentException: Cannot understand Console route at "(--from-file=|--model=|--recent)" in /var/www/mw/vendor/zendframework/zendframework/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php on line 432

I expected that the route is only matched if either the parameter --from-file or --model is set.

@mtymek
Copy link
Contributor

mtymek commented Aug 23, 2016

At this moment zend-console does not support "alternative parameters". You can only use literal alternative:

( foo | bar )

or flag alternative:

( -x | -c )

I can't promise anything, but I'll try to look into this in coming few days.

@zf2timo
Copy link
Author

zf2timo commented Aug 24, 2016

As a workaround i use a route definition like this:
[--from-file=] [--model=]
And in my controller is a validation for the parameters executed.

@weierophinney
Copy link
Member

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

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

3 participants