You are here

abstract class FeedsFetcher in Feeds 7.2

Same name and namespace in other branches
  1. 6 plugins/FeedsFetcher.inc \FeedsFetcher
  2. 7 plugins/FeedsFetcher.inc \FeedsFetcher

Abstract class, defines shared functionality between fetchers.

Implements FeedsSourceInfoInterface to expose source forms to Feeds.

Hierarchy

Expanded class hierarchy of FeedsFetcher

3 string references to 'FeedsFetcher'
FeedsPlugin::typeOf in plugins/FeedsPlugin.inc
Determines the type of a plugin.
hook_feeds_plugins in ./feeds.api.php
Declare Feeds plugins.
_feeds_feeds_plugins in ./feeds.plugins.inc
Break out for feeds_feed_plugins().

File

plugins/FeedsFetcher.inc, line 294
Contains the FeedsFetcher and related classes.

View source
abstract class FeedsFetcher extends FeedsPlugin {

  /**
   * Implements FeedsPlugin::pluginType().
   */
  public function pluginType() {
    return 'fetcher';
  }

  /**
   * Fetch content from a source and return it.
   *
   * Every class that extends FeedsFetcher must implement this method.
   *
   * @param $source
   *   Source value as entered by user through sourceForm().
   *
   * @return
   *   A FeedsFetcherResult object.
   */
  public abstract function fetch(FeedsSource $source);

  /**
   * Clear all caches for results for given source.
   *
   * @param FeedsSource $source
   *   Source information for this expiry. Implementers can choose to only clear
   *   caches pertaining to this source.
   */
  public function clear(FeedsSource $source) {
  }

  /**
   * Request handler invoked if callback URL is requested. Locked down by
   * default. For a example usage see FeedsHTTPFetcher.
   *
   * Note: this method may exit the script.
   *
   * @return
   *   A string to be returned to the client.
   */
  public function request($feed_nid = 0) {
    drupal_access_denied();
  }

  /**
   * Construct a path for a concrete fetcher/source combination. The result of
   * this method matches up with the general path definition in
   * FeedsFetcher::menuItem(). For example usage look at FeedsHTTPFetcher.
   *
   * @return
   *   Path for this fetcher/source combination.
   */
  public function path($feed_nid = 0) {
    $id = urlencode($this->id);
    if ($feed_nid && is_numeric($feed_nid)) {
      return "feeds/importer/{$id}/{$feed_nid}";
    }
    return "feeds/importer/{$id}";
  }

  /**
   * Menu item definition for fetchers of this class. Note how the path
   * component in the item definition matches the return value of
   * FeedsFetcher::path().
   *
   * Requests to this menu item will be routed to FeedsFetcher::request().
   *
   * @return
   *   An array where the key is the Drupal menu item path and the value is
   *   a valid Drupal menu item definition.
   */
  public function menuItem() {
    return array(
      'feeds/importer/%feeds_importer' => array(
        'page callback' => 'feeds_fetcher_callback',
        'page arguments' => array(
          2,
          3,
        ),
        'access callback' => TRUE,
        'file' => 'feeds.pages.inc',
        'type' => MENU_CALLBACK,
      ),
    );
  }

  /**
   * Subscribe to a source. Only implement if fetcher requires subscription.
   *
   * @param FeedsSource $source
   *   Source information for this subscription.
   */
  public function subscribe(FeedsSource $source) {
  }

  /**
   * Unsubscribe from a source. Only implement if fetcher requires subscription.
   *
   * @param FeedsSource $source
   *   Source information for unsubscribing.
   */
  public function unsubscribe(FeedsSource $source) {
  }

  /**
   * Override import period settings. This can be used to force a certain import
   * interval.
   *
   * @param $source
   *   A FeedsSource object.
   *
   * @return
   *   A time span in seconds if periodic import should be overridden for given
   *   $source, NULL otherwise.
   */
  public function importPeriod(FeedsSource $source) {
  }

