Grav\Plugin\Admin\Admin::getTempDir PHP Méthode

getTempDir() public static méthode

public static getTempDir ( )
    public static function getTempDir()
    {
        try {
            $tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
        } catch (\Exception $e) {
            $tmp_dir = Grav::instance()['locator']->findResource('cache://', true, true) . '/tmp';
        }
        return $tmp_dir;
    }

Usage Example

Exemple #1
0
 /**
  * @return bool
  */
 public static function selfupgrade()
 {
     $upgrader = new Upgrader();
     if (!Installer::isGravInstance(GRAV_ROOT)) {
         return false;
     }
     if (is_link(GRAV_ROOT . DS . 'index.php')) {
         Installer::setError(Installer::IS_LINK);
         return false;
     }
     if (method_exists($upgrader, 'meetsRequirements') && !$upgrader->meetsRequirements()) {
         $error = [];
         $error[] = '<p>Grav has increased the minimum PHP requirement.<br />';
         $error[] = 'You are currently running PHP <strong>' . PHP_VERSION . '</strong>';
         $error[] = ', but PHP <strong>' . GRAV_PHP_MIN . '</strong> is required.</p>';
         $error[] = '<p><a href="http://getgrav.org/blog/changing-php-requirements-to-5.5" class="button button-small secondary">Additional information</a></p>';
         Installer::setError(implode("\n", $error));
         return false;
     }
     $update = $upgrader->getAssets()['grav-update'];
     $tmp = Admin::getTempDir() . '/Grav-' . uniqid();
     $file = self::_downloadSelfupgrade($update, $tmp);
     Installer::install($file, GRAV_ROOT, ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]);
     $errorCode = Installer::lastErrorCode();
     Folder::delete($tmp);
     if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) {
         return false;
     }
     return true;
 }
All Usage Examples Of Grav\Plugin\Admin\Admin::getTempDir