Contao\CoreBundle\Cache\ContaoCacheWarmer::warmUp PHP Method

warmUp() public method

public warmUp ( $cacheDir )
    public function warmUp($cacheDir)
    {
        if (!$this->isCompleteInstallation()) {
            return;
        }
        $this->framework->initialize();
        $this->generateConfigCache($cacheDir);
        $this->generateDcaCache($cacheDir);
        $this->generateLanguageCache($cacheDir);
        $this->generateDcaExtracts($cacheDir);
        $this->generateTemplateMapper($cacheDir);
    }

Usage Example

コード例 #1
0
 /**
  * Tests the warmUp() method.
  */
 public function testWarmUp()
 {
     /** @var Connection|\PHPUnit_Framework_MockObject_MockObject $connection */
     $connection = $this->getMock('Doctrine\\DBAL\\Connection', ['prepare', 'execute', 'fetch', 'query'], [], '', false);
     $connection->expects($this->any())->method('prepare')->willReturn($connection);
     $class1 = new \stdClass();
     $class1->language = 'en-US';
     $class2 = new \stdClass();
     $class2->language = 'en';
     $connection->expects($this->exactly(3))->method('fetch')->willReturnOnConsecutiveCalls($class1, $class2, false);
     $warmer = new ContaoCacheWarmer(new Filesystem(), new ResourceFinder($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'), new FileLocator($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'), $this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao', $connection, $this->mockContaoFramework());
     $warmer->warmUp($this->getCacheDir());
     $this->assertFileExists($this->getCacheDir() . '/contao');
     $this->assertFileExists($this->getCacheDir() . '/contao/config');
     $this->assertFileExists($this->getCacheDir() . '/contao/config/autoload.php');
     $this->assertFileExists($this->getCacheDir() . '/contao/config/config.php');
     $this->assertFileExists($this->getCacheDir() . '/contao/config/mapping.php');
     $this->assertFileExists($this->getCacheDir() . '/contao/dca');
     $this->assertFileExists($this->getCacheDir() . '/contao/dca/tl_test.php');
     $this->assertFileExists($this->getCacheDir() . '/contao/languages');
     $this->assertFileExists($this->getCacheDir() . '/contao/languages/en');
     $this->assertFileExists($this->getCacheDir() . '/contao/languages/en/default.php');
     $this->assertFileExists($this->getCacheDir() . '/contao/sql');
     $this->assertFileExists($this->getCacheDir() . '/contao/sql/tl_test.php');
     $this->assertContains("\$GLOBALS['TL_TEST'] = true;", file_get_contents($this->getCacheDir() . '/contao/config/config.php'));
     $this->assertContains('*/empty.fallback', file_get_contents($this->getCacheDir() . '/contao/config/mapping.php'));
     $this->assertContains('test.com/empty.en', file_get_contents($this->getCacheDir() . '/contao/config/mapping.php'));
     $this->assertContains("\$GLOBALS['TL_DCA']['tl_test'] = [\n", file_get_contents($this->getCacheDir() . '/contao/dca/tl_test.php'));
     $this->assertContains("\$GLOBALS['TL_LANG']['MSC']['first']", file_get_contents($this->getCacheDir() . '/contao/languages/en/default.php'));
     $this->assertContains("\$this->arrFields = array (\n  'id' => 'int(10) unsigned NOT NULL auto_increment',\n);", file_get_contents($this->getCacheDir() . '/contao/sql/tl_test.php'));
 }
All Usage Examples Of Contao\CoreBundle\Cache\ContaoCacheWarmer::warmUp