Custom events and $result->getAttribute('id'); in Symphony 2.5
This is an open discussion with 3 replies, filed under General.
Search
Do you have any more context?
I need it for my chained events of an ecommerce, where the products of an order should reference the same order only if the order creation is successful. In older version it was possible using this code:
include(TOOLKIT . '/events/event.section.php'); if($result->getAttribute('result') == "success") { $nump = $_POST['nump']; for ($i = 0; $i < $nump; ++$i) { $_POST['products']['fields'][$i]['orderid'] = $result->getAttribute('id'); }
but now both...$result->getAttribute('result')
and $result->getAttribute('id')
never work.
Ah right, that's been deprecated for a while. The new method is to use the execute
method. This will return an XMLElement for you. Seehttps://github.com/symphonycms/symphony-2/blob/master/symphony/lib/toolkit/events/class.event.section.php
Create an account or sign in to comment.
Unlike previous versions of symphony in which it was possible to use the $result-> getAttribute('id') function to get the id of the last entry created, from version 2.5 isn't possible use this function. Is there an alternative?