2014-09-15 11:38:24 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Controllers\ViewProxies;
|
|
|
|
|
|
|
|
class PostViewProxy extends AbstractViewProxy
|
|
|
|
{
|
2014-09-21 09:35:43 +02:00
|
|
|
private $tagViewProxy;
|
|
|
|
|
|
|
|
public function __construct(TagViewProxy $tagViewProxy)
|
|
|
|
{
|
|
|
|
$this->tagViewProxy = $tagViewProxy;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:38:24 +02:00
|
|
|
public function fromEntity($post)
|
|
|
|
{
|
|
|
|
$result = new \StdClass;
|
|
|
|
if ($post)
|
|
|
|
{
|
|
|
|
$result->id = $post->getId();
|
|
|
|
$result->name = $post->getName();
|
|
|
|
$result->userId = $post->getUserId();
|
|
|
|
$result->uploadTime = $post->getUploadTime();
|
|
|
|
$result->lastEditTime = $post->getLastEditTime();
|
|
|
|
$result->safety = \Szurubooru\Helpers\EnumHelper::postSafetyToString($post->getSafety());
|
|
|
|
$result->contentType = \Szurubooru\Helpers\EnumHelper::postTypeToString($post->getContentType());
|
|
|
|
$result->contentChecksum = $post->getContentChecksum();
|
2014-09-18 19:30:12 +02:00
|
|
|
$result->contentMimeType = $post->getContentMimeType();
|
2014-09-15 11:38:24 +02:00
|
|
|
$result->source = $post->getSource();
|
|
|
|
$result->imageWidth = $post->getImageWidth();
|
|
|
|
$result->imageHeight = $post->getImageHeight();
|
2014-09-21 09:35:43 +02:00
|
|
|
$result->tags = $this->tagViewProxy->fromArray($post->getTags());
|
2014-09-15 11:38:24 +02:00
|
|
|
$result->originalFileSize = $post->getOriginalFileSize();
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|