コード例 #1
0
ファイル: Search.php プロジェクト: bbeckman/NDL-VuFind2
 /**
  * Initialize
  *
  * @return void
  */
 public function initialize()
 {
     if ($this->isInitialized) {
         return;
     }
     // Special case for PostgreSQL inserts -- we need to provide an extra
     // clue so that the database knows how to write bytea data correctly:
     if ($this->adapter->getDriver()->getDatabasePlatformName() == "Postgresql") {
         if (!is_object($this->featureSet)) {
             $this->featureSet = new Feature\FeatureSet();
         }
         $eventFeature = new Feature\EventFeature();
         $eventFeature->getEventManager()->attach(Feature\EventFeature::EVENT_PRE_INSERT, [$this, 'onPreInsert']);
         $this->featureSet->addFeature($eventFeature);
     }
     parent::initialize();
 }
コード例 #2
0
ファイル: Module.php プロジェクト: kalelc/inventory
 public function getServiceConfig()
 {
     return array('factories' => array('Cache\\Adapter\\MemcachedOptions' => function ($sm) {
         $config = $sm->get('config');
         return new MemcachedOptions($config['memcached']);
     }, 'Cache\\Adapter\\Memcached' => function ($sm) {
         return new Memcached($sm->get('Cache\\Adapter\\MemcachedOptions'));
     }, "Application\\Listener\\MemcachedListener" => function ($sm) {
         $memcached = $sm->get('Cache\\Adapter\\Memcached');
         $cacheListener = new MemcachedListener($memcached);
         return $cacheListener;
     }, 'Zend\\EventManager\\EventManager' => function ($sm) {
         $eventManager = new EventManager();
         return $eventManager;
     }), 'initializers' => array('EventFeatureCacheAwareInterface' => function ($model, $serviceLocator) {
         if ($model instanceof EventFeatureCacheAwareInterface) {
             $logListener = $serviceLocator->get('Security\\Listener\\LogListener');
             $eventFeature = new EventFeature();
             $eventFeature->getEventManager()->attachAggregate($logListener);
             $model->setEventFeatureCache($eventFeature);
         }
     }));
 }
コード例 #3
0
ファイル: EventFeatureTest.php プロジェクト: pnaq57/zf2demo
 public function testPostDelete()
 {
     $closureHasRun = false;
     /** @var $event EventFeature\TableGatewayEvent */
     $event = null;
     $this->eventManager->attach('postDelete', function ($e) use(&$closureHasRun, &$event) {
         $event = $e;
         $closureHasRun = true;
     });
     $this->feature->postDelete($stmt = $this->getMock('Zend\\Db\\Adapter\\Driver\\StatementInterface'), $result = $this->getMock('Zend\\Db\\Adapter\\Driver\\ResultInterface'));
     $this->assertTrue($closureHasRun);
     $this->assertInstanceOf('Zend\\Db\\TableGateway\\TableGateway', $event->getTarget());
     $this->assertEquals('postDelete', $event->getName());
     $this->assertSame($stmt, $event->getParam('statement'));
     $this->assertSame($result, $event->getParam('result'));
 }