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 use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
15 use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
17 class AutowireServiceResource implements SelfCheckingResourceInterface, \Serializable
21 private $autowiringMetadata = array();
23 public function __construct($class, $path, array $autowiringMetadata)
25 $this->class = $class;
26 $this->filePath = $path;
27 $this->autowiringMetadata = $autowiringMetadata;
30 public function isFresh($timestamp)
32 if (!file_exists($this->filePath)) {
36 // has the file *not* been modified? Definitely fresh
37 if (@filemtime($this->filePath) <= $timestamp) {
42 $reflectionClass = new \ReflectionClass($this->class);
43 } catch (\ReflectionException $e) {
44 // the class does not exist anymore!
48 return (array) $this === (array) AutowirePass::createResourceForClass($reflectionClass);
51 public function __toString()
53 return 'service.autowire.'.$this->class;
56 public function serialize()
58 return serialize(array($this->class, $this->filePath, $this->autowiringMetadata));
61 public function unserialize($serialized)
63 list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized);
67 * @deprecated Implemented for compatibility with Symfony 2.8
69 public function getResource()
71 return $this->filePath;