PHP Class Neos\Media\Domain\Model\ImageVariant

Inheritance: extends Asset, implements Neos\Media\Domain\Model\AssetVariantInterface, implements Neos\Media\Domain\Model\ImageInterface, use trait DimensionsTrait
Show file Open project: neos/neos-development-collection Class Usage Examples

Protected Properties

Property Type Description
$adjustments ArrayCollection<\Neos\Media\Domain\Model\Adjustment\AbstractImageAdjustment>
$imageService Neos\Media\Domain\Service\ImageService
$name string
$originalAsset Image

Public Methods

Method Description
__construct ( Image $originalAsset ) Constructs a new Image Variant based on the given original
addAdjustment ( Neos\Media\Domain\Model\Adjustment\ImageAdjustmentInterface $adjustment ) : void Adds the given adjustment to the list of adjustments applied to this image variant.
addAdjustments ( array $adjustments ) : void Adds the given adjustments to the list of adjustments applied to this image variant.
addTag ( Tag $tag ) : void Add a single tag to this asset
addVariant ( ImageVariant $variant ) : void Adding variants to variants is not supported.
getAdjustments ( ) : Doctrine\Common\Collections\Collection
getCaption ( ) : string Returns the caption of the original image
getFileExtension ( ) : string File extension of the image without leading dot.
getName ( ) : string Returns the name
getOriginalAsset ( ) : Image Returns the original image this variant is based on
getResource ( ) : PersistentResource Returns the resource of this image variant
getTitle ( ) : string Returns the title of the original image
getVariants ( ) : array Retrieving variants from variants is not supported (no-operation)
initializeObject ( integer $initializationCause ) : void Initialize this image variant
refresh ( ) : void Refreshes this image variant: according to the added adjustments, a new image is rendered and stored as this image variant's resource.
setName ( string $name ) : void Sets a name which can be used for identifying this variant
setResource ( PersistentResource $resource ) : void Setting the image resource on an ImageVariant is not allowed, this method will throw a RuntimeException.
setTags ( Doctrine\Common\Collections\Collection $tags ) : void Set the tags assigned to this asset
setTitle ( string $title ) : void Setting the title on an ImageVariant is not allowed, this method will throw a RuntimeException.

Protected Methods

Method Description
applyAdjustment ( Neos\Media\Domain\Model\Adjustment\ImageAdjustmentInterface $adjustment ) : void Apply the given adjustment to the image variant.
renderResource ( ) : void Tells the ImageService to render the resource of this ImageVariant according to the existing adjustments.

Method Details

__construct() public method

Constructs a new Image Variant based on the given original
public __construct ( Image $originalAsset )
$originalAsset Image The original Image asset this variant is derived from

addAdjustment() public method

If an adjustment of the given type already exists, the existing one will be overridden by the new one.
public addAdjustment ( Neos\Media\Domain\Model\Adjustment\ImageAdjustmentInterface $adjustment ) : void
$adjustment Neos\Media\Domain\Model\Adjustment\ImageAdjustmentInterface The adjustment to apply
return void

addAdjustments() public method

If an adjustment of one of the given types already exists, the existing one will be overridden by the new one.
public addAdjustments ( array $adjustments ) : void
$adjustments array
return void

addTag() public method

Add a single tag to this asset
public addTag ( Tag $tag ) : void
$tag Tag
return void

addVariant() public method

Adding variants to variants is not supported.
public addVariant ( ImageVariant $variant ) : void
$variant ImageVariant
return void

applyAdjustment() protected method

If an adjustment of the given type already exists, the existing one will be overridden by the new one.
protected applyAdjustment ( Neos\Media\Domain\Model\Adjustment\ImageAdjustmentInterface $adjustment ) : void
$adjustment Neos\Media\Domain\Model\Adjustment\ImageAdjustmentInterface
return void

getAdjustments() public method

public getAdjustments ( ) : Doctrine\Common\Collections\Collection
return Doctrine\Common\Collections\Collection

getCaption() public method

Returns the caption of the original image
public getCaption ( ) : string
return string

getFileExtension() public method

This will return the file extension of the original image as this should not be different in image variants
public getFileExtension ( ) : string
return string

getName() public method

Returns the name
public getName ( ) : string
return string

getOriginalAsset() public method

Returns the original image this variant is based on
public getOriginalAsset ( ) : Image
return Image

getResource() public method

Returns the resource of this image variant
public getResource ( ) : PersistentResource
return Neos\Flow\ResourceManagement\PersistentResource

getTitle() public method

Returns the title of the original image
public getTitle ( ) : string
return string

getVariants() public method

Retrieving variants from variants is not supported (no-operation)
public getVariants ( ) : array
return array

initializeObject() public method

This method will generate the resource of this asset when this object has just been newly created. We can't run renderResource() in the constructor since not all dependencies have been injected then. Generating resources lazily in the getResource() method is not feasible either, because getters will be triggered by the validation mechanism on flushing the persistence which will result in undefined behavior. We don't call refresh() here because we only want the resource to be rendered, not all other refresh actions from parent classes being executed.
public initializeObject ( integer $initializationCause ) : void
$initializationCause integer
return void

refresh() public method

Refreshes this image variant: according to the added adjustments, a new image is rendered and stored as this image variant's resource.
See also: getResource()
public refresh ( ) : void
return void

renderResource() protected method

Tells the ImageService to render the resource of this ImageVariant according to the existing adjustments.
protected renderResource ( ) : void
return void

setName() public method

Sets a name which can be used for identifying this variant
public setName ( string $name ) : void
$name string
return void

setResource() public method

Setting the image resource on an ImageVariant is not allowed, this method will throw a RuntimeException.
public setResource ( PersistentResource $resource ) : void
$resource Neos\Flow\ResourceManagement\PersistentResource
return void

setTags() public method

Set the tags assigned to this asset
public setTags ( Doctrine\Common\Collections\Collection $tags ) : void
$tags Doctrine\Common\Collections\Collection
return void

setTitle() public method

Setting the title on an ImageVariant is not allowed, this method will throw a RuntimeException.
public setTitle ( string $title ) : void
$title string
return void

Property Details

$adjustments protected property

protected ArrayCollection<\Neos\Media\Domain\Model\Adjustment\AbstractImageAdjustment> $adjustments
return ArrayCollection<\Neos\Media\Domain\Model\Adjustment\AbstractImageAdjustment>

$imageService protected property

protected ImageService,Neos\Media\Domain\Service $imageService
return Neos\Media\Domain\Service\ImageService

$name protected property

protected string $name
return string

$originalAsset protected property

protected Image,Neos\Media\Domain\Model $originalAsset
return Image