mirror of
https://github.com/symfony/ux-svelte.git
synced 2026-03-24 00:12:07 +01:00
80 lines
2.3 KiB
PHP
80 lines
2.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\UX\Svelte\Tests\Kernel;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
|
use Symfony\Bundle\TwigBundle\TwigBundle;
|
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\HttpKernel\Kernel;
|
|
use Symfony\UX\StimulusBundle\StimulusBundle;
|
|
use Symfony\UX\Svelte\SvelteBundle;
|
|
|
|
/**
|
|
* @author Titouan Galopin <galopintitouan@gmail.com>
|
|
* @author Thomas Choquet <thomas.choquet.pro@gmail.com>
|
|
*
|
|
* @internal
|
|
*/
|
|
class TwigAppKernel extends Kernel
|
|
{
|
|
public function registerBundles(): iterable
|
|
{
|
|
return [new StimulusBundle(), new FrameworkBundle(), new TwigBundle(), new SvelteBundle()];
|
|
}
|
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader): void
|
|
{
|
|
$loader->load(static function (ContainerBuilder $container) {
|
|
$container->loadFromExtension('framework', [
|
|
'secret' => '$ecret',
|
|
'test' => true,
|
|
'http_method_override' => false,
|
|
'php_errors' => [
|
|
'log' => true,
|
|
],
|
|
...(self::VERSION_ID >= 60200 ? [
|
|
'handle_all_throwables' => true,
|
|
] : []),
|
|
]);
|
|
$container->loadFromExtension('twig', [
|
|
'default_path' => __DIR__.'/templates',
|
|
'strict_variables' => true,
|
|
]);
|
|
|
|
$container->setAlias('test.twig', 'twig')->setPublic(true);
|
|
$container->setAlias('test.twig.extension.svelte', 'twig.extension.svelte')->setPublic(true);
|
|
});
|
|
}
|
|
|
|
public function getCacheDir(): string
|
|
{
|
|
return $this->createTmpDir('cache');
|
|
}
|
|
|
|
public function getLogDir(): string
|
|
{
|
|
return $this->createTmpDir('logs');
|
|
}
|
|
|
|
private function createTmpDir(string $type): string
|
|
{
|
|
$dir = sys_get_temp_dir().'/svelte_bundle/'.uniqid($type.'_', true);
|
|
|
|
if (!file_exists($dir)) {
|
|
mkdir($dir, 0o777, true);
|
|
}
|
|
|
|
return $dir;
|
|
}
|
|
}
|