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@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); Chris@14: Chris@0: use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; Chris@0: use Symfony\Component\DependencyInjection\Compiler\AutowirePass; Chris@0: Chris@14: /** Chris@14: * @deprecated since version 3.3, to be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead. Chris@14: */ Chris@0: class AutowireServiceResource implements SelfCheckingResourceInterface, \Serializable Chris@0: { Chris@0: private $class; Chris@0: private $filePath; Chris@17: private $autowiringMetadata = []; 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@17: /** Chris@17: * @internal Chris@17: */ Chris@0: public function serialize() Chris@0: { Chris@17: return serialize([$this->class, $this->filePath, $this->autowiringMetadata]); Chris@0: } Chris@0: Chris@17: /** Chris@17: * @internal Chris@17: */ Chris@0: public function unserialize($serialized) Chris@0: { Chris@14: if (\PHP_VERSION_ID >= 70000) { Chris@17: list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized, ['allowed_classes' => false]); Chris@14: } else { Chris@14: list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized); Chris@14: } 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: }