Reflection turned out to be bad, since I cannot implement my own method in entities, like Post::setUser() instead of Post::setUserId().
21 lines
414 B
PHP
21 lines
414 B
PHP
<?php
|
|
namespace Szurubooru\Dao\EntityConverters;
|
|
|
|
class PostEntityConverter implements IEntityConverter
|
|
{
|
|
public function toArray(\Szurubooru\Entities\Entity $entity)
|
|
{
|
|
return
|
|
[
|
|
'id' => $entity->getId(),
|
|
'name' => $entity->getName(),
|
|
];
|
|
}
|
|
|
|
public function toEntity(array $array)
|
|
{
|
|
$entity = new \Szurubooru\Entities\Post($array['id']);
|
|
$entity->setName($array['name']);
|
|
return $entity;
|
|
}
|
|
}
|