CoolCMS API

AdvertBuildTrait

Builds the `Advert` entity from the submitted admin form values.

Edit clones the loaded profile (keeping price, author and region associations, the collections categoryRels, assetRels, fileRels and parameterRels, rating_thread_id and active) and overwrites only the edited scalar fields. parameterRels and categoryRels are then overwritten by AdvertFormTrait::applyParameterRels() and AdvertFormTrait::applyCategoryRels(): parameterRels only when the submitted rows are not empty, categoryRels always.

Both are owned collections on the Admin entity (cascade, orphanRemoval and #[CollectionOf(owned: true)]): EntityHydrator::extract() serializes them fully and the Api hydrateForPersist merges them with a real Doctrine object-graph persist (the composite PK matches an existing row: update; a new row: insert; a missing row: orphan removal delete). They are therefore excluded from defaultSkipFields and graphDataKeys of the Api AdvertManager.

assetRels and fileRels stay non-owned (skipped): the clone carries them as references, and without the protection the Api owned merge would not match them (empty child, orphan removal and EntityMissingAssignedId on flush). They are protected by stripping defaultSkipFields from $data in Api/Presenters/SaveTrait::internalActionSave(); new images and files are written by the Api afterSave through meta['assets'] and meta['files'].

meta['suppressNotifications'] suppresses notifications (AdvertFormTrait::saveAdvertForm()).

Table of Contents

Methods

buildAdvert()  : Advert

Methods

On this page

Search results