migration symfony 5 4 (#300)

* symfony 5.4 (diff dev)

* symfony 5.4 (working)

* symfony 5.4 (update autoload)

* symfony 5.4 (remove swiftmailer mailer implementation)

* symfony 5.4 (php doc and split Global accessor class)


### Impacted packages:

composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies

composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
bdalsass
2022-06-16 09:13:24 +02:00
committed by GitHub
parent abb13b70b9
commit 79da71ecf8
2178 changed files with 87439 additions and 59451 deletions

View File

@@ -15,16 +15,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Loader\ExistsLoaderInterface;
use Twig\Loader\SourceContextLoaderInterface;
use Twig\Template;
/**
* Profiler Templates Manager.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Artur Wielogórski <wodor@wodor.net>
*
* @internal
*/
class TemplateManager
{
@@ -42,13 +38,11 @@ class TemplateManager
/**
* Gets the template name for a given panel.
*
* @param string $panel
*
* @return mixed
*
* @throws NotFoundHttpException
*/
public function getName(Profile $profile, $panel)
public function getName(Profile $profile, string $panel)
{
$templates = $this->getNames($profile);
@@ -59,33 +53,14 @@ class TemplateManager
return $templates[$panel];
}
/**
* Gets the templates for a given profile.
*
* @return Template[]
*
* @deprecated not used anymore internally
*/
public function getTemplates(Profile $profile)
{
$templates = $this->getNames($profile);
foreach ($templates as $name => $template) {
$templates[$name] = $this->twig->loadTemplate($template);
}
return $templates;
}
/**
* Gets template names of templates that are present in the viewed profile.
*
* @return array
*
* @throws \UnexpectedValueException
*/
public function getNames(Profile $profile)
public function getNames(Profile $profile): array
{
$loader = $this->twig->getLoader();
$templates = [];
foreach ($this->templates as $arguments) {
@@ -93,17 +68,17 @@ class TemplateManager
continue;
}
list($name, $template) = $arguments;
[$name, $template] = $arguments;
if (!$this->profiler->has($name) || !$profile->hasCollector($name)) {
continue;
}
if ('.html.twig' === substr($template, -10)) {
if (str_ends_with($template, '.html.twig')) {
$template = substr($template, 0, -10);
}
if (!$this->templateExists($template.'.html.twig')) {
if (!$loader->exists($template.'.html.twig')) {
throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
}
@@ -112,27 +87,4 @@ class TemplateManager
return $templates;
}
// to be removed when the minimum required version of Twig is >= 2.0
protected function templateExists($template)
{
$loader = $this->twig->getLoader();
if (1 === Environment::MAJOR_VERSION && !$loader instanceof ExistsLoaderInterface) {
try {
if ($loader instanceof SourceContextLoaderInterface) {
$loader->getSourceContext($template);
} else {
$loader->getSource($template);
}
return true;
} catch (LoaderError $e) {
}
return false;
}
return $loader->exists($template);
}
}