Spork Code Libraries

LimitStrategy

Keeps track of when a client does something suspicious and takes action when a client has exceeded the threshold for a type of event. Each type of event has its own threshold limit and interval and actions.

Extends
\Zend\Mvc\Controller\Plugin\AbstractPlugin
Implements

Constants

CONFIG_KEY

CONFIG_KEY

Properties

$actionPlugins

$actionPlugins : \Zend\ServiceManager\AbstractPluginManager

Actions Plugin Manager

Type

\Zend\ServiceManager\AbstractPluginManager

$limits

$limits : array

List of Limit instances

Type

array

$listeners

$listeners : array

Event listeners

Type

array

$remoteAddress

$remoteAddress : \Zend\Http\PhpEnvironment\RemoteAddress

Remote Address

Type

\Zend\Http\PhpEnvironment\RemoteAddress

$pluginName

$pluginName : string

Name of controller plugin

Type

string

$storagePlugins

$storagePlugins : \Zend\ServiceManager\AbstractPluginManager

Storage Plugin Manager

Type

\Zend\ServiceManager\AbstractPluginManager

Methods

__construct()

__construct(array  $options = null) 

Initialize strategy

Parameters

array $options

attach()

attach(\Zend\EventManager\EventManagerInterface  $events) 

Attach event listeners

Parameters

\Zend\EventManager\EventManagerInterface $events
See also

detach()

detach(\Zend\EventManager\EventManagerInterface  $events) 

Detach event listeners

Parameters

\Zend\EventManager\EventManagerInterface $events
See also

getServiceLocator()

getServiceLocator() : \Zend\ServiceManager\ServiceLocatorInterface

Get service locator

Returns

\Zend\ServiceManager\ServiceLocatorInterface
See also

setServiceLocator()

setServiceLocator(\Zend\ServiceManager\ServiceLocatorInterface  $serviceLocator) 

Set service locator

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
See also

getActionPlugins()

getActionPlugins() : \Zend\ServiceManager\AbstractPluginManager

Get action plugin manager

Returns

\Zend\ServiceManager\AbstractPluginManager

setActionPlugins()

setActionPlugins(\Zend\ServiceManager\AbstractPluginManager  $actionPlugins) 

Set action plugin manager

Parameters

\Zend\ServiceManager\AbstractPluginManager $actionPlugins

getLimits()

getLimits() : array

Get limits

Returns

array

setLimits()

setLimits(array  $limits) 

Set limits

Parameters

array $limits

getPluginName()

getPluginName() : string

Get controller plugin name

Returns

string

setStorage()

setStorage(\Spork\Mvc\Listener\Limit\StorageInterface|string|array  $storage) : \Spork\Mvc\Listener\Limit\LimitStrategy

Set storage instance

Parameters

\Spork\Mvc\Listener\Limit\StorageInterface|string|array $storage

Throws

\Exception

on invalid type

Returns

\Spork\Mvc\Listener\Limit\LimitStrategy

getStoragePlugins()

getStoragePlugins() : \Zend\ServiceManager\AbstractPluginManager

Get storage plugin manager

Returns

\Zend\ServiceManager\AbstractPluginManager

setStoragePlugins()

setStoragePlugins(\Zend\ServiceManager\AbstractPluginManager  $plugins) : \Spork\Mvc\Listener\Limit\LimitStrategy

Set storage plugin manager

Parameters

\Zend\ServiceManager\AbstractPluginManager $plugins

Returns

\Spork\Mvc\Listener\Limit\LimitStrategy

increment()

increment(string  $limitName) 

Increment the count for a limit

Parameters

string $limitName

initialize()

initialize(\Zend\Mvc\MvcEvent  $event) 

Configure instance and inject it into controller plugin manager

Parameters

\Zend\Mvc\MvcEvent $event

check()

check(\Zend\Mvc\MvcEvent  $event) 

Test limits and take actions if they have been exceeded

Parameters

\Zend\Mvc\MvcEvent $event

configure()

configure(array  $options) 

Configure instance

Parameters

array $options