[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/config/Resource/ -> ComposerResource.php (source)

   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\Config\Resource;
  13  
  14  /**
  15   * ComposerResource tracks the PHP version and Composer dependencies.
  16   *
  17   * @author Nicolas Grekas <p@tchwork.com>
  18   */
  19  class ComposerResource implements SelfCheckingResourceInterface, \Serializable
  20  {
  21      private $vendors;
  22  
  23      private static $runtimeVendors;
  24  
  25      public function __construct()
  26      {
  27          self::refresh();
  28          $this->vendors = self::$runtimeVendors;
  29      }
  30  
  31      public function getVendors()
  32      {
  33          return array_keys($this->vendors);
  34      }
  35  
  36      /**
  37       * {@inheritdoc}
  38       */
  39      public function __toString()
  40      {
  41          return __CLASS__;
  42      }
  43  
  44      /**
  45       * {@inheritdoc}
  46       */
  47      public function isFresh($timestamp)
  48      {
  49          self::refresh();
  50  
  51          return array_values(self::$runtimeVendors) === array_values($this->vendors);
  52      }
  53  
  54      /**
  55       * @internal
  56       */
  57      public function serialize()
  58      {
  59          return serialize($this->vendors);
  60      }
  61  
  62      /**
  63       * @internal
  64       */
  65      public function unserialize($serialized)
  66      {
  67          $this->vendors = unserialize($serialized);
  68      }
  69  
  70      private static function refresh()
  71      {
  72          self::$runtimeVendors = [];
  73  
  74          foreach (get_declared_classes() as $class) {
  75              if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
  76                  $r = new \ReflectionClass($class);
  77                  $v = \dirname(\dirname($r->getFileName()));
  78                  if (file_exists($v.'/composer/installed.json')) {
  79                      self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json');
  80                  }
  81              }
  82          }
  83      }
  84  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1