2016-03-12 20:10:13 +00:00
< ? php
/*
* This file is part of the Symfony package .
*
* ( c ) Fabien Potencier < fabien @ symfony . com >
*
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
namespace Symfony\Component\DependencyInjection\Config ;
2017-12-31 05:33:21 +00:00
@ 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 );
2017-01-26 15:09:57 +00:00
2016-03-12 20:10:13 +00:00
use Symfony\Component\Config\Resource\SelfCheckingResourceInterface ;
2016-04-04 13:41:40 +01:00
use Symfony\Component\DependencyInjection\Compiler\AutowirePass ;
2016-03-12 20:10:13 +00:00
2017-01-26 15:09:57 +00:00
/**
* @ deprecated since version 3.3 , to be removed in 4.0 . Use ContainerBuilder :: getReflectionClass () instead .
*/
2016-03-12 20:10:13 +00:00
class AutowireServiceResource implements SelfCheckingResourceInterface , \Serializable
{
private $class ;
private $filePath ;
2019-01-16 09:39:14 +00:00
private $autowiringMetadata = [];
2016-03-12 20:10:13 +00:00
public function __construct ( $class , $path , array $autowiringMetadata )
{
$this -> class = $class ;
$this -> filePath = $path ;
$this -> autowiringMetadata = $autowiringMetadata ;
}
public function isFresh ( $timestamp )
{
if ( ! file_exists ( $this -> filePath )) {
return false ;
}
2016-04-04 13:41:40 +01:00
// has the file *not* been modified? Definitely fresh
if ( @ filemtime ( $this -> filePath ) <= $timestamp ) {
return true ;
}
try {
$reflectionClass = new \ReflectionClass ( $this -> class );
} catch ( \ReflectionException $e ) {
// the class does not exist anymore!
return false ;
}
return ( array ) $this === ( array ) AutowirePass :: createResourceForClass ( $reflectionClass );
2016-03-12 20:10:13 +00:00
}
public function __toString ()
{
return 'service.autowire.' . $this -> class ;
}
2019-01-30 09:03:33 +00:00
/**
* @ internal
*/
2016-03-12 20:10:13 +00:00
public function serialize ()
{
2019-01-16 09:39:14 +00:00
return serialize ([ $this -> class , $this -> filePath , $this -> autowiringMetadata ]);
2016-03-12 20:10:13 +00:00
}
2019-01-30 09:03:33 +00:00
/**
* @ internal
*/
2016-03-12 20:10:13 +00:00
public function unserialize ( $serialized )
{
2017-06-02 10:51:43 +01:00
if ( \PHP_VERSION_ID >= 70000 ) {
2019-01-16 09:39:14 +00:00
list ( $this -> class , $this -> filePath , $this -> autowiringMetadata ) = unserialize ( $serialized , [ 'allowed_classes' => false ]);
2016-12-29 18:41:55 +00:00
} else {
list ( $this -> class , $this -> filePath , $this -> autowiringMetadata ) = unserialize ( $serialized );
}
2016-03-12 20:10:13 +00:00
}
/**
* @ deprecated Implemented for compatibility with Symfony 2.8
*/
public function getResource ()
{
return $this -> filePath ;
}
}