Version: current

     1 <?php
     2
     3 class FileDataObjectTrackingDecorator extends DataObjectDecorator {
     4     function extraStatics() {   }
     5
     6     function onAfterDelete() {
     7
     8         // выставляем флаг HasBrokenFile
     9         if ($tracking = $this->owner->BackFileTracking()) {
    10             foreach($tracking as $entry) {
    11                 if (($linkedObject = $entry->LinkedObject()) && $linkedObject->is_a('SiteTree')) {
    12                     $linkedObject->syncLinkTracking();
    13                     $linkedObject->writeToStage('Stage');
    14                     if ($linkedObject->isPublished()) {
    15                         $linkedObject->publish('Stage', 'Live');
    16                     }
    17                 }
    18             }
    19         }
    20         // чистим трекинг при удалении файла
    21         DataObjectFileTracking::delete_track(0, '', '', array($this->owner->ID));
    22     }
    23
    24     function BackFileTracking() {
    25         return DataObject::get('DataObjectFileTracking', "FileID = {$this->owner->ID}");
    26     }
    27 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -