public function __invoke(MigrationContext $context)
 {
     $container = $context->getContainer();
     $working_directory = $container['working_directory'];
     $repository_sub_folders = glob($working_directory . '/*', GLOB_ONLYDIR);
     foreach ($repository_sub_folders as $repository_sub_folder) {
         $old_cache_files = glob($repository_sub_folder . '/*.cache');
         $new_cache_files = glob($repository_sub_folder . '/*_D*.cache');
         $cache_files = array_diff($old_cache_files, $new_cache_files);
         foreach ($cache_files as $cache_file) {
             $cache = new FileCacheStorage($cache_file);
             $cache_content = $cache->get();
             $cache_expires_on = $cache_content['expiration'];
             if (!isset($cache_expires_on)) {
                 $cache_content['duration'] = null;
             } else {
                 $cache_content['duration'] = $this->getDateDiff(filemtime($cache_file), $cache_expires_on);
             }
             $cache->set($cache_content);
             $filename_suffix = 'D' . (isset($cache_content['duration']) ? $cache_content['duration'] : 'INF');
             $new_cache_file = str_replace('.cache', '_' . $filename_suffix . '.cache', $cache_file);
             if (file_exists($new_cache_file)) {
                 unlink($cache_file);
             } else {
                 rename($cache_file, $new_cache_file);
             }
         }
     }
 }
 public function testGetDatabase()
 {
     $this->assertSame($this->database, $this->context->getDatabase());
 }
 /**
  * Creates migration manager context.
  *
  * @param ExtendedPdoInterface $database     Database.
  * @param RevisionLog          $revision_log Revision log.
  */
 public function __construct(ExtendedPdoInterface $database, RevisionLog $revision_log)
 {
     parent::__construct($database);
     $this->_revisionLog = $revision_log;
 }