szurubooru/src/Controllers/ViewProxies/PostViewProxy.php

41 lines
1.3 KiB
PHP
Raw Normal View History

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;
2014-09-21 18:21:54 +02:00
private $userViewProxy;
2014-09-21 09:35:43 +02:00
2014-09-21 18:21:54 +02:00
public function __construct(
TagViewProxy $tagViewProxy,
UserViewProxy $userViewProxy)
2014-09-21 09:35:43 +02:00
{
$this->tagViewProxy = $tagViewProxy;
2014-09-21 18:21:54 +02:00
$this->userViewProxy = $userViewProxy;
2014-09-21 09:35:43 +02:00
}
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->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-23 19:00:40 +02:00
$result->contentExtension = \Szurubooru\Helpers\MimeHelper::getExtension($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();
2014-09-21 18:21:54 +02:00
$result->user = $this->userViewProxy->fromEntity($post->getUser());
2014-09-15 11:38:24 +02:00
}
return $result;
}
}