src/Cms/LogBundle/Entity/RecentFeed.php line 22

Open in your IDE?
  1. <?php
  2. namespace Cms\LogBundle\Entity;
  3. use Cms\CoreBundle\Model\Interfaces\DatabaseOptimizationInterface;
  4. use Cms\TenantBundle\Entity\TenantedEntities\AnonymousTenantedEntity;
  5. use Doctrine\Common\Util\ClassUtils;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Platform\SecurityBundle\Entity\Identity\Account;
  8. /**
  9.  * Class RecentFeed
  10.  * @package Cms\LogBundle\Entity
  11.  *
  12.  * @ORM\Entity(
  13.  *     repositoryClass = "Cms\LogBundle\Doctrine\RecentFeedRepository"
  14.  * )
  15.  * @ORM\Table(
  16.  *     name = "cms__log__recent_feed"
  17.  * )
  18.  */
  19. class RecentFeed extends AnonymousTenantedEntity implements DatabaseOptimizationInterface
  20. {
  21.     use RecentFeedModulesTrait;
  22.     /**
  23.      * @var Account
  24.      *
  25.      * @ORM\ManyToOne(
  26.      *     targetEntity = "Platform\SecurityBundle\Entity\Identity\Account"
  27.      * )
  28.      * @ORM\JoinColumn(
  29.      *     name = "account",
  30.      *     referencedColumnName = "id",
  31.      *     onDelete = "CASCADE"
  32.      * )
  33.      */
  34.     protected $account;
  35.     /**
  36.      * @var string
  37.      *
  38.      * @ORM\Column(
  39.      *     type = "string",
  40.      *     nullable = false
  41.      * )
  42.      */
  43.     protected $name;
  44.     /**
  45.      * @var int
  46.      *
  47.      * @ORM\Column(
  48.      *     type = "integer",
  49.      *     nullable = false
  50.      * )
  51.      */
  52.     protected $checksum;
  53.     /**
  54.      * @return Account
  55.      */
  56.     public function getAccount(): Account
  57.     {
  58.         return $this->account;
  59.     }
  60.     /**
  61.      * @param Account $value
  62.      * @return $this
  63.      */
  64.     public function setAccount(Account $value): self
  65.     {
  66.         $this->account $value;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return string
  71.      */
  72.     public function getName(): string
  73.     {
  74.         return $this->name;
  75.     }
  76.     /**
  77.      * @param string $value
  78.      * @return $this
  79.      */
  80.     public function setName(string $value): self
  81.     {
  82.         $this->name $value;
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return int
  87.      */
  88.     public function getChecksum(): string
  89.     {
  90.         return $this->checksum;
  91.     }
  92.     /**
  93.      * @param int $value
  94.      * @return $this
  95.      */
  96.     public function setChecksum(int $value): self
  97.     {
  98.         $this->checksum $value;
  99.         return $this;
  100.     }
  101.     /**
  102.      * {@inheritDoc}
  103.      */
  104.     public function optimize(): array
  105.     {
  106.         $account $this->getAccount();
  107.         $proxy $this->getProxy();
  108.         $department $this->getProxy()->getContainer();
  109.         $draft $this->getProxy()->getDraft();
  110.         $optimizations = [
  111.             ClassUtils::getClass($account) => $account->getId(),
  112.             ClassUtils::getClass($proxy) => $proxy->getId(),
  113.             ClassUtils::getClass($department) => $department->getId(),
  114.         ];
  115.         if ( ! empty($draft)) {
  116.             $optimizations[ClassUtils::getClass($draft)] = $draft->getId();
  117.         }
  118.         return $optimizations;
  119.     }
  120. }