Pimcore\File::mkdir PHP Method

mkdir() public static method

public static mkdir ( $path, null $mode = null, boolean $recursive = true ) : boolean
$path
$mode null
$recursive boolean
return boolean
    public static function mkdir($path, $mode = null, $recursive = true)
    {
        if (!$mode) {
            $mode = self::$defaultMode;
        }
        $return = @mkdir($path, $mode, $recursive, self::getContext());
        return $return;
    }

Usage Example

Example #1
0
 /**
  * @param null $options
  * @return bool|void
  * @throws \Exception
  * @throws \Zend_Http_Client_Exception
  */
 public function send($options = null)
 {
     $sourceFile = $this->getSourceFile();
     $destinationFile = $this->getDestinationFile();
     if (!$sourceFile) {
         throw new \Exception("No sourceFile provided.");
     }
     if (!$destinationFile) {
         throw new \Exception("No destinationFile provided.");
     }
     if (is_array($options)) {
         if ($options['overwrite'] == false && file_exists($destinationFile)) {
             throw new \Exception("Destination file : '" . $destinationFile . "' already exists.");
         }
     }
     if (!$this->getHttpClient()) {
         $httpClient = \Pimcore\Tool::getHttpClient(null, ['timeout' => 3600 * 60]);
     } else {
         $httpClient = $this->getHttpClient();
     }
     $httpClient->setUri($this->getSourceFile());
     $response = $httpClient->request();
     if ($response->isSuccessful()) {
         $data = $response->getBody();
         File::mkdir(dirname($destinationFile));
         $result = File::put($destinationFile, $data);
         if ($result === false) {
             throw new \Exception("Couldn't write destination file:" . $destinationFile);
         }
     } else {
         throw new \Exception("Couldn't download file:" . $sourceFile);
     }
     return true;
 }
All Usage Examples Of Pimcore\File::mkdir