public function flush()
 {
     $models = array();
     foreach ($this->persistConfigs as $config) {
         $this->calculateConfigChangeSet($config);
         $this->eventDispatcher->dispatch(Events::PRE_PERSIST_CONFIG, new PersistConfigEvent($config, $this));
         if (isset($models[$config->getId()->toString()])) {
             $model = $models[$config->getId()->toString()];
         } else {
             $model = $this->modelManager->getModelByConfigId($config->getId());
             $models[$config->getId()->toString()] = $model;
         }
         //TODO::refactoring
         $serializableValues = $this->getProvider($config->getId()->getScope())->getPropertyConfig()->getSerializableValues($config->getId());
         $model->fromArray($config->getId()->getScope(), $config->all(), $serializableValues);
         if ($this->cache) {
             $this->cache->removeConfigFromCache($config->getId());
             $this->cache->removeAllConfigurable();
         }
     }
     $this->auditManager->log();
     foreach ($models as $model) {
         $this->getEntityManager()->persist($model);
     }
     $this->getEntityManager()->flush();
     $this->persistConfigs = new \SplObjectStorage();
     $this->configChangeSets = new ArrayCollection();
 }
 public function testLogWithoutUser()
 {
     $securityContext = $this->getMockForAbstractClass('Symfony\\Component\\Security\\Core\\SecurityContextInterface');
     $securityContext->expects($this->any())->method('getToken');
     $securityLink = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\DependencyInjection\\Utils\\ServiceLink')->disableOriginalConstructor()->getMock();
     $securityLink->expects($this->any())->method('getService')->will($this->returnValue($securityContext));
     $configManager = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
     $configManagerLink = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\DependencyInjection\\Utils\\ServiceLink')->disableOriginalConstructor()->getMock();
     $configManagerLink->expects($this->any())->method('getService')->will($this->returnValue($configManager));
     $auditManager = new AuditManager($configManagerLink, $securityLink);
     $auditManager->log();
 }
Пример #3
0
 public function flush()
 {
     $models = [];
     $this->prepareFlush($models);
     $this->auditManager->log();
     foreach ($models as $model) {
         $this->getEntityManager()->persist($model);
     }
     // @todo: need investigation if we can call this flush only if !empty($models)
     $this->getEntityManager()->flush();
     $this->eventDispatcher->dispatch(Events::POST_FLUSH_CONFIG, new FlushConfigEvent($models, $this));
     if ($this->cache && !empty($models)) {
         $this->cache->removeAllConfigurable();
     }
     $this->persistConfigs = [];
     $this->configChangeSets = [];
 }