/**
 * Allow altering the request before it is processed.
 *
 * @param \Drupal\restful\Plugin\resource\ResourceInterface &$resource
 *   The resource object to alter.
 */
function hook_restful_resource_alter(\Drupal\restful\Plugin\resource\ResourceInterface &$resource)
{
    // Chain a decorator with the passed in resource based on the resource
    // annotation definition.
    $plugin_definition = $resource->getPluginDefinition();
    if (!empty($plugin_definition['renderCache']) && !empty($plugin_definition['renderCache']['render'])) {
        $resource = new \Drupal\restful\Plugin\resource\CachedResource($resource);
    }
}
 /**
  * Constructs a Drupal\Component\Plugin\PluginBase object.
  *
  * @param ResourceInterface $subject
  *   The decorated object.
  * @param RateLimitManager $rate_limit_manager
  *   Injected rate limit manager.
  */
 public function __construct(ResourceInterface $subject, RateLimitManager $rate_limit_manager = NULL)
 {
     $this->subject = $subject;
     $plugin_definition = $subject->getPluginDefinition();
     $rate_limit_info = empty($plugin_definition['rateLimit']) ? array() : $plugin_definition['rateLimit'];
     if ($limit = variable_get('restful_global_rate_limit', 0)) {
         $rate_limit_info['global'] = array('period' => variable_get('restful_global_rate_period', 'P1D'), 'limits' => array());
         foreach (user_roles() as $role_name) {
             $rate_limit_info['global']['limits'][$role_name] = $limit;
         }
     }
     $this->rateLimitManager = $rate_limit_manager ? $rate_limit_manager : new RateLimitManager($this, $rate_limit_info);
 }
 /**
  * {@inheritdoc}
  *
  * This is a decorated resource, get proxy the request until you reach the
  * annotated resource.
  */
 public function getPluginDefinition()
 {
     return $this->subject->getPluginDefinition();
 }