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

zend-barcode without zend-servicemanager and zend-validator #6293

Closed
oscherler opened this issue May 19, 2014 · 6 comments
Closed

zend-barcode without zend-servicemanager and zend-validator #6293

oscherler opened this issue May 19, 2014 · 6 comments
Assignees
Milestone

Comments

@oscherler
Copy link
Contributor

Is there any way to use zendframework/zend-barcode without zendframework/zend-servicemanagerand zendframework/zend-validator? I’d say “no” for zend-validator and “yes, albeit in a convoluted way” for zend-servicemanager.

If not, they should be in the require section of the composer.json.

@Ocramius
Copy link
Member

@oscherler do you have any specific failures to report on this? Wondering what API is failing if those two components are not included.

@Ocramius Ocramius added this to the 2.3.2 milestone May 19, 2014
@oscherler
Copy link
Contributor Author

I made a sample in this gist.

Apparently, zend-servicemanager is only needed if you use the factory method shown in Barcode creation using Zend\Barcode\Barcode class, so all is good.

zend-validator, on the other hand, seems to be needed as soon as you call draw() on a subclass of Zend\Barcode\Object\AbstractObject, which is done by each provided renderer’s render() method (in AbstractRenderer::drawInstructionList()).

I copy the relevant portion of the gist below:

use Zend\Barcode\Barcode;

$barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
$barcode = new Zend\Barcode\Object\Code39( $barcodeOptions );

$rendererOptions = array();
$renderer = new Zend\Barcode\Renderer\Image( $rendererOptions );

$renderer->setBarcode( $barcode )->render();

PHP Fatal error: Class 'Zend\Validator\Barcode' not found in /home/olivier/tests/zend-barcode/vendor/zendframework/zend-barcode/Zend/Barcode/Object/AbstractObject.php on line 1200

@Ocramius
Copy link
Member

Yeah, so I suppose that the zendframework/zend-servicemanager should be in suggest, while zendframework/zend-validator should be in require.

A bit annoying, but better than having failures (for now)

@oscherler
Copy link
Contributor Author

Yes, and maybe the suggest could say something like “Required when using the factory methods”.

@Ocramius
Copy link
Member

Correct.

@oscherler want to send a PR or should I do it later?

@Ocramius Ocramius self-assigned this May 19, 2014
@oscherler
Copy link
Contributor Author

I’ll make a PR.

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

No branches or pull requests

2 participants