-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Fix deletion of context.objectId #738
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Quality Gate passedIssues Measures |
I have read the CLA Document and I hereby sign the CLA |
Hello @alexmarkop , could you please provide steps to reproduce the problem? What I did was:
Seems to be working for me. Did I miss something? |
Hi @mcop1 , delete context.objectId; Take a look at the code snippet in the following example (Asset Upload Path): \Pimcore::getEventDispatcher()->addListener(AssetEvents::RESOLVE_UPLOAD_TARGET,
function(\Pimcore\Event\Model\Asset\ResolveUploadTargetEvent $event) {
$context = $event->getContext();
if ($context["containerType"] == "object") {
$objectId = $context["objectId"];
$newsObject = News::getById($objectId);
if ($newsObject) {
$fieldname = $context["fieldname"];
$targetPath = $newsObject->getPath() . $newsObject->getKey() . "/" . $fieldname;
$parent = \Pimcore\Model\Asset\Service::createFolderByPath($targetPath);
if ($parent) {
$event->setParentId($parent->getId());
}
}
}
}); now |
Thanks again for the fix! Cherry picked to 1.6 with 77e046a |
This code change fixes the mistaken deletion of "objectId" from "this.context".
Without this, the following example is broken:
https://pimcore.com/docs/platform/Pimcore/Extending_Pimcore/Event_API_and_Event_Manager/#asset-upload-path