本文整理汇总了PHP中Zend\Cache\Storage\Capabilities类的典型用法代码示例。如果您正苦于以下问题:PHP Capabilities类的具体用法?PHP Capabilities怎么用?PHP Capabilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Capabilities类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTriggerChangeEventOfBaseCapabilities
public function testTriggerChangeEventOfBaseCapabilities()
{
$em = $this->_capabilities->getEventManager();
$this->assertInstanceOf('Zend\\EventManager\\EventManager', $em);
$event = null;
$em->attach('change', function ($eventArg) use(&$event) {
$event = $eventArg;
});
$this->_baseCapabilities->setMaxTtl($this->_marker, 100);
$this->assertInstanceOf('Zend\\EventManager\\Event', $event);
$this->assertEquals('change', $event->getName());
$this->assertSame($this->_baseCapabilities, $event->getTarget());
$this->assertEquals(array('maxTtl' => 100), $event->getParams());
}
示例2: getEventManager
/**
* Get the event manager
*
* @return EventManager
* @throws Exception\MissingDependencyException
*/
public function getEventManager()
{
if ($this->eventManager instanceof EventManager) {
return $this->eventManager;
}
if (!class_exists('Zend\\EventManager\\EventManager')) {
throw new Exception\MissingDependencyException('Zend\\EventManager\\EventManager not found');
}
// create a new event manager object
$eventManager = new EventManager();
// trigger change event on change of a base capability
if ($this->baseCapabilities && $this->baseCapabilities->hasEventManager()) {
$onChange = function ($event) use($eventManager) {
$eventManager->trigger('change', $event->getTarget(), $event->getParams());
};
$this->baseCapabilities->getEventManager()->attach('change', $onChange);
}
// register event manager
$this->eventManager = $eventManager;
return $this->eventManager;
}
示例3: internalGetCapabilities
/**
* Internal method to get capabilities of this adapter
*
* @return Capabilities
*/
protected function internalGetCapabilities()
{
if ($this->capabilities === null) {
$marker = new stdClass();
$capabilities = new Capabilities($this, $marker, array('supportedDatatypes' => array('NULL' => true, 'boolean' => true, 'integer' => true, 'double' => true, 'string' => true, 'array' => true, 'object' => 'object', 'resource' => false), 'supportedMetadata' => array('internal_key', 'atime', 'ctime', 'mtime', 'rtime', 'size', 'hits', 'ttl'), 'minTtl' => 1, 'maxTtl' => 0, 'staticTtl' => true, 'ttlPrecision' => 1, 'useRequestTime' => (bool) ini_get('apc.use_request_time'), 'expiredRead' => false, 'maxKeyLength' => 5182, 'namespaceIsPrefix' => true, 'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator()));
// update namespace separator on change option
$this->getEventManager()->attach('option', function ($event) use($capabilities, $marker) {
$params = $event->getParams();
if (isset($params['namespace_separator'])) {
$capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
}
});
$this->capabilities = $capabilities;
$this->capabilityMarker = $marker;
}
return $this->capabilities;
}
示例4: internalGetCapabilities
/**
* Internal method to get capabilities of this adapter
*
* @return Capabilities
*/
protected function internalGetCapabilities()
{
if ($this->capabilities === null) {
$marker = new stdClass();
$options = $this->getOptions();
// detect metadata
$metadata = array('mtime', 'filespec');
if (!$options->getNoAtime()) {
$metadata[] = 'atime';
}
if (!$options->getNoCtime()) {
$metadata[] = 'ctime';
}
$capabilities = new Capabilities($this, $marker, array('supportedDatatypes' => array('NULL' => 'string', 'boolean' => 'string', 'integer' => 'string', 'double' => 'string', 'string' => true, 'array' => false, 'object' => false, 'resource' => false), 'supportedMetadata' => $metadata, 'minTtl' => 1, 'maxTtl' => 0, 'staticTtl' => false, 'ttlPrecision' => 1, 'expiredRead' => true, 'maxKeyLength' => 251, 'namespaceIsPrefix' => true, 'namespaceSeparator' => $options->getNamespaceSeparator()));
// update capabilities on change options
$this->getEventManager()->attach('option', function ($event) use($capabilities, $marker) {
$params = $event->getParams();
if (isset($params['namespace_separator'])) {
$capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
}
if (isset($params['no_atime']) || isset($params['no_ctime'])) {
$metadata = $capabilities->getSupportedMetadata();
if (isset($params['no_atime']) && !$params['no_atime']) {
$metadata[] = 'atime';
} elseif (isset($params['no_atime']) && ($index = array_search('atime', $metadata)) !== false) {
unset($metadata[$index]);
}
if (isset($params['no_ctime']) && !$params['no_ctime']) {
$metadata[] = 'ctime';
} elseif (isset($params['no_ctime']) && ($index = array_search('ctime', $metadata)) !== false) {
unset($metadata[$index]);
}
$capabilities->setSupportedMetadata($marker, $metadata);
}
});
$this->capabilityMarker = $marker;
$this->capabilities = $capabilities;
}
return $this->capabilities;
}
示例5: internalGetCapabilities
/**
* Internal method to get capabilities of this adapter
*
* @return Capabilities
*/
protected function internalGetCapabilities()
{
if ($this->capabilities === null) {
$marker = new stdClass();
$capabilities = new Capabilities($this, $marker, array('supportedDatatypes' => array('NULL' => 'string', 'boolean' => 'string', 'integer' => 'string', 'double' => 'string', 'string' => true, 'array' => false, 'object' => false, 'resource' => false), 'minTtl' => 0, 'supportedMetadata' => array(), 'maxKeyLength' => 0, 'namespaceIsPrefix' => true, 'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator()));
// update namespace separator on change option
$this->getEventManager()->attach('option', function ($event) use($capabilities, $marker) {
$params = $event->getParams();
if (isset($params['namespace_separator'])) {
$capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
}
});
$this->capabilities = $capabilities;
$this->capabilityMarker = $marker;
}
return $this->capabilities;
}
示例6: testTriggerCapabilityEvent
public function testTriggerCapabilityEvent()
{
$em = $this->_capabilities->getAdapter()->getEventManager();
$event = null;
$em->attach('capability', function ($eventArg) use(&$event) {
$event = $eventArg;
});
$this->_capabilities->setMaxTtl($this->_marker, 100);
$this->assertInstanceOf('Zend\\EventManager\\Event', $event);
$this->assertEquals('capability', $event->getName());
$this->assertSame($this->_adapter, $event->getTarget());
$params = $event->getParams();
$this->assertInstanceOf('ArrayObject', $params);
$this->assertTrue(isset($params['maxTtl']));
$this->assertEquals(100, $params['maxTtl']);
}