Пример #1
0
 public function testBuildEntityWithUnsupportedSecurityToken()
 {
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $token->expects($this->once())->method('getUser')->willReturn('test');
     $this->tokenStorage->expects($this->any())->method('getToken')->willReturn($token);
     $this->configManager->expects($this->never())->method('getUpdateConfig');
     $this->auditManager->buildEntity($this->configManager);
 }
Пример #2
0
 /**
  * Flushes all changes that have been queued up to now to a database.
  */
 public function flush()
 {
     /** @var ConfigModel[] $models */
     $models = [];
     $this->prepareFlush($models);
     $em = $this->getEntityManager();
     $now = new \DateTime('now', new \DateTimeZone('UTC'));
     $logEntry = $this->auditManager->buildEntity($this);
     foreach ($models as $model) {
         if (null === $model->getId()) {
             $model->setCreated($now);
         }
         $model->setUpdated($now);
         $em->persist($model);
     }
     if (!empty($models)) {
         $em->flush();
     }
     if (null !== $logEntry) {
         $this->auditManager->save($logEntry);
     }
     // @todo: Should be removed together with deprecated events
     if ($this->hasListeners(Events::POST_FLUSH_CONFIG)) {
         $this->eventDispatcher->dispatch(Events::POST_FLUSH_CONFIG, new Event\FlushConfigEvent($models, $this));
     }
     $this->eventDispatcher->dispatch(Events::POST_FLUSH, new Event\PostFlushConfigEvent($models, $this));
     if (!empty($models)) {
         $this->cache->deleteAllConfigurable();
     }
     $this->persistConfigs = [];
     $this->configChangeSets = [];
 }