| 1 |
86
|
kore |
=========== |
|
| 2 |
87
|
kore |
API changes |
|
| 3 |
86
|
kore |
=========== |
|
| 4 |
↓
|
kore |
|
|
| 5 |
159
|
kore |
This document documents backwards compatibility breaking API changes. |
|
| 6 |
98
|
kore |
|
|
| 7 |
↓
|
kore |
0.2-alpha to 0.3-alpha |
|
| 8 |
↓
|
kore |
====================== |
|
| 9 |
↓
|
kore |
|
|
| 10 |
87
|
kore |
PHPillow has been converted to also run with PHP 5.2, instead of just PHP 5.3 |
|
| 11 |
86
|
kore |
and higher. This process involved some API changes, which are listed below. |
|
| 12 |
↓
|
kore |
|
|
| 13 |
↓
|
kore |
- fetchById() cannot be called statically any more. |
|
| 14 |
159
|
kore |
|
|
| 15 |
86
|
kore |
For static calls with the same functionality you should use the manager |
|
| 16 |
↓
|
kore |
class, like:: |
|
| 17 |
↓
|
kore |
|
|
| 18 |
↓
|
kore |
$document = phpillowManager::fetchDocument( 'name', 'id' ); |
|
| 19 |
↓
|
kore |
|
|
| 20 |
↓
|
kore |
This works basically the same. If you want to call the fetchById method |
|
| 21 |
↓
|
kore |
without using the manager you may just do:: |
|
| 22 |
↓
|
kore |
|
|
| 23 |
159
|
kore |
$document = new myPhpillowDocument(); |
|
| 24 |
86
|
kore |
$document->fetchById( 'id' ); |
|
| 25 |
↓
|
kore |
|
|
| 26 |
↓
|
kore |
- The static property $type cannot be used anymore to define the document |
|
| 27 |
↓
|
kore |
type. The document type has to be returned by the getType method in *each* |
|
| 28 |
↓
|
kore |
of your document classes. |
|
| 29 |
↓
|
kore |
|
|
| 30 |
87
|
kore |
When using PHP 5.3 or higher you may still implement a generic base class |
|
| 31 |
86
|
kore |
for all your documents, which implements this method in a generic way and |
|
| 32 |
↓
|
kore |
extend all your concrete document classes from this one. The generic |
|
| 33 |
↓
|
kore |
implementation would then look like:: |
|
| 34 |
↓
|
kore |
|
|
| 35 |
↓
|
kore |
protected function getType() |
|
| 36 |
↓
|
kore |
{ |
|
| 37 |
↓
|
kore |
return static::$type; |
|
| 38 |
↓
|
kore |
} |
|
| 39 |
↓
|
kore |
|
|
| 40 |
87
|
kore |
- If you still want to use the static document factory method createNew() for |
|
| 41 |
↓
|
kore |
your document classes with PHP 5.2 or lower you need to implement a generic |
|
| 42 |
86
|
kore |
createNew() method in *each* of your classes, because PHP 5.2 does not |
|
| 43 |
87
|
kore |
support late static binding. But you can now instantiate the document |
|
| 44 |
↓
|
kore |
classes directly. Generally either the registry should be used or normal |
|
| 45 |
↓
|
kore |
instantiations of the document classes. This generic method would look |
|
| 46 |
↓
|
kore |
like:: |
|
| 47 |
86
|
kore |
|
|
| 48 |
↓
|
kore |
public static function createNew( $docType = null ) |
|
| 49 |
↓
|
kore |
{ |
|
| 50 |
↓
|
kore |
return parent::createNew( $docType === null ? __CLASS__ : $docType ); |
|
| 51 |
↓
|
kore |
} |
|
| 52 |
↓
|
kore |
|
|
| 53 |
↓
|
kore |
This implementation works fine when extending from this document class, as |
|
| 54 |
↓
|
kore |
long as all extending classes again implement this method. |
|
| 55 |
↓
|
kore |
|
|
| 56 |
87
|
kore |
Using PHP 5.3 you may still omit this method in all document classes. The |
|
| 57 |
↓
|
kore |
example classes all implement this method to be compatible with PHP 5.2. |
|
| 58 |
86
|
kore |
|
|
| 59 |
103
|
kore |
- There are two class interface changes: |
|
| 60 |
↓
|
kore |
|
|
| 61 |
↓
|
kore |
- The constructor of the document classes now need to be public, so that the |
|
| 62 |
↓
|
kore |
document classes can be instantiated directly. |
|
| 63 |
↓
|
kore |
|
|
| 64 |
↓
|
kore |
- The getViewName() method in views must not be static. |
|
| 65 |
↓
|
kore |
|
|