ZF-14: Remove Zend_Pdf_Const

Description

Zend_Pdf_Const was initially conceived as the single home for all PDF-related constants. This worked well enough when the number of constants was small, but recent work (ZF-6 and Zend_Pdf_Image subclasses) has more than tripled the constant count, making a master class like this difficult to maintain.

None of the other components in the framework share this model; they all define constants in the base classes that use them. For consistency with the other components in the framework, and to improve maintainability going forward, move the constants currently defined in Zend_Pdf_Const to the base classes in which they are used.

Comments

This issue necessitates a change to the public API. Specific details to follow...

Done. This issue caused a backwards-incompatible API change. To repair your code, you will need to perform the following global search-and-replace operations:

 
Zend_Pdf_Const::PAGESIZE_     ->  Zend_Pdf_Page::SIZE_
Zend_Pdf_Const::SHAPEDRAW_    ->  Zend_Pdf_Page::SHAPEDRAW_
Zend_Pdf_Const::FILLMETHOD_   ->  Zend_Pdf_Page::FILLMETHOD_
Zend_Pdf_Const::LINEDASHING_  ->  Zend_Pdf_Page::LINEDASHING_
Zend_Pdf_Const::PDF_          ->  Zend_Pdf::PDF_
Zend_Pdf_Const::pdfDate()     ->  Zend_Pdf::pdfDate()

In addition, font object creation has been revamped. Font objects are now instantiated via a factory methods. You will also need to perform the following global search-and-replace operation:

 
new Zend_Pdf_Font_Standard(Zend_Pdf_Const::FONT_  ->
  Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_

Finally, the old static arrays {{$pageSizeAliases}} and {{$standardFonts}} have been completely removed. There are no replacements.

On Jun 17, 2006, at 4:04 PM, andi@zend.com wrote:

I have one piece of feedback though. The constants (not sure if you are responsible for naming them or not) don't use underscores to separate words. I think it'd be much nicer to do so. I know we have it in the PHP coding standards, but not sure if we wrote it in the ZFW coding standards (if not we should).

Implemented Andi's request. All constants in Zend_Pdf now have underscores between words.

{panel:title=NOTE: Due to this change, ignore the instructions above and use these instead.|titleBGColor=#F7D6C1|bgColor=#FFFFCE} To repair your code, you will need to perform the following global search-and-replace operations:

Zend_Pdf_Const::PAGESIZE_                 -> Zend_Pdf_Page::SIZE_
Zend_Pdf_Const::SHAPEDRAW_FILLNSTROKE     -> Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE
Zend_Pdf_Const::SHAPEDRAW_                -> Zend_Pdf_Page::SHAPE_DRAW_
Zend_Pdf_Const::FILLMETHOD_NONZEROWINDING -> Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING
Zend_Pdf_Const::FILLMETHOD_EVENODD        -> Zend_Pdf_Page::FILL_METHOD_EVEN_ODD
Zend_Pdf_Const::LINEDASHING_              -> Zend_Pdf_Page::LINE_DASHING_
Zend_Pdf_Const::PDF_                      -> Zend_Pdf::PDF_
Zend_Pdf_Const::pdfDate()                 -> Zend_Pdf::pdfDate()

In addition, font object creation has been revamped. Font objects are now instantiated via a factory methods. You will also need to perform the following global search-and-replace operations:

new Zend_Pdf_Font_Standard(Zend_Pdf_Const::FONT_  ->
  Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_

_BOLDITALIC  ->  _BOLD_ITALIC

Finally, the old static arrays $pageSizeAliases and $standardFonts have been completely removed. There are no replacements. {panel}

Updated the coding standards document as well: http://framework.zend.com/wiki/display/…

This change was made eons ago (in Zend Framework time) but the file Zend/Pdf/Const.php still exists. At this point it is safe to remove it entirely.

Fixed with 12192

Changing issues in preparation for the 1.7.0 release.