getFullPath example

    chmod($temporary_path, 0444);

    // Determine the exact modification time of the file.     $mtime = $this->getUncachedMTime($temporary_path);

    // Move the temporary file into the proper directory. Note that POSIX     // compliant systems as well as modern Windows perform the rename operation     // atomically, i.e. there is no point at which another process attempting to     // access the new path will find it missing.     $directory = $this->getContainingDirectoryFullPath($name);
    $this->ensureDirectory($directory);
    $full_path = $this->getFullPath($name$directory$mtime);
    $result = rename($temporary_path$full_path);

    // Finally reset the modification time of the directory to match the one of     // the newly created file. In order to prevent the creation of a file if the     // directory does not exist, ensure that the path terminates with a     // directory separator.     //     // Recall that when subsequently loading the file, the hash is calculated     // based on the file name, the containing mtime, and a the secret string.     // Hence updating the mtime here is comparable to pointing a symbolic link     // at a new target, i.e., the newly created file.

  public function __construct(array $configuration) {
    $this->directory = $configuration['directory'] . '/' . $configuration['bin'];
  }

  /** * {@inheritdoc} */
  public function exists($name) {
    return file_exists($this->getFullPath($name));
  }

  /** * {@inheritdoc} */
  public function load($name) {
    // The FALSE returned on failure is enough for the caller to handle this,     // we do not want a warning too.     return (@include_once $this->getFullPath($name)) !== FALSE;
  }

  
/** * @return \Closure that will return the root config class */
    public function build(ConfigurationInterface $configuration): \Closure
    {
        $this->classes = [];

        $rootNode = $configuration->getConfigTreeBuilder()->buildTree();
        $rootClass = new ClassBuilder('Symfony\\Config', $rootNode->getName());

        $path = $this->getFullPath($rootClass);
        if (!is_file($path)) {
            // Generate the class if the file not exists             $this->classes[] = $rootClass;
            $this->buildNode($rootNode$rootClass$this->getSubNamespace($rootClass));
            $rootClass->addImplements(ConfigBuilderInterface::class);
            $rootClass->addMethod('getExtensionAlias', ' public function NAME(): string { return \'ALIAS\'; }', ['ALIAS' => $rootNode->getPath()]);

            

  public function __construct(array $configuration) {

    $this->directory = $configuration['directory'] . '/' . $configuration['bin'];
  }

  /** * {@inheritdoc} */
  public function exists($name) {
    return file_exists($this->getFullPath($name));
  }

  /** * {@inheritdoc} */
  public function load($name) {
    // The FALSE returned on failure is enough for the caller to handle this,     // we do not want a warning too.     return (@include_once $this->getFullPath($name)) !== FALSE;
  }

  

  protected function getByHash($cidhash$allow_invalid = FALSE) {
    if ($file = $this->storage()->getFullPath($cidhash)) {
      $cache = @include $file;
    }
    if (isset($cache)) {
      return $this->prepareItem($cache$allow_invalid);
    }
    return FALSE;
  }

  /** * {@inheritdoc} */
  
/** * Determines whether a protected file exists and sets the filename too. * * @param string $name * The virtual file name. Can be a relative path. * * @return string|false * The full path where the file is if it is valid, FALSE otherwise. */
  protected function checkFile($name) {
    $filename = $this->getFullPath($name$directory$directory_mtime);
    return file_exists($filename) && filemtime($filename) <= $directory_mtime ? $filename : FALSE;
  }

  /** * {@inheritdoc} */
  public function getPath($name) {
    return $this->checkFile($name);
  }

}
Home | Imprint | This part of the site doesn't use cookies.