You are here

juicerio.module in Juicer - Social Media Feed Aggregator 8

Same filename and directory in other branches
  1. 7 juicerio.module

Module file for the Juicer Integration module.

File

juicerio.module
View source
<?php

/**
 * @file
 * Module file for the Juicer Integration module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function juicerio_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.juicerio') {
    $readme_file = file_exists(__DIR__ . '/README.md') ? __DIR__ . '/README.md' : __DIR__ . '/README.txt';
    if (!file_exists($readme_file)) {
      return NULL;
    }
    $text = file_get_contents($readme_file);
    if ($text && !\Drupal::moduleHandler()
      ->moduleExists('markdown')) {
      return '<pre>' . $text . '</pre>';
    }
    else {

      // Use the Markdown filter to render the README.
      $filter_manager = \Drupal::service('plugin.manager.filter');
      $settings = \Drupal::configFactory()
        ->get('markdown.settings')
        ->getRawData();
      $config = [
        'settings' => $settings,
      ];
      $filter = $filter_manager
        ->createInstance('markdown', $config);
      return $filter
        ->process($text, 'en');
    }
  }
  return NULL;
}

/**
 * Implements hook_theme().
 */
function juicerio_theme($existing, $type, $theme, $path) {
  return [
    'juicerio_feed' => [
      'template' => 'juicer-feed',
      'variables' => [
        'feed_id' => NULL,
        'post_num' => NULL,
        'infinite_pages' => NULL,
        'gutter_amt' => NULL,
        'column_num' => NULL,
        'filters' => NULL,
        'style' => NULL,
      ],
    ],
  ];
}

Functions

Namesort descending Description
juicerio_help Implements hook_help().
juicerio_theme Implements hook_theme().