Skip to content

Commit

Permalink
initialize the default MimeTypes instance in its constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Jan 27, 2019
1 parent 1aa652e commit a6a5fab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Expand Up @@ -73,11 +73,6 @@ public function boot()
if ($trustedHosts = $this->container->getParameter('kernel.trusted_hosts')) {
Request::setTrustedHosts($trustedHosts);
}

if ($this->container->has('mime_types')) {
$mt = $this->container->get('mime_types');
$mt->setDefault($mt);
}
}

public function build(ContainerBuilder $container)
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Mime/MimeTypes.php
Expand Up @@ -45,6 +45,10 @@ public function __construct(array $map = [])
}
$this->registerGuesser(new FileBinaryMimeTypeGuesser());
$this->registerGuesser(new FileinfoMimeTypeGuesser());

if (null === self::$default) {
self::$default = $this;
}
}

public static function setDefault(self $default)
Expand All @@ -54,7 +58,7 @@ public static function setDefault(self $default)

public static function getDefault(): self
{
return self::$default ?? self::$default = new self();
return self::$default;
}

/**
Expand Down

0 comments on commit a6a5fab

Please sign in to comment.