Core Framework Events
All core framework events are defined as constants on component-specific classes
in the Pimcore\Event namespace. Each constant includes a PHPDoc description
of the event's purpose and the event object it dispatches.
Available Event Classes
Elements
- AssetEvents - create, update, delete, copy, and upload operations on assets
- DocumentEvents - create, update, delete, copy, and print operations on documents
- DataObjectEvents - create, update, delete, and copy operations on data objects
- ElementEvents - cross-type element operations (resolve, sanity check)
- VersionEvents - version create, update, delete operations
Data Modeling
- DataObjectClassDefinitionEvents - class definition create, update, delete
- ObjectbrickDefinitionEvents - objectbrick definition changes
- FieldcollectionDefinitionEvents - fieldcollection definition changes
- DataObjectClassificationStoreEvents - classification store operations
- DataObjectCustomLayoutEvents - custom layout changes
- DataObjectQuantityValueEvents - quantity value unit operations
System
- SystemEvents - system startup and maintenance events
- CoreCacheEvents - cache save, delete, and clear operations
- FullPageCacheEvents - full-page cache lifecycle events
- MailEvents - pre-send and post-send events for Pimcore mail
- TranslationEvents - translation operations
- WorkflowEvents - workflow transitions and place changes
- TagEvents - tag assignment and management
- NoteEvents - note create, update, and delete
- NotificationEvents - notification lifecycle events
- UserRoleEvents - user and role management events
- SiteEvents - site create, update, delete
- WebsiteSettingEvents - website setting changes
- ReportEvents - report-related events
- UrlSlugEvents - URL slug operations
Frontend and Rendering
- FrontendEvents - frontend rendering events
Other
- TestEvents - test lifecycle events
Examples
Hook into Pre-Update Events for Assets, Documents, and Data Objects
Register listeners for multiple element types in config/services.yaml:
services:
App\EventListener\TestListener:
tags:
- { name: kernel.event_listener, event: pimcore.asset.preUpdate, method: onPreUpdate }
- { name: kernel.event_listener, event: pimcore.document.preUpdate, method: onPreUpdate }
- { name: kernel.event_listener, event: pimcore.dataobject.preUpdate, method: onPreUpdate }
The listener class in src/EventListener/TestListener.php:
<?php
namespace App\EventListener;
use Pimcore\Event\Model\ElementEventInterface;
use Pimcore\Event\Model\DataObjectEvent;
use Pimcore\Event\Model\AssetEvent;
use Pimcore\Event\Model\DocumentEvent;
class TestListener
{
public function onPreUpdate(ElementEventInterface $e): void
{
if ($e instanceof AssetEvent) {
$foo = $e->getAsset();
} else if ($e instanceof DocumentEvent) {
$foo = $e->getDocument();
} else if ($e instanceof DataObjectEvent) {
$foo = $e->getObject();
$foo->setMyValue(microtime(true));
// no need to call save - this is the pre-update event
}
}
}
Modify Object Lists Globally
The pimcore.dataobject.list.beforeListLoad event modifies object listings before
they load. This applies globally to the tree, grid list, and search panel.
Use this to implement custom permission rules, for example restricting listings
to objects owned by the current user. Combine with
overriding the model
to also override isAllowed(), enforcing the same rules across all access paths
(including REST APIs).
Dynamic Asset Upload Path
The AssetEvents::RESOLVE_UPLOAD_TARGET event dynamically modifies the target folder for uploaded assets based on the object they are assigned to.
Data types like image and relation fields allow a dedicated upload path, defaulting
to /_default_upload_bucket when not configured in the class definition or config.
The event provides contextual information (field name, fieldcollection index, etc.)
matching the context described in Calculated Value Type.
Register as an EventSubscriberInterface:
<?php
namespace App\EventSubscriber;
use Pimcore\Event\AssetEvents;
use Pimcore\Event\Model\Asset\ResolveUploadTargetEvent;
use Pimcore\Model\Asset\Service;
use App\Model\DataObject\News;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AssetUploadPathSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
AssetEvents::RESOLVE_UPLOAD_TARGET => 'onResolveUploadTarget',
];
}
public function onResolveUploadTarget(ResolveUploadTargetEvent $event): void
{
$context = $event->getContext();
if ($context['containerType'] !== 'object') {
return;
}
$newsObject = News::getById($context['objectId']);
if (!$newsObject) {
return;
}
$fieldname = $context['fieldname'];
$targetPath = $newsObject->getPath() . $newsObject->getKey() . '/' . $fieldname;
$parent = Service::createFolderByPath($targetPath);
if ($parent) {
$event->setParentId($parent->getId());
}
}
}