Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\DependencyInjection\Config; Chris@0: Chris@0: use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; Chris@0: use Symfony\Component\DependencyInjection\Compiler\AutowirePass; Chris@0: Chris@0: class AutowireServiceResource implements SelfCheckingResourceInterface, \Serializable Chris@0: { Chris@0: private $class; Chris@0: private $filePath; Chris@0: private $autowiringMetadata = array(); Chris@0: Chris@0: public function __construct($class, $path, array $autowiringMetadata) Chris@0: { Chris@0: $this->class = $class; Chris@0: $this->filePath = $path; Chris@0: $this->autowiringMetadata = $autowiringMetadata; Chris@0: } Chris@0: Chris@0: public function isFresh($timestamp) Chris@0: { Chris@0: if (!file_exists($this->filePath)) { Chris@0: return false; Chris@0: } Chris@0: Chris@0: // has the file *not* been modified? Definitely fresh Chris@0: if (@filemtime($this->filePath) <= $timestamp) { Chris@0: return true; Chris@0: } Chris@0: Chris@0: try { Chris@0: $reflectionClass = new \ReflectionClass($this->class); Chris@0: } catch (\ReflectionException $e) { Chris@0: // the class does not exist anymore! Chris@0: return false; Chris@0: } Chris@0: Chris@0: return (array) $this === (array) AutowirePass::createResourceForClass($reflectionClass); Chris@0: } Chris@0: Chris@0: public function __toString() Chris@0: { Chris@0: return 'service.autowire.'.$this->class; Chris@0: } Chris@0: Chris@0: public function serialize() Chris@0: { Chris@0: return serialize(array($this->class, $this->filePath, $this->autowiringMetadata)); Chris@0: } Chris@0: Chris@0: public function unserialize($serialized) Chris@0: { Chris@0: list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized); Chris@0: } Chris@0: Chris@0: /** Chris@0: * @deprecated Implemented for compatibility with Symfony 2.8 Chris@0: */ Chris@0: public function getResource() Chris@0: { Chris@0: return $this->filePath; Chris@0: } Chris@0: }