You are here

blogapi_movabletype.module in Blog API 8

Same filename and directory in other branches
  1. 7.2 modules/blogapi_movabletype/blogapi_movabletype.module

Module file for blogapi_movabletype.

File

modules/blogapi_movabletype/blogapi_movabletype.module
View source
<?php

/**
 * @file
 * Module file for blogapi_movabletype.
 */

/**
 * Implements hook_xmlrpc().
 */
function blogapi_movabletype_xmlrpc() {
  $manager = \Drupal::service('plugin.manager.blogapi');
  $plugin = $manager
    ->createInstance('MovabletypeProvider');
  return $plugin
    ->getMethods();
}

/**
 * Callback for mt.supportedTextFilters.
 *
 * @return mixed
 *   BlogAPI response.
 */
function blogapi_movabletype_text_filters() {
  $communicator = \Drupal::service('service.communicator.blogapi');
  return $communicator
    ->getTextFormats();
}

/**
 * Callback for mt.getPostCategories.
 *
 * @param $nid
 *   The node ID.
 *
 * @param $username
 *   Drupal username.
 *
 * @param $pass
 *   Drupal password.
 *
 * @return mixed
 *   BlogAPI response.
 */
function blogapi_movabletype_post_categories($nid, $username, $pass) {
  $communicator = \Drupal::service('service.communicator.blogapi');
  return $communicator
    ->getNodeCategories($nid, $username, $pass);
}

/**
 * Callback for mt.getCategoryList.
 *
 * @param $ct
 *   Content type machine name.
 *
 * @param $username
 *   Drupal username.
 *
 * @param $pass
 *   Drupal password.
 *
 * @return mixed
 *   BlogAPI response.
 */
function blogapi_movabletype_category_list($ct, $username, $pass) {
  $communicator = \Drupal::service('service.communicator.blogapi');
  return $communicator
    ->getCategoryList($ct, $username, $pass);
}

/**
 * Callback for mt.setPostCategories.
 *
 * @param string $nid
 *   The node ID.
 *
 * @param string $username
 *   Drupal username.
 *
 * @param string $pass
 *   Drupal password.
 *
 * @param mixed $data
 *   Node contents.
 *
 * @return object
 *   BlogAPI response.
 */
function blogapi_movabletype_set_categories($nid, $username, $pass, $data) {
  $communicator = \Drupal::service('service.communicator.blogapi');
  return $communicator
    ->setPostCategories($nid, $username, $pass, $data);
}

/**
 * Callback for mt.publishPost.
 *
 * @param $nid
 *   The node ID.
 *
 * @param $username
 *   Drupal username.
 *
 * @param $pass
 *   Drupal password.
 *
 * @return bool|object
 *   BlogAPI response.
 */
function blogapi_movabletype_publish_post($nid, $username, $pass) {
  $communicator = \Drupal::service('service.communicator.blogapi');
  return $communicator
    ->publishPost($nid, $username, $pass);
}

/**
 * Callback for mt.getRecentPostTitles.
 *
 * @param $ct
 *   Content type machine name.
 *
 * @param $username
 *   Drupal username.
 *
 * @param $pass
 *   Drupal password.
 *
 * @param $number_of_posts
 *   The number of recent posts to return.
 *
 * @return array|object
 *   BlogAPI response.
 */
function blogapi_movabletype_get_recent_posts($ct, $username, $pass, $number_of_posts) {
  $communicator = \Drupal::service('service.communicator.blogapi');
  return $communicator
    ->getRecentPosts($ct, $username, $pass, $number_of_posts, FALSE);
}

/**
 * Callback for mt.supportedMethods.
 *
 * Returns all implemented methods except itself.
 *
 * @return array
 *   BlogAPI response.
 */
function blogapi_movabletype_supported_methods() {
  $manager = \Drupal::service('plugin.manager.blogapi');
  $definitions = $manager
    ->getDefinitions();
  $methods = [];
  foreach ($definitions as $plugin_name => $plugin_info) {
    $plugin = $manager
      ->createInstance($plugin_name);
    $tmp = $plugin
      ->getMethods();
    foreach ($tmp as $method) {
      if ($method[0] != 'mt.supportedMethods') {
        $methods[] = $method[0];
      }
    }
  }
  return $methods;
}

Functions

Namesort descending Description
blogapi_movabletype_category_list Callback for mt.getCategoryList.
blogapi_movabletype_get_recent_posts Callback for mt.getRecentPostTitles.
blogapi_movabletype_post_categories Callback for mt.getPostCategories.
blogapi_movabletype_publish_post Callback for mt.publishPost.
blogapi_movabletype_set_categories Callback for mt.setPostCategories.
blogapi_movabletype_supported_methods Callback for mt.supportedMethods.
blogapi_movabletype_text_filters Callback for mt.supportedTextFilters.
blogapi_movabletype_xmlrpc Implements hook_xmlrpc().