<?php
namespace Cms\LogBundle\Entity;
use Cms\CoreBundle\Model\Interfaces\DatabaseOptimizationInterface;
use Cms\TenantBundle\Entity\TenantedEntities\AnonymousTenantedEntity;
use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\Mapping as ORM;
use Platform\SecurityBundle\Entity\Identity\Account;
/**
* Class RecentFeed
* @package Cms\LogBundle\Entity
*
* @ORM\Entity(
* repositoryClass = "Cms\LogBundle\Doctrine\RecentFeedRepository"
* )
* @ORM\Table(
* name = "cms__log__recent_feed"
* )
*/
class RecentFeed extends AnonymousTenantedEntity implements DatabaseOptimizationInterface
{
use RecentFeedModulesTrait;
/**
* @var Account
*
* @ORM\ManyToOne(
* targetEntity = "Platform\SecurityBundle\Entity\Identity\Account"
* )
* @ORM\JoinColumn(
* name = "account",
* referencedColumnName = "id",
* onDelete = "CASCADE"
* )
*/
protected $account;
/**
* @var string
*
* @ORM\Column(
* type = "string",
* nullable = false
* )
*/
protected $name;
/**
* @var int
*
* @ORM\Column(
* type = "integer",
* nullable = false
* )
*/
protected $checksum;
/**
* @return Account
*/
public function getAccount(): Account
{
return $this->account;
}
/**
* @param Account $value
* @return $this
*/
public function setAccount(Account $value): self
{
$this->account = $value;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $value
* @return $this
*/
public function setName(string $value): self
{
$this->name = $value;
return $this;
}
/**
* @return int
*/
public function getChecksum(): string
{
return $this->checksum;
}
/**
* @param int $value
* @return $this
*/
public function setChecksum(int $value): self
{
$this->checksum = $value;
return $this;
}
/**
* {@inheritDoc}
*/
public function optimize(): array
{
$account = $this->getAccount();
$proxy = $this->getProxy();
$department = $this->getProxy()->getContainer();
$draft = $this->getProxy()->getDraft();
$optimizations = [
ClassUtils::getClass($account) => $account->getId(),
ClassUtils::getClass($proxy) => $proxy->getId(),
ClassUtils::getClass($department) => $department->getId(),
];
if ( ! empty($draft)) {
$optimizations[ClassUtils::getClass($draft)] = $draft->getId();
}
return $optimizations;
}
}