Attachments events

This commit is contained in:
Eric Espie
2022-06-01 11:46:00 +02:00
parent 812c1f6bb4
commit 35e1f080b8
2 changed files with 17 additions and 43 deletions

View File

@@ -203,40 +203,6 @@
}
}]]></code>
</method>
<method id="EventUpdateAfter">
<comment> /**
* @param array $aEventData
*
* @return void
* @throws \CoreException
*/
</comment>
<static>false</static>
<access>protected</access>
<type>Overload-ExNihilo</type>
<code><![CDATA[
final protected function EventUpdateAfter(array $aEventData)
{
$this->FireEvent(EVENT_SERVICE_ATTACHMENT_AFTER_UPDATE);
}
]]></code>
</method>
<method id="EventDeleteAfter">
<comment> /**
* @return void
* @throws \CoreException
*/
</comment>
<static>false</static>
<access>protected</access>
<type>Overload-ExNihilo</type>
<code><![CDATA[
final protected function EventDeleteAfter()
{
$this->FireEvent(EVENT_SERVICE_ATTACHMENT_AFTER_DELETE);
}
]]></code>
</method>
</methods>
<presentation>
<details>
@@ -288,8 +254,8 @@
</class>
</classes>
<events>
<event id="EVENT_SERVICE_ATTACHMENT_AFTER_UPDATE" _delta="define">
<description>An attachment has been updated in database.</description>
<event id="EVENT_SERVICE_ADD_ATTACHMENT_TO_OBJECT" _delta="define">
<description>An attachment has been added to an object</description>
<replaces>Attachment::AfterUpdate</replaces>
<sources>
<source id="Attachment">Attachment</source>
@@ -299,9 +265,9 @@
<description>The attachment updated</description>
<type>DBObject</type>
</event_datum>
<event_datum id="changes">
<description>Array of all the attributes changed</description>
<type>array</type>
<event_datum id="target_object">
<description>The object to which the attachment is linked</description>
<type>DBObject</type>
</event_datum>
<event_datum id="debug_info">
<description>Debug string</description>
@@ -309,15 +275,19 @@
</event_datum>
</event_data>
</event>
<event id="EVENT_SERVICE_ATTACHMENT_AFTER_DELETE" _delta="define">
<description>An attachment has been deleted from database.</description>
<replaces>Attachment::AfterDelete</replaces>
<event id="EVENT_SERVICE_REMOVE_ATTACHMENT_FROM_OBJECT" _delta="define">
<description>An attachment has been removed from an object</description>
<replaces>Attachment::AfterUpdate</replaces>
<sources>
<source id="Attachment">Attachment</source>
</sources>
<event_data>
<event_datum id="object">
<description>The attachment deleted</description>
<description>The attachment updated</description>
<type>DBObject</type>
</event_datum>
<event_datum id="target_object">
<description>The object to which the attachment is linked</description>
<type>DBObject</type>
</event_datum>
<event_datum id="debug_info">

View File

@@ -304,6 +304,8 @@ class AttachmentPlugIn implements iApplicationUIExtension, iApplicationObjectExt
// Remove attachments that are no longer attached to the current object
if (in_array($oAttachment->GetKey(), $aRemovedAttachmentIds))
{
$aData = ['target_object' => $oObject];
$oAttachment->FireEvent(EVENT_SERVICE_REMOVE_ATTACHMENT_FROM_OBJECT, $aData);
$oAttachment->DBDelete();
$aActions[] = self::GetActionChangeOp($oAttachment, false /* false => deletion */);
}
@@ -332,6 +334,8 @@ class AttachmentPlugIn implements iApplicationUIExtension, iApplicationObjectExt
$oAttachment->DBUpdate();
// temporary attachment confirmed, list it in the history
$aActions[] = self::GetActionChangeOp($oAttachment, true /* true => creation */);
$aData = ['target_object' => $oObject];
$oAttachment->FireEvent(EVENT_SERVICE_ADD_ATTACHMENT_TO_OBJECT, $aData);
}
}
}