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
Afficher le fichier Open project: neos/neos-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$adjustments ArrayCollection<\Neos\Media\Domain\Model\Adjustment\AbstractImageAdjustment>
$imageService Neos\Media\Domain\Service\ImageService
$name string
$originalAsset Image

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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 méthode

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
Résultat void

addAdjustments() public méthode

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
Résultat void

addTag() public méthode

Add a single tag to this asset
public addTag ( Tag $tag ) : void
$tag Tag
Résultat void

addVariant() public méthode

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

applyAdjustment() protected méthode

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
Résultat void

getAdjustments() public méthode

public getAdjustments ( ) : Doctrine\Common\Collections\Collection
Résultat Doctrine\Common\Collections\Collection

getCaption() public méthode

Returns the caption of the original image
public getCaption ( ) : string
Résultat string

getFileExtension() public méthode

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

getName() public méthode

Returns the name
public getName ( ) : string
Résultat string

getOriginalAsset() public méthode

Returns the original image this variant is based on
public getOriginalAsset ( ) : Image
Résultat Image

getResource() public méthode

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

getTitle() public méthode

Returns the title of the original image
public getTitle ( ) : string
Résultat string

getVariants() public méthode

Retrieving variants from variants is not supported (no-operation)
public getVariants ( ) : array
Résultat array

initializeObject() public méthode

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
Résultat void

refresh() public méthode

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
Résultat void

renderResource() protected méthode

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

setName() public méthode

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

setResource() public méthode

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
Résultat void

setTags() public méthode

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

setTitle() public méthode

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

Property Details

$adjustments protected_oe property

protected ArrayCollection<\Neos\Media\Domain\Model\Adjustment\AbstractImageAdjustment> $adjustments
Résultat ArrayCollection<\Neos\Media\Domain\Model\Adjustment\AbstractImageAdjustment>

$imageService protected_oe property

protected ImageService,Neos\Media\Domain\Service $imageService
Résultat Neos\Media\Domain\Service\ImageService

$name protected_oe property

protected string $name
Résultat string

$originalAsset protected_oe property

protected Image,Neos\Media\Domain\Model $originalAsset
Résultat Image