/**
  * Constructor for RestfulRateLimitManager.
  *
  * @param string $resource
  *   Resource name being checked.
  * @param array $plugin
  *   The plugin info array for the rate limit.
  * @param \stdClass $account
  *   The identified user account for the request.
  */
 public function __construct($resource, array $plugin, $account = NULL) {
   parent::__construct($plugin);
   $this->resource = $resource;
   $this->setPluginInfo($plugin);
   $this->account = $account ? $account : drupal_anonymous_user();
 }
Exemple #2
0
 /**
  * Constructs a RestfulEntityBase object.
  *
  * @param array $plugin
  *   Plugin definition.
  * @param RestfulAuthenticationManager $auth_manager
  *   (optional) Injected authentication manager.
  * @param DrupalCacheInterface $cache_controller
  *   (optional) Injected cache backend.
  */
 public function __construct(array $plugin, \RestfulAuthenticationManager $auth_manager = NULL, \DrupalCacheInterface $cache_controller = NULL, $langcode = NULL) {
   parent::__construct($plugin);
   $this->authenticationManager = $auth_manager ? $auth_manager : new \RestfulAuthenticationManager();
   $this->cacheController = $cache_controller ? $cache_controller : $this->newCacheObject();
   if ($rate_limit = $this->getPluginKey('rate_limit')) {
     $this->setRateLimitManager(new \RestfulRateLimitManager($this->getPluginKey('resource'), $rate_limit));
   }
   $this->staticCache = new \RestfulStaticCacheController();
   if (is_null($langcode)) {
     global $language;
     $this->langcode = $language->language;
   }
   else {
     $this->langcode = $langcode;
   }
 }