Пример #1
0
 public function testConfigLog()
 {
     $userMock = $this->getMockForAbstractClass('Symfony\\Component\\Security\\Core\\User\\UserInterface');
     $this->assertEmpty($this->configLog->getId());
     $data = new \DateTime();
     $this->configLog->setLoggedAt($data);
     $this->assertEquals($data, $this->configLog->getLoggedAt());
     $this->configLog->setLoggedAt(null);
     $this->configLog->prePersist();
     $this->assertInstanceOf('\\DateTime', $this->configLog->getLoggedAt());
     $this->configLog->setUser($userMock);
     $this->assertEquals($userMock, $this->configLog->getUser());
     $this->configLog->addDiff($this->configLogDiff);
     $this->assertEquals($this->configLogDiff, $this->configLog->getDiffs()->first());
     $diffsCollection = new ArrayCollection(array($this->configLogDiff));
     $this->configLog->setDiffs($diffsCollection);
     $this->assertEquals($diffsCollection, $this->configLog->getDiffs());
 }
Пример #2
0
 /**
  * Log all changed Config
  */
 public function log()
 {
     if (!$this->getUser()) {
         return;
     }
     $log = new ConfigLog();
     $log->setUser($this->getUser());
     foreach ($this->getConfigManager()->getUpdateConfig() as $config) {
         if ($diff = $this->computeChanges($config, $log)) {
             $log->addDiff($diff);
         }
     }
     if ($log->getDiffs()->count()) {
         $this->getConfigManager()->getEntityManager()->persist($log);
     }
 }
Пример #3
0
 /**
  * Creates a log entry contains all changed configs
  *
  * @param ConfigManager $configManager
  *
  * @return ConfigLog|null
  */
 public function buildLogEntry(ConfigManager $configManager)
 {
     $user = $this->getUser();
     if (null === $user) {
         return null;
     }
     $log = new ConfigLog();
     foreach ($configManager->getUpdateConfig() as $config) {
         $diff = $this->computeChanges($config, $configManager);
         if (null !== $diff) {
             $log->addDiff($diff);
         }
     }
     if ($log->getDiffs()->isEmpty()) {
         return null;
     }
     $log->setUser($user);
     return $log;
 }