Пример #1
0
 /**
  * Wraps a media entity with accesorry data, like author, attachments, targets, etc...
  * 
  * @param type $object
  * @return type
  */
 public function getObject(Entity $subject)
 {
     //1. getActor
     //Media Object;;
     //First get the nature of the media object;
     //        if(!is_object($subject)&& !is_a($subject, Entity::class)):
     //            $subjectEntity = Platform\Entity::getInstance(); //An empty entity here because it is impossible to guess the properties of this object
     //            $subject = $subjectEntity->loadObjectByURI($subject, array()); //Then we load the object
     //        endif;
     $object = NULL;
     $mediaObjectURI = $subject->getObjectURI();
     if (!empty($mediaObjectURI)) {
         //Create an media object, and fire an event asking callbacks to complete the media object
         $mediaSubject = new Object();
         $mediaObjectType = $subject->getObjectType();
         //Fire the event, passing the mediaSubject by reference
         //Although it looks stupid to need to find out the nature of the media subject before trigger
         //It actually provides an extra exclusion for callback so not all callbacks go to the database
         //so for instance if we found an media subject was a collection, callbacks can first check if the
         //trigger is to model a collection before diving ing
         //\Library\Event::trigger("onMediaSubjectModel", $mediaSubject, $subject);
         //You never know what callbacks will do to your subject so we just check
         //that the media subject is what we think it is, i.e an media object
         if (is_object($mediaSubject) && method_exists($mediaSubject, "getArray")) {
             $object = $mediaSubject::getArray();
             //If it is then we can set the media object output vars
         }
     } else {
         //If there no explicitly defined mediaObjects, in media_object
         //parse media_content for medialinks
         //Parse media targets medialinks
         //@todo;
         // $mediaLinks = Media\MediaLink::parse($data);
     }
     return $object;
 }