harvs1789uk
  1. class VimeoFileExtension extends DataExtension
  2. {
  3. private static $db = [
  4. 'VimeoURI' => 'Text',
  5. 'VimeoEmbed' => 'HTMLText'
  6. ];
  7.  
  8. public function onAfterPublish($original) {
  9. error_log("Doing File::onAfterPublish()");
  10. error_log(json_encode($original));
  11. }
  12. }
harvs1789uk

I am already extending File with a DataExtension to add some DB fields (like VimeoURI) if I could add something to the effect of onAfterPublish() on that extension, that would also be an ideal solution?

harvs1789uk

Is it not possible to get involved in the publication worjk flow from an Extension?

harvs1789uk

Not sure, it's not very exact as I am just watching the filesystem (Finder on Mac) to see when the file disapears from one dir and moves to the other...not an exact science lol

harvs1789uk

Also from having dug into File::doPublish() a bit, I think I might even need to overload ChangeSetItem::publish() anyway thanks to the publishRecursive() method etc....

harvs1789uk

Does anyone have any ideas or suggestion?

I am thinking I might be better off managing this in an extension of File instead, but I don't know how to tie in to the publication flow in a DataExtension?

harvs1789uk

So, I need some help re: Versioned DataObject and related Files (which are owned via $owns) and the publication process.

I am trying to identify related video files and upload them to Vimeo when my DataObject is published.

If the related video file is already published in it's own right, this works fine (as $video->getURL() returns the expected path, outside of .protected and without the file hash as a sub-folder).

However, if the File is still a draft, although the $owns on my DataObject triggers a publication of the file when my DataObject gets published, the file publication is not complete by the time my DataObject onAfterPublish($original) gets executed.

When $video->getURL() is called on my file when it is still draft, I am returned:

/public/assets/Uploads/Creative-Work/b596ac3fc5/under-5mb-sample-2.mov

Of which there are two issues:

1 - This isn't actually where the file sits on the file system, it's missing the .protected part (i.e. actual path is /public/assets/.protected/Uploads/Creative-Work/b596ac3fc5/under-5mb-sample-2.mov) 2 - It's literally just about to be moved from this location to it's new, public, location...so this might fail anyway