Skip to content

omnibase/gallery API reference

Floor
Prepared structure · Omnibase
Version
main
Verified for real
Its README does not say
Licence
MIT
composer require omnibase/gallery:dev-main

Read from the package's own PHP files at the commit c71090111a35: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Base\Gallery

  • GalleryBundle class

    Albums of photographs on top of omnibase's Thread. An Album IS a Thread (JOINED subclass): one album is one creation, its Photos are ordered.

    3 methods

Base\Gallery\Controller\Admin

  • OpenToAdminsTrait trait

    This bundle's screens are written by the site's administrators (ROLE_ADMIN: a teacher, an editor), not only by the super-admin the admin bundle requires by default for anything that writes - as omnibase/estate does. $custom names the screen's own actions (#[AdminAction]).

Base\Gallery\Controller\Admin\Crud

  • AlbumCrudController class

    An album in the back office: its title, the day the work was made, the preview shown on the list, its text, its tags and taxa, and its photographs - each with its place, saved in that order. Two buttons: "Publier" (or back to draft) and "À la une".

    13 methods

  • PhotoCrudController class

    Every photograph of every album, album by album and in order: to find one, fix a caption or a credit without opening its album. A photograph is added from its album's screen as well.

    6 methods

Base\Gallery\Controller\Client

  • GalleryController class

    The gallery: every published album a page at a time, filtered by a tag (?tag=); one page per taxon (/galerie/{taxon}: the albums it classifies, with its label and description); one page per album, its photographs in order. The first segment is gallery.path ("galerie" by default).

    3 methods

Base\Gallery\DependencyInjection

Base\Gallery\Entity

  • Album class

    An album: one creation, shown by its photographs. An omnibase thread - title, excerpt and text translated, slug, publication state and date, tags (free words that filter the list), taxa (what the site classifies with: each may have its own page) - with the day the work was made, a "featured" flag and its photographs in order on top.

    17 methods

  • Photo class

    A photograph of an album: the file, the words under it (caption), the words a screen reader says (alt), who took it (credit), its place in the album, whether it is the album's cover, and a free label - "Avant", "Après", "Détail" - that a site may show on it or group by.

    24 methods

