GalleryAssetRel
extends BaseEntity
in package
implements
IdentifiableInterface, AssetRelInterface
Gallery to image link with a position (drag&drop sortable in the admin).
The PK is composite (gallery + image); order is the image position. The ORM identity and
the ManyToOne mappings come from the UI variants of Gallery/Asset.
A gallery has no soft delete or main column: images are saved by hard DELETE+INSERT in
afterSave, so isRemoved() is always false and isMain() derives from the order (first
is main). This satisfies the contract of
AssetRelCollectionTrait.
Tags
Attributes
- #[DefaultIncludes]
- ['asset']
- #[MappedSuperclass]
- #[TableAlias]
- $alias: 'galleryImageRel'
Table of Contents
Interfaces
- IdentifiableInterface
- Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).
- AssetRelInterface
- Link between an entity and an image or file (`*AssetRel`, `*ImageRel`) with order and flags.
Properties
Methods
- __construct() : mixed
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getAsset() : TImage|null
- getGallery() : TGallery|null
- getId() : int|null
- Returns the gallery id without triggering lazy loading (used to group relations).
- getImageId() : int|null
- Returns the image id without triggering lazy loading of the proxy.
- getOrder() : int
- isMain() : bool
- Whether this is the first image; the gallery has no `main` column.
- isRemoved() : bool
- Always false: gallery images are hard deleted.
- setAsset() : $this
- setGallery() : $this
- setOrder() : $this
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$asset
protected
TImage|null
$asset
= null
$gallery
protected
TGallery|null
$gallery
= null
$order
protected
int
$order
= 0
Attributes
- #[Column]
- $name: '`order`'
- $type: 'integer'
- $options: ['unsigned' => true]
Methods
__construct()
public
__construct([mixed $gallery = null ][, mixed $asset = null ][, int $order = 0 ]) : mixed
Parameters
- $gallery : mixed = null
- $asset : mixed = null
- $order : int = 0
callInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
getAllTraits()
Returns all traits the class uses, including those used by parent classes and nested traits.
public
getAllTraits() : array<string, string>
Return values
array<string, string>getAsset()
public
getAsset() : TImage|null
Return values
TImage|nullgetGallery()
public
getGallery() : TGallery|null
Return values
TGallery|nullgetId()
Returns the gallery id without triggering lazy loading (used to group relations).
public
getId() : int|null
Return values
int|nullgetImageId()
Returns the image id without triggering lazy loading of the proxy.
public
getImageId() : int|null
Return values
int|nullgetOrder()
public
getOrder() : int
Return values
intisMain()
Whether this is the first image; the gallery has no `main` column.
public
isMain() : bool
Return values
boolisRemoved()
Always false: gallery images are hard deleted.
public
isRemoved() : bool
Return values
boolsetAsset()
public
setAsset(TImage|null $asset) : $this
Parameters
- $asset : TImage|null
Return values
$thissetGallery()
public
setGallery(TGallery|null $gallery) : $this
Parameters
- $gallery : TGallery|null
Return values
$thissetOrder()
public
setOrder(int $order) : $this
Parameters
- $order : int
Return values
$thisgetTraitsRecursive()
Walks the trait list recursively and collects nested traits too.
private
static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
- $traits : array<string, string>