Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Config/AutowireServiceResource.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\DependencyInjection\Config; | |
13 | |
14 use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; | |
15 use Symfony\Component\DependencyInjection\Compiler\AutowirePass; | |
16 | |
17 class AutowireServiceResource implements SelfCheckingResourceInterface, \Serializable | |
18 { | |
19 private $class; | |
20 private $filePath; | |
21 private $autowiringMetadata = array(); | |
22 | |
23 public function __construct($class, $path, array $autowiringMetadata) | |
24 { | |
25 $this->class = $class; | |
26 $this->filePath = $path; | |
27 $this->autowiringMetadata = $autowiringMetadata; | |
28 } | |
29 | |
30 public function isFresh($timestamp) | |
31 { | |
32 if (!file_exists($this->filePath)) { | |
33 return false; | |
34 } | |
35 | |
36 // has the file *not* been modified? Definitely fresh | |
37 if (@filemtime($this->filePath) <= $timestamp) { | |
38 return true; | |
39 } | |
40 | |
41 try { | |
42 $reflectionClass = new \ReflectionClass($this->class); | |
43 } catch (\ReflectionException $e) { | |
44 // the class does not exist anymore! | |
45 return false; | |
46 } | |
47 | |
48 return (array) $this === (array) AutowirePass::createResourceForClass($reflectionClass); | |
49 } | |
50 | |
51 public function __toString() | |
52 { | |
53 return 'service.autowire.'.$this->class; | |
54 } | |
55 | |
56 public function serialize() | |
57 { | |
58 return serialize(array($this->class, $this->filePath, $this->autowiringMetadata)); | |
59 } | |
60 | |
61 public function unserialize($serialized) | |
62 { | |
63 list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized); | |
64 } | |
65 | |
66 /** | |
67 * @deprecated Implemented for compatibility with Symfony 2.8 | |
68 */ | |
69 public function getResource() | |
70 { | |
71 return $this->filePath; | |
72 } | |
73 } |