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

Mandatory Value Parameters can not be parsed #2

Closed
weierophinney opened this issue Dec 31, 2019 · 3 comments
Closed

Mandatory Value Parameters can not be parsed #2

weierophinney opened this issue Dec 31, 2019 · 3 comments

Comments

@weierophinney
Copy link
Member

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.


Originally posted by @zf2timo at zendframework/zend-console#27

@weierophinney
Copy link
Member Author

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.


Originally posted by @mtymek at zendframework/zend-console#27 (comment)

@weierophinney
Copy link
Member Author

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


Originally posted by @zf2timo at zendframework/zend-console#27 (comment)

@weierophinney
Copy link
Member Author

This package is abandoned and will receive no further development!

We recommend using laminas/laminas-cli.

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

1 participant