Removed deprecations in Templating component
This commit is contained in:
parent
ac1465e1fb
commit
c936361fa6
@ -1,52 +0,0 @@
|
||||
<?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\Bundle\FrameworkBundle\Templating;
|
||||
|
||||
trigger_error('The '.__NAMESPACE__.'\Debugger class is deprecated since version 2.4 and will be removed in 3.0. Use the Psr\Log\LoggerInterface interface instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Templating\DebuggerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Binds the Symfony templating loader debugger to the Symfony logger.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
* Use Psr\Log\LoggerInterface instead.
|
||||
*/
|
||||
class Debugger implements DebuggerInterface
|
||||
{
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
*/
|
||||
public function __construct(LoggerInterface $logger = null)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message.
|
||||
*
|
||||
* @param string $message A message to log
|
||||
*/
|
||||
public function log($message)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug($message);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?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\Component\Templating;
|
||||
|
||||
/**
|
||||
* DebuggerInterface is the interface you need to implement
|
||||
* to debug template loader instances.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0. Use Psr\Log\LoggerInterface instead.
|
||||
*/
|
||||
interface DebuggerInterface
|
||||
{
|
||||
/**
|
||||
* Logs a message.
|
||||
*
|
||||
* @param string $message A message to log
|
||||
*/
|
||||
public function log($message);
|
||||
}
|
@ -65,15 +65,12 @@ class FilesystemLoader extends Loader
|
||||
if (is_file($file = strtr($templatePathPattern, $replacements)) && is_readable($file)) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('Loaded template file.', array('file' => $file));
|
||||
} elseif (null !== $this->debugger) {
|
||||
// just for BC, to be removed in 3.0
|
||||
$this->debugger->log(sprintf('Loaded template file "%s".', $file));
|
||||
}
|
||||
|
||||
return new FileStorage($file);
|
||||
}
|
||||
|
||||
if (null !== $this->logger || null !== $this->debugger) {
|
||||
if (null !== $this->logger) {
|
||||
$fileFailures[] = $file;
|
||||
}
|
||||
}
|
||||
@ -82,9 +79,6 @@ class FilesystemLoader extends Loader
|
||||
foreach ($fileFailures as $file) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('Failed loading template file.', array('file' => $file));
|
||||
} elseif (null !== $this->debugger) {
|
||||
// just for BC, to be removed in 3.0
|
||||
$this->debugger->log(sprintf('Failed loading template file "%s".', $file));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Templating\Loader;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Templating\DebuggerInterface;
|
||||
|
||||
/**
|
||||
* Loader is the base class for all template loader classes.
|
||||
@ -26,11 +25,6 @@ abstract class Loader implements LoaderInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.4, to be removed in 3.0. Use $this->logger instead.
|
||||
*/
|
||||
protected $debugger;
|
||||
|
||||
/**
|
||||
* Sets the debug logger to use for this loader.
|
||||
*
|
||||
@ -40,18 +34,4 @@ abstract class Loader implements LoaderInterface
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debugger to use for this loader.
|
||||
*
|
||||
* @param DebuggerInterface $debugger A debugger instance
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0. Use $this->setLogger() instead.
|
||||
*/
|
||||
public function setDebugger(DebuggerInterface $debugger)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. Use the setLogger() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->debugger = $debugger;
|
||||
}
|
||||
}
|
||||
|
@ -23,19 +23,6 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader->setLogger($logger);
|
||||
$this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetSetDebugger()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$loader = new ProjectTemplateLoader4();
|
||||
$debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');
|
||||
$loader->setDebugger($debugger);
|
||||
$this->assertSame($debugger, $loader->getDebugger(), '->setDebugger() sets the debugger instance');
|
||||
}
|
||||
}
|
||||
|
||||
class ProjectTemplateLoader4 extends Loader
|
||||
|
Reference in New Issue
Block a user