Newer
Older
Dries Buytaert
committed
<?php
/**
* @file
* RESTful web services module.
*/
Angie Byron
committed
use Drupal\Core\Routing\RouteMatchInterface;
Dries Buytaert
committed
/**
* Implements hook_permission().
*/
function rest_permission() {
$permissions = array();
$manager = \Drupal::service('plugin.manager.rest');
$resources = \Drupal::config('rest.settings')->get('resources');
if ($resources && $enabled = array_intersect_key($manager->getDefinitions(), $resources)) {
foreach ($enabled as $key => $resource) {
$plugin = $manager->getInstance(array('id' => $key));
$permissions = array_merge($permissions, $plugin->permissions());
Dries Buytaert
committed
}
}
return $permissions;
}
/**
* Implements hook_help().
*/
Angie Byron
committed
function rest_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.rest':
Dries Buytaert
committed
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The REST module provides a framework for exposing Drupal\'s data structures as RESTful web services. It can be used to read and write resources remotely, such as entity types like nodes or users. For more information, see the online handbook entry for the <a href="@rest">RESTful web services module</a>.', array('@rest' => 'http://drupal.org/documentation/modules/rest')) . '</p>';
return $output;