本文整理汇总了PHP中Zend\Cache\Storage\StorageInterface::getEventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageInterface::getEventManager方法的具体用法?PHP StorageInterface::getEventManager怎么用?PHP StorageInterface::getEventManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Cache\Storage\StorageInterface
的用法示例。
在下文中一共展示了StorageInterface::getEventManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: triggerOptionEvent
/**
* Triggers an option event if this options instance has a connection to
* an adapter implements EventsCapableInterface.
*
* @param string $optionName
* @param mixed $optionValue
* @return void
*/
protected function triggerOptionEvent($optionName, $optionValue)
{
if ($this->adapter instanceof EventsCapableInterface) {
$event = new Event('option', $this->adapter, new ArrayObject([$optionName => $optionValue]));
$this->adapter->getEventManager()->triggerEvent($event);
}
}
示例2: setCapability
/**
* Change a capability
*
* @param stdClass $marker
* @param string $property
* @param mixed $value
* @return Capabilities Fluent interface
* @throws Exception\InvalidArgumentException
*/
protected function setCapability(stdClass $marker, $property, $value)
{
if ($this->marker !== $marker) {
throw new Exception\InvalidArgumentException('Invalid marker');
}
if ($this->{$property} !== $value) {
$this->{$property} = $value;
// trigger event
if ($this->storage instanceof EventsCapableInterface) {
$this->storage->getEventManager()->trigger('capability', $this->storage, new ArrayObject(array($property => $value)));
}
}
return $this;
}
示例3: triggerCacheException
/**
* Fakes an exception in the cache, so that the cache's own EventManager decides what to do with it (throw or continue without cache)
*
* @param string $eventName name of faked storage adapter method (e.g. getItem or setItem)
* @param array $args arguments for the faked method call to the storage adapter
* @param mixed $result return value of the faked method call in case the exception will not be (re)thrown
* @param \Exception $exception exception which 'supposedly' got thrown within the faked method
* @return mixed the return value after triggering an ExceptionEvent at the EventManager (most likely the original $result)
* @throws \Exception the original $exception, depending on the ExceptionEvent's 'ThrowException' value after being triggered at the EventManager
* @see \Zend\Cache\Storage\Adapter\AbstractAdapter::triggerException()
*/
protected static function triggerCacheException($eventName, $args, &$result, \Exception $exception)
{
if (is_null(self::$cache)) {
return $result;
}
if (is_array($args)) {
$args = new \ArrayObject($args);
}
$exceptionEvent = new \Zend\Cache\Storage\ExceptionEvent($eventName . '.exception', self::$cache, $args, $result, $exception);
$responseCollection = self::$cache->getEventManager()->trigger($exceptionEvent);
if ($exceptionEvent->getThrowException()) {
throw $exceptionEvent->getException();
}
if ($responseCollection->stopped()) {
return $responseCollection->last();
}
return $exceptionEvent->getResult();
}