You are here

abstract class MediaInternetBaseHandler in D7 Media 7.4

Same name and namespace in other branches
  1. 7 modules/media_internet/includes/MediaInternetBaseHandler.inc \MediaInternetBaseHandler
  2. 7.2 modules/media_internet/includes/MediaInternetBaseHandler.inc \MediaInternetBaseHandler
  3. 7.3 modules/media_internet/includes/MediaInternetBaseHandler.inc \MediaInternetBaseHandler

A base class for managing the addition of Internet media.

Classes extending this class manage the addition of Internet media. To achieve this, the class should parse user-submitted embed code, claim it when appropriate and save it as a managed file.

Hierarchy

Expanded class hierarchy of MediaInternetBaseHandler

File

modules/media_internet/includes/MediaInternetBaseHandler.inc, line 15
Definition of MediaInternetBaseHandler.

View source
abstract class MediaInternetBaseHandler {

  /**
   * The constructor for the MediaInternetBaseHandler class. This method is also called
   * from the classes that extend this class and override this method.
   */
  public function __construct($embedCode) {
    $this->embedCode = $embedCode;
  }

  /**
   * Determines if this handler should claim the item.
   *
   * @param string $embed_code
   *   A string of user-submitted embed code.
   *
   * @return boolean
   *   Pass TRUE to claim the item.
   */
  public abstract function claim($embed_code);

  /**
   * Returns a file object which can be used for validation.
   *
   * @return StdClass
   */
  public abstract function getFileObject();

  /**
   * If required, implementors can validate the embedCode.
   */
  public function validate() {
  }

  /**
   * Before the file has been saved, implementors may do additional operations.
   *
   * @param object $file_obj
   */
  public function preSave(&$file_obj) {
  }

  /**
   * Saves a file to the file_managed table (with file_save).
   *
   * @return StdClass
   */
  public function save() {
    $file_obj = $this
      ->getFileObject();
    $this
      ->preSave($file_obj);
    file_save($file_obj);
    $this
      ->postSave($file_obj);
    return $file_obj;
  }

  /**
   * After the file has been saved, implementors may do additional operations.
   *
   * @param object $file_obj
   */
  public function postSave(&$file_obj) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MediaInternetBaseHandler::claim abstract public function Determines if this handler should claim the item. 2
MediaInternetBaseHandler::getFileObject abstract public function Returns a file object which can be used for validation. 2
MediaInternetBaseHandler::postSave public function After the file has been saved, implementors may do additional operations. 1
MediaInternetBaseHandler::preSave public function Before the file has been saved, implementors may do additional operations. 1
MediaInternetBaseHandler::save public function Saves a file to the file_managed table (with file_save).
MediaInternetBaseHandler::validate public function If required, implementors can validate the embedCode.
MediaInternetBaseHandler::__construct public function The constructor for the MediaInternetBaseHandler class. This method is also called from the classes that extend this class and override this method.