4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Config;
14 @trigger_error('The '.__NAMESPACE__.'\AutowireServiceResource class is deprecated since Symfony 3.3 and will be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead.', E_USER_DEPRECATED);
16 use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
17 use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
20 * @deprecated since version 3.3, to be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead.
22 class AutowireServiceResource implements SelfCheckingResourceInterface, \Serializable
26 private $autowiringMetadata = array();
28 public function __construct($class, $path, array $autowiringMetadata)
30 $this->class = $class;
31 $this->filePath = $path;
32 $this->autowiringMetadata = $autowiringMetadata;
35 public function isFresh($timestamp)
37 if (!file_exists($this->filePath)) {
41 // has the file *not* been modified? Definitely fresh
42 if (@filemtime($this->filePath) <= $timestamp) {
47 $reflectionClass = new \ReflectionClass($this->class);
48 } catch (\ReflectionException $e) {
49 // the class does not exist anymore!
53 return (array) $this === (array) AutowirePass::createResourceForClass($reflectionClass);
56 public function __toString()
58 return 'service.autowire.'.$this->class;
61 public function serialize()
63 return serialize(array($this->class, $this->filePath, $this->autowiringMetadata));
66 public function unserialize($serialized)
68 if (\PHP_VERSION_ID >= 70000) {
69 list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized, array('allowed_classes' => false));
71 list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized);
76 * @deprecated Implemented for compatibility with Symfony 2.8
78 public function getResource()
80 return $this->filePath;