Repository URL to install this package:
|
Version:
6.3.0 ▾
|
<?php
/**
* Created by IntelliJ IDEA.
* User: martino
* Date: 28/04/16
* Time: 20:15
*/
namespace DigitalAscetic\FileBundle\Entity\File;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* Class ManagedImage
*
* @package DigitalAscetic\FileBundle\Entity\File
*
* @ORM\Table(name="managed_image")
* @ORM\Entity()
*/
#[ORM\Table(name: "managed_image")]
#[ORM\Entity]
class ManagedImage extends AbstractManagedFile
{
const VIEW_DEFAULT = "default";
const VIEW_COMPLETE = "complete";
const ALIAS = "mImg";
public static function getSerializationGroups($viewName): array
{
$result = array('id', 'image_default', 'image_source');
switch ($viewName) {
case 'complete' :
$result = array_merge($result, ManagedFile::getSerializationGroups(ManagedFile::VIEW_COMPLETE));
break;
default:
$result = array_merge($result, ManagedFile::getSerializationGroups(ManagedFile::VIEW_DEFAULT));
break;
}
return $result;
}
/**
* @var ManagedFile $file
*
* @ORM\OneToOne(targetEntity="DigitalAscetic\FileBundle\Entity\File\ManagedFile", cascade={"all"})
* @ORM\JoinColumn(name="file_id", referencedColumnName="id", nullable=false)
* @Groups({"image_default"})
*/
#[ORM\OneToOne(targetEntity: "DigitalAscetic\FileBundle\Entity\File\ManagedFile", cascade: ["all"])]
#[ORM\JoinColumn(name: "file_id", referencedColumnName: "id", nullable: false)]
#[Groups("image_default")]
private ManagedFile $file;
/**
* @var int|null
*
* @ORM\Column(name="width", type="integer", nullable=true)
* @Assert\Regex("/^\d+/")
* @Groups({"image_default"})
*/
#[ORM\Column(name: "width", type: "integer", nullable: true)]
#[Assert\Regex("/^\d+/")]
#[Groups("image_default")]
private ?int $width = null;
/**
* @var int|null
*
* @ORM\Column(name="height", type="integer", nullable=true)
* @Assert\Regex("/^\d+/")
* @Groups({"image_default"})
*/
#[ORM\Column(name: "height", type: "integer", nullable: true)]
#[Assert\Regex("/^\d+/")]
#[Groups("image_default")]
private ?int $height = null;
/**
* Image constructor.
* @param ManagedFile $file
*/
public function __construct(ManagedFile $file)
{
$this->file = $file;
}
/**
* @return int|null
*/
public function getHeight(): ?int
{
return $this->height;
}
/**
* @param int|null $height
*/
public function setHeight(?int $height): void
{
$this->height = $height;
}
/**
* @return ManagedFile
*/
public function getFile(): ManagedFile
{
return $this->file;
}
/**
* @return int|null
*/
public function getWidth(): ?int
{
return $this->width;
}
/**
* @param int|null $width
*/
public function setWidth(?int $width): void
{
$this->width = $width;
}
/**
* Name used in the __toString method
*
* @return string
*/
public function getInstanceName(): string
{
return $this->file->getInstanceName();
}
}