Skip to content

Commit

Permalink
deprecations / comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DDEV User committed Aug 5, 2024
1 parent 4dac255 commit 4d4af0d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/EventListener/PimcoreElementListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function onObjectPostUpdate(DataObjectEvent $event): void
/** @var DataObject\Concrete $object */
$object = $event->getObject();

// @deprecated since 5.0: published/unpublished must be handled by project-specific resource validation
$dispatchType = ContextDefinitionInterface::CONTEXT_DISPATCH_TYPE_UPDATE;
if (method_exists($object, 'isPublished') && $object->isPublished() === false) {
$dispatchType = ContextDefinitionInterface::CONTEXT_DISPATCH_TYPE_DELETE;
Expand Down Expand Up @@ -199,6 +200,7 @@ protected function checkInheritanceIndex(ElementInterface $element): void

foreach ($list->getObjects() as $childObject) {
$dispatchType = ContextDefinitionInterface::CONTEXT_DISPATCH_TYPE_UPDATE;
// @deprecated since 5.0: published/unpublished must be handled by project-specific resource validation
if (method_exists($childObject, 'isPublished') && $childObject->isPublished() === false) {
$dispatchType = ContextDefinitionInterface::CONTEXT_DISPATCH_TYPE_DELETE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Queue/DataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public function addToContextQueue(string $contextName, string $dispatchType, mix

protected function generateJob(string $contextName, string $dispatchType, mixed $resource, array $options): void
{

if($resource instanceof ElementInterface) {
// @todo: introduce generic "resource info" dto with resource information
if ($resource instanceof ElementInterface) {
$resourceType = sprintf('%s-%s', Element\Service::getElementType($resource), $resource->getId());
$resource = null;
} elseif (is_object($resource)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Queue/MessageHandler/QueuedResourcesHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ private function process(array $jobs): void
try {

$resource = $message->resource;
// @todo: use introduced "resource info" dto to determinate resource / type
if (str_contains($message->resourceType, '-')) {
[$type, $id] = explode('-', $message->resourceType);
if (is_numeric($id)) {
$id = (int) $id;
}
$resource = Element\Service::getElementById($type, $id);
if (null === $resource && $message->dispatchType === ContextDefinitionInterface::CONTEXT_DISPATCH_TYPE_DELETE) {
if ($resource === null && $message->dispatchType === ContextDefinitionInterface::CONTEXT_DISPATCH_TYPE_DELETE) {
// at this time, the resource is already deleted by pimcore
// since we do not serialize the resource into the message,
// we need to create a dummy resource to retrieve a valid resource meta for deletion
Expand Down

0 comments on commit 4d4af0d

Please sign in to comment.