当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage\Capabilities类代码示例

本文整理汇总了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());
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:14,代码来源:CapabilitiesTest.php

示例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;
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:27,代码来源:Capabilities.php

示例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;
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:22,代码来源:Apc.php

示例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;
 }
开发者ID:tillk,项目名称:vufind,代码行数:45,代码来源:Filesystem.php

示例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;
 }
开发者ID:tillk,项目名称:vufind,代码行数:22,代码来源:Dba.php

示例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']);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:16,代码来源:CapabilitiesTest.php


注:本文中的Zend\Cache\Storage\Capabilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。