saymedia/php-typepad-api — Issue #5: TPLists
Author: neshte
Created: 2012-01-26 14:23:33+00:00
State: open

* TPLists as:
* TPImageLink
* TPVideoLink
* TPAudioLink

Are appending TPXxxx links outside the **entries** array of the *TPList*.

I personally find it difficult to loop on a PHP Object with an empty **entries** array and some numeric properties such as
TPList->0 TPList->1.

Maybe I'm not using the API the right way. The way I managed this was to:

### On the **Typepad.php** file:

change from this:

```php
559: $obj = (object) $data;
```
to this:

```php
559: $obj = new stdClass();
560: $obj->entries = $data;
```
and from this:

```php
704:parent::__construct($data);
705:$this->of_class = $of_class;
```
to this:

```php
704:$this->of_class = $of_class;
705:parent::__construct($data);
```
### Then on **ObjectTypes.php** file (change TPXxxxLink for XxxxLink):

change from this:

```php
479: if (isset($data->embeddedImageLinks)) $this->embeddedImageLinks = new TPList($data->embeddedImageLinks, 'TPImageLink');
```
to this:

```php
479: if (isset($data->embeddedImageLinks)) $this->embeddedImageLinks = new TPList($data->embeddedImageLinks, 'ImageLink');
```
from this:

```php
638: if (isset($data->embeddedVideoLinks)) $this->embeddedVideoLinks = new TPList($data->embeddedVideoLinks, 'TPVideoLink');
639: if (isset($data->embeddedAudioLinks)) $this->embeddedAudioLinks = new TPList($data->embeddedAudioLinks, 'TPAudioLink');
```
to this:

```php
638: if (isset($data->embeddedVideoLinks)) $this->embeddedVideoLinks = new TPList($data->embeddedVideoLinks, 'VideoLink');
639: if (isset($data->embeddedAudioLinks)) $this->embeddedAudioLinks = new TPList($data->embeddedAudioLinks, 'AudioLink');
```
from this:

```php
if (isset($data->embeddedImageLinks)) $this->embeddedImageLinks = new TPList($data->embeddedImageLinks, 'TPImageLink');
```
to this:

```php
if (isset($data->embeddedImageLinks)) $this->embeddedImageLinks = new TPList($data->embeddedImageLinks, 'ImageLink');
```