  /**
   * Invoked after an import is finished.
   *
   * @param $source
   *   A FeedsSource object.
   */
  public function afterImport(FeedsSource $source) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsConfigurable::$config protected property Holds the actual configuration information.
FeedsConfigurable::$disabled protected property CTools export enabled status of this object.
FeedsConfigurable::$export_type protected property CTools export type of this object.
FeedsConfigurable::$id protected property An unique identifier for the configuration.
FeedsConfigurable::addConfig public function Similar to setConfig but adds to existing configuration.
FeedsConfigurable::configForm public function Returns configuration form for this object. 6
FeedsConfigurable::configFormSubmit public function Submission handler for configForm(). 2
FeedsConfigurable::configFormValidate public function Validation handler for configForm(). 3
FeedsConfigurable::copy public function Copy a configuration. 1
FeedsConfigurable::doesExist public function Determine whether this object is persistent. 1
FeedsConfigurable::existing public function Determines whether this object is persistent and enabled. 1
FeedsConfigurable::getConfig public function Implements getConfig(). 1
FeedsConfigurable::hasConfigForm public function Returns whether or not the configurable has a config form.
FeedsConfigurable::isEnabled public function Determine whether this object is enabled.
FeedsConfigurable::setConfig public function Set configuration.
FeedsConfigurable::validateConfig public function Validates the configuration. 2
FeedsConfigurable::__get public function Overrides magic method __get().
FeedsConfigurable::__isset public function Override magic method __isset(). This is needed due to overriding __get().
FeedsFetcher::afterImport public function Invoked after an import is finished. 1
FeedsFetcher::clear public function Clear all caches for results for given source. 1
FeedsFetcher::fetch abstract public function Fetch content from a source and return it. 2
FeedsFetcher::importPeriod public function Override import period settings. This can be used to force a certain import interval. 1
FeedsFetcher::menuItem public function Menu item definition for fetchers of this class. Note how the path component in the item definition matches the return value of FeedsFetcher::path().
FeedsFetcher::path public function Construct a path for a concrete fetcher/source combination. The result of this method matches up with the general path definition in FeedsFetcher::menuItem(). For example usage look at FeedsHTTPFetcher.
FeedsFetcher::pluginType public function Implements FeedsPlugin::pluginType(). Overrides FeedsPlugin::pluginType
FeedsFetcher::request public function Request handler invoked if callback URL is requested. Locked down by default. For a example usage see FeedsHTTPFetcher. 1
FeedsFetcher::subscribe public function Subscribe to a source. Only implement if fetcher requires subscription. 1
FeedsFetcher::unsubscribe public function Unsubscribe from a source. Only implement if fetcher requires subscription. 1
FeedsPlugin::$pluginDefinition protected property The plugin definition.
FeedsPlugin::all public static function Get all available plugins.
FeedsPlugin::byType public static function Gets all available plugins of a particular type.
FeedsPlugin::child public static function Determines whether given plugin is derived from given base plugin.
FeedsPlugin::configDefaults public function Overrides FeedsConfigurable::configDefaults(). Overrides FeedsConfigurable::configDefaults 4
FeedsPlugin::dependencies public function Implements FeedsConfigurable::dependencies(). Overrides FeedsConfigurable::dependencies 1
FeedsPlugin::hasSourceConfig public function Returns TRUE if $this->sourceForm() returns a form. Overrides FeedsSourceInterface::hasSourceConfig
FeedsPlugin::instance public static function Instantiates a FeedsPlugin object. Overrides FeedsConfigurable::instance
FeedsPlugin::loadMappers public static function Loads on-behalf implementations from mappers/ directory.
FeedsPlugin::pluginDefinition public function Returns the plugin definition.
FeedsPlugin::save public function Save changes to the configuration of this object. Delegate saving to parent (= Feed) which will collect information from this object by way of getConfig() and store it. Overrides FeedsConfigurable::save 1
FeedsPlugin::setPluginDefinition protected function Sets the plugin definition.
FeedsPlugin::sourceDefaults public function Implements FeedsSourceInterface::sourceDefaults(). Overrides FeedsSourceInterface::sourceDefaults 1
FeedsPlugin::sourceDelete public function A source is being deleted. Overrides FeedsSourceInterface::sourceDelete 2
FeedsPlugin::sourceForm public function Callback methods, exposes source form. Overrides FeedsSourceInterface::sourceForm 3
FeedsPlugin::sourceFormValidate public function Validation handler for sourceForm. Overrides FeedsSourceInterface::sourceFormValidate 2
FeedsPlugin::sourceSave public function A source is being saved. Overrides FeedsSourceInterface::sourceSave 2
FeedsPlugin::typeOf public static function Determines the type of a plugin.
FeedsPlugin::__construct protected function Constructs a FeedsPlugin object. Overrides FeedsConfigurable::__construct