/** * Constructor for RateLimitManager. * * @param ResourceInterface $resource * Resource being checked. * @param array $plugin_options * Array of options keyed by plugin id. * @param object $account * The identified user account for the request. * @param RateLimitPluginManager $manager * The plugin manager. */ public function __construct(ResourceInterface $resource, array $plugin_options, $account = NULL, RateLimitPluginManager $manager = NULL) { $this->resource = $resource; $account = $account ? $account : $resource->getAccount(); $this->account = $account ? $account : drupal_anonymous_user(); $manager = $manager ?: RateLimitPluginManager::create(); $options = array(); foreach ($plugin_options as $plugin_id => $rate_options) { // Set the instance id to articles::request and specify the plugin id. $instance_id = $resource->getResourceName() . PluginBase::DERIVATIVE_SEPARATOR . $plugin_id; $options[$instance_id] = array('id' => $plugin_id, 'resource' => $resource); $options[$instance_id] += $rate_options; } $this->plugins = new RateLimitPluginCollection($manager, $options); }
/** * Proxy method to get the account from the rateLimitManager. * * {@inheritdoc} */ public function getAccount($cache = TRUE) { return $this->subject->getAccount($cache); }