Base\Gallery\EventListener

  • SitemapListener class

    The albums' and the taxa's own pages in /sitemap.xml: omnibase lists the routes it can generate by itself (the gallery's first page), and these are behind a slug it cannot know. Each album carries the day it was last changed, so a crawler comes back to the ones that move.

    2 methods

Base\Gallery\Form

  • PhotoType class

    One photograph of an album in the back office: the picture, its place, its caption, what a screen reader says, the credit, a free label and whether it is the cover.

    2 methods

Base\Gallery\Repository

  • AlbumRepository class

    The published albums. Every query is on Album: with JOINED inheritance an application's subclass comes back as itself, so the pages and the Twig function need no other repository. A subclass's own repository extends this one and passes its class. (INSTANCE OF takes the class's name, not its discriminator as a parameter: the name covers the subclasses.)

    11 methods

  • PhotoRepository class

    1 method

Base\Gallery\Service

  • JsonLd class

    An album as schema.org reads it: an ImageGallery whose images are ImageObjects, each with its address, its caption and its credit.

    2 methods

Base\Gallery\Twig

  • GalleryExtension class

    What a host's own pages ask the gallery: a few albums for a home page or a family's page, the taxa for a menu.

    2 methods

class GalleryBundle extends AbstractBaseBundle GalleryBundle.php:14

Albums of photographs on top of omnibase's Thread. An Album IS a Thread (JOINED subclass): one album is one creation, its Photos are ordered.

Nothing else: no follow-up of the work (that is omnibase/forge), no trade.

public function __construct()
public function getPath(): string

Modern layout: the class lives in src/, the bundle root is the package root.

public function build(ContainerBuilder $container): void

trait OpenToAdminsTrait OpenToAdminsTrait.php:14

This bundle's screens are written by the site's administrators (ROLE_ADMIN: a teacher, an editor), not only by the super-admin the admin bundle requires by default for anything that writes - as omnibase/estate does. $custom names the screen's own actions (#[AdminAction]).

class AlbumCrudController extends AbstractCrudController AlbumCrudController.php:40

An album in the back office: its title, the day the work was made, the preview shown on the list, its text, its tags and taxa, and its photographs - each with its place, saved in that order. Two buttons: "Publier" (or back to draft) and "À la une".

An application's subclass of Album has its own screen by extending this one: getEntityFqcn() returns its class, configureFields() yields parent's fields and its own (docs/extending.md).

public function setTaxonClass(string $taxonClass = Taxon::class): void
public static function getEntityFqcn(): string
public static function getPreferredIcon(): ?string
public function configureFilters(Filters $filters): Filters
public function configureActions(Actions $actions): Actions
public function configureFields(string $pageName): iterable
public function createEntity(string $entityFqcn): object
public function persistEntity(EntityManagerInterface $entityManager, object $entity): void

Saved in the order typed: the places rewritten 1, 2, 3..., one cover at most.

public function updateEntity(EntityManagerInterface $entityManager, object $entity): void
public function publish(string $entityId): Response
public function unpublish(string $entityId): Response
public function feature(string $entityId): Response
public function unfeature(string $entityId): Response

class PhotoCrudController extends AbstractCrudController PhotoCrudController.php:25

Every photograph of every album, album by album and in order: to find one, fix a caption or a credit without opening its album. A photograph is added from its album's screen as well.

public static function getEntityFqcn(): string
public static function getPreferredIcon(): ?string
public function configureCrud(Crud $crud): Crud
public function configureFilters(Filters $filters): Filters
public function configureActions(Actions $actions): Actions
public function configureFields(string $pageName): iterable

class GalleryController extends AbstractController GalleryController.php:27

The gallery: every published album a page at a time, filtered by a tag (?tag=); one page per taxon (/galerie/{taxon}: the albums it classifies, with its label and description); one page per album, its photographs in order. The first segment is gallery.path ("galerie" by default).

A taxon's page and an album's page share one pattern, /{path}/{slug}: the taxon is looked for first - they are few, and an album never takes a taxon's slug knowingly.

public function __construct(readonly AlbumRepository $albums, readonly JsonLd $jsonLd, readonly int $perPage = 24, readonly string $taxonClass = Taxon::class)
public function index(Request $request): Response
public function show(Request $request, string $slug): Response

class GalleryConfiguration extends AbstractBaseConfiguration GalleryConfiguration.php:9

public function getConfigTreeBuilder(): TreeBuilder

class GalleryExtension extends AbstractBaseExtension GalleryExtension.php:11

public function getConfiguration(array $config, ContainerBuilder $container): GalleryConfiguration
public function load(array $configs, ContainerBuilder $container): void

class Album extends Thread implements LinkableInterface Album.php:27

An album: one creation, shown by its photographs. An omnibase thread - title, excerpt and text translated, slug, publication state and date, tags (free words that filter the list), taxa (what the site classifies with: each may have its own page) - with the day the work was made, a "featured" flag and its photographs in order on top.

Written to be extended: an application that needs more (a customer, a town, a technical sheet) declares a JOINED subclass with its own #[DiscriminatorEntry]; the repository, the pages, the Twig function and the back office work on it as they are (docs/extending.md).

public static function __iconizeStatic(): ?array
public function __toLink(array $routeParameters = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): ?string
public function __construct(?\Base\Entity\User $owner = null, ?Thread $parent = null, ?string $title = null, ?string $slug = null)
public function __toString(): string
public function getMadeAt(): ?\DateTimeInterface
public function setMadeAt(?\DateTimeInterface $madeAt): self
public function isFeatured(): bool
public function setFeatured(bool $featured): self
public function getPhotos(): Collection
Returns

as stored; getOrderedPhotos() for the order shown

public function addPhoto(Photo $photo): self
public function removePhoto(Photo $photo): self
public function getOrderedPhotos(): array

The photographs in the order they are shown: by position, then in the order they were added - also right after one was added or moved, before the database has sorted them.

public function getCover(): ?Photo

The photograph on the album's card and at the top of its page: the one marked, else the first.

public function setCover(?Photo $cover): self

One cover at most: marking a photograph unmarks the others.

public function getPhotosByLabel(): array

The photographs carrying a label ("Avant", "Après"), by label, in order.

@return array<string, list<Photo>>

public function renumberPhotos(): self

The positions rewritten 1, 2, 3... in the order shown (after a photograph was removed or moved).

public function publish(bool $published = true, ?\DateTimeInterface $at = null): self

Publish it now (or at $at), or take it back to draft.

class Photo Photo.php:16

A photograph of an album: the file, the words under it (caption), the words a screen reader says (alt), who took it (credit), its place in the album, whether it is the album's cover, and a free label - "Avant", "Après", "Détail" - that a site may show on it or group by.

public function __toString(): string
public function getId(): ?int
public function getAlbum(): ?Album
public function setAlbum(?Album $album): self
public function getFile(): ?string

Where the storage keeps the picture (what omnibase's |picture, |thumbnail and |lightbox take).

public function setFile($file): self
public function hasFile(): bool

Whether a picture is set, without asking the storage where it is.

public function getFileUrl(): ?string

The picture's address on the site ("/uploads/…"), what an <img> or a JSON-LD ImageObject takes: the storage gives its public path from the server's root, the public directory is taken off.

public static function publicUrl(?string $path): ?string

"/srv/app/public/uploads/a.jpg" → "/uploads/a.jpg"; a URL or a site path as it is.

public function getCaption(): ?string
public function setCaption(?string $caption): self
public function getAlt(): string

What a screen reader says: the alt typed, else the caption, else the album's title.

public function getOwnAlt(): ?string

The alt as typed (the form's value): null when none was.

public function setOwnAlt(?string $alt): self
public function setAlt(?string $alt): self
public function getCredit(): ?string
public function setCredit(?string $credit): self
public function getCreditLine(): ?string

The credit with its sign: "Anna Meyer" is printed "© Anna Meyer".

public function getPosition(): ?int
public function setPosition(?int $position): self
public function isCover(): bool
public function setCover(bool $cover): self
public function getLabel(): ?string
public function setLabel(?string $label): self

final class SitemapListener SitemapListener.php:17

The albums' and the taxa's own pages in /sitemap.xml: omnibase lists the routes it can generate by itself (the gallery's first page), and these are behind a slug it cannot know. Each album carries the day it was last changed, so a crawler comes back to the ones that move.

public function __construct(readonly AlbumRepository $albums, readonly string $taxonClass = Taxon::class, readonly bool $enabled = true)
public function __invoke(SitemapEvent $event): void

class PhotoType extends AbstractType PhotoType.php:22

One photograph of an album in the back office: the picture, its place, its caption, what a screen reader says, the credit, a free label and whether it is the cover.

The texts name their domain (@gallery.…): omnibase gives every field the "fields" domain, which the form's own translation_domain does not reach.

public function buildForm(FormBuilderInterface $builder, array $options): void
public function configureOptions(OptionsResolver $resolver): void

class AlbumRepository extends ServiceEntityRepository AlbumRepository.php:22

The published albums. Every query is on Album: with JOINED inheritance an application's subclass comes back as itself, so the pages and the Twig function need no other repository. A subclass's own repository extends this one and passes its class. (INSTANCE OF takes the class's name, not its discriminator as a parameter: the name covers the subclasses.)

public function __construct(ManagerRegistry $registry, string $entityClass = Album::class)
public function findPublishedPage(int $page = 1, int $perPage = 24, ?string $taxon = null, ?string $tag = null, ?bool $featured = null): array

A page of the published albums - the featured ones first, then the most recent work (madeAt, else the publication date) - of one taxon and/or one tag when their slugs are given. Paged by hand: Doctrine's Paginator walks the SQL with an output walker omnibase's own SqlWalker is incompatible with.

public function countPublished(?string $taxon = null, ?string $tag = null, ?bool $featured = null): int
public function findLatest(int $limit = 6, ?bool $featured = null, ?string $taxon = null): array
public function findAllPublished(): array
Returns

every published album, for a sitemap

public function findOnePublished(string $slug): ?Album
public function findNeighbours(Album $album): array
Returns

the one before and the one after in the list's order

public static function neighbours(array $ids, int $id, callable $load): array

The ids before and after $id in $ids, each turned into its album.

public function findTags(?string $taxon = null): array
Returns

the tags of the published albums (of one taxon when given): the list's filters

public function findTaxa(string $class = Taxon::class): array

The taxa that have a page: of $class (omnibase's Taxon and its subclasses by default). With the default class, only those that classify a published album; with an application's class, all of them - by their position when the class has that field.

public function findTaxon(string $slug, string $class = Taxon::class): ?Taxon

class PhotoRepository extends ServiceEntityRepository PhotoRepository.php:10

public function __construct(ManagerRegistry $registry)

final class JsonLd JsonLd.php:13

An album as schema.org reads it: an ImageGallery whose images are ImageObjects, each with its address, its caption and its credit.

Plain arrays: the template encodes them.

public function album(Album $album, string $url, ?callable $absolute = null): array
$url

the album's absolute address

$absolute

turns a picture's site path ("/uploads/a.jpg") into an absolute address; null leaves the paths as they are

public function photo(Photo $photo, ?callable $absolute = null): ?array
Returns

null for a photograph without a file

final class GalleryExtension extends AbstractExtension GalleryExtension.php:12

What a host's own pages ask the gallery: a few albums for a home page or a family's page, the taxa for a menu.

public function __construct(readonly AlbumRepository $albums, readonly string $taxonClass = Taxon::class)
public function getFunctions(): array