ensureDirectory example

// 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;
  }

  /** * {@inheritdoc} */
  public function save($name$code) {
    $path = $this->getFullPath($name);
    $directory = dirname($path);
    $this->ensureDirectory($directory);
    return (bool) file_put_contents($path$code);
  }

  /** * Ensures the directory exists, has the right permissions, and a .htaccess. * * For compatibility with open_basedir, the requested directory is created * using a recursion logic that is based on the relative directory path/tree: * It works from the end of the path recursively back towards the root * directory, until an existing parent directory is found. From there, the * subdirectories are created. * * @param string $directory * The directory path. * @param int $mode * The mode, permissions, the directory should have. */
/** * {@inheritdoc} */
  protected function execute(InputInterface $input, OutputInterface $output): int {
    // Determines and validates the setup class prior to installing a database     // to avoid creating unnecessary sites.     $root = dirname(__DIR__, 5);
    chdir($root);
    $class_name = $this->getSetupClass($input->getOption('setup-file'));
    // Ensure we can install a site in the sites/simpletest directory.     $this->ensureDirectory($root);

    $db_url = $input->getOption('db-url');
    $base_url = $input->getOption('base-url');
    putenv("SIMPLETEST_DB=$db_url");
    putenv("SIMPLETEST_BASE_URL=$base_url");

    // Manage site fixture.     $this->setup($input->getOption('install-profile')$class_name$input->getOption('langcode'));

    // Make sure there is an entry in sites.php for the new site.     $fs = new Filesystem();
    

  public function __construct(array $configuration) {
    parent::__construct($configuration);
    $this->secret = $configuration['secret'];
  }

  /** * {@inheritdoc} */
  public function save($name$data) {
    $this->ensureDirectory($this->directory);

    // Write the file out to a temporary location. Prepend with a '.' to keep it     // hidden from listings and web servers.     $temporary_path = $this->tempnam($this->directory, '.');
    if (!$temporary_path || !@file_put_contents($temporary_path$data)) {
      return FALSE;
    }
    // The file will not be chmod() in the future so this is the final     // permission.     chmod($temporary_path, 0444);

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