Rander the view.

@param (string) $file    Name of files
@param (array)  $args    Attributes.
@param (bool)   $minify  Is code should be minify
@param (array)  $headers Custom headers.

@since 1.0.0

@return mixed
542628
public static function view($file, array $args = [], bool $minify = false, array $headers = [], $code = 200)
    {
        $headers['Content-Type'] = 'text/html';
        if ($minify === true) {
            $minify = new Minify();
            self::renderTemplate($file, $args);
            $config = [
                'code'    => $code,
                'body'    => $minify->htmlMinify(ob_get_clean(), 'code'),
                'headers' => [
                    $headers,
                ],
            ];
            $response = new Response($config);
            $response->send();
        } else {
            self::renderTemplate($file, $args);
            $config = [
                'code'    => $code,
                'body'    => ob_get_clean(),
                'headers' => [
                    $headers,
                ],
            ];
            $response = new Response($config);
            $response->send();
        }
    }
277821
public function toFile($file)
	{
		$minified = $this->minify();

		// Create dir
		$dir = dirname($file);

		if (!is_dir($dir))
		{
			if (is_file($dir))
			{
				throw new \RuntimeException(sprintf('Path: %s is already a file.', $dir));
			}

			if (!@mkdir($dir, 0755, true) && !is_dir($dir))
			{
				throw new \RuntimeException(sprintf('Auto create dir: %s fail.', $dir));
			}
		}

		file_put_contents($file, $minified);

		return $this;
	}
662545
public function parseFile($file, array $tokens = [])
    {
        $this->filePath = $file;
        $template = accioPath('resources/scripts/' . str_replace('.', '/', $this->filePath) . '.sh');

        if ($this->filesystem->exists($template)) {
            $this->parseString($this->filesystem->get($template), $tokens);
            return $this;
        }

        throw new RuntimeException('Template ' . $template . ' does not exist');
    }
911705
public static function HasGifHeader( string $file, string $firstBytes = null ) : bool
   {

      if ( empty( $firstBytes ) )
      {
         $firstBytes = File::ReadFirstBytes( $file, 6 );
      }

      return (bool) \preg_match( '~^GIF\d~', $firstBytes );

   }
911602
public function load($view, $args = array())
    {
        $view = ltrim($view, '/');

        $segments = explode('/', str_replace('.', '/', $view));

        // Pop file from segments.
        $view = array_pop($segments);

        // Custom directory path.
        $pathOfView = app('path.base').'/'.implode('/', $segments);

        // Add temporary path with a hint type.
        $this->view->addNamespace('custom', $pathOfView);

        return $this->of('custom::'.$view, $args);
    }
247708
public function mkdir_p( $file, array $atts = array() ) {

		$dir_levels = $this->parse_path( $file );
		$path = '';

		$atts['type'] = 'dir';

		foreach ( $dir_levels as $level ) {

			$path .= '/' . $level;

			if ( $this->exists( $path ) ) {
				continue;
			}

			if ( ! $this->add_file( $path, $atts ) ) {
				return false;
			}
		}

		return true;
	}
900782
protected function upload($args)
    {
        $target = $args['target'];
        $volume = $this->volume($target);
        $files  = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array();
        $result = array('added' => array(), 'header' => empty($args['html']) ? false : 'Content-Type: text/html; charset=utf-8');

        if (empty($files)) {
            return array('error' => $this->error(self::ERROR_UPLOAD, self::ERROR_UPLOAD_NO_FILES), 'header' => $header);
        }

        if (!$volume) {
            return array('error' => $this->error(self::ERROR_UPLOAD, self::ERROR_TRGDIR_NOT_FOUND, '#'.$target), 'header' => $header);
        }

        foreach ($files['name'] as $i => $name) {
            if (($error = $files['error'][$i]) > 0) {
                $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $error == UPLOAD_ERR_INI_SIZE || $error == UPLOAD_ERR_FORM_SIZE ? self::ERROR_UPLOAD_FILE_SIZE : self::ERROR_UPLOAD_TRANSFER);
                $this->uploadDebug = 'Upload error code: '.$error;
                break;
            }

            $tmpname = $files['tmp_name'][$i];

            if (($fp = fopen($tmpname, 'rb')) == false) {
                $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER);
                $this->uploadDebug = 'Upload error: unable open tmp file';
                break;
            }

            if (($file = $volume->upload($fp, $target, $name, $tmpname)) === false) {
                $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error());
                fclose($fp);
                break;
            }

            fclose($fp);
            $result['added'][] = $file;
        }

        return $result;
    }
3310
public static function make (string $file, array $variables=[]) : bool
	{
		$fileLocation = static::fileAnalyzer($file);			
		if (file_exists($fileLocation)):
			ob_start(getConstant('MINIFY_HTML_OUTPUT') ? 'minifyHTMLOutput' : NULL);
			if (!empty($variables)) self::with($variables);
	        extract($GLOBALS, EXTR_OVERWRITE);
			extract(static::$passedVariables, EXTR_OVERWRITE);
			require getConstant("BOOTSTRAP", TRUE)."Initializers.php";
			require_once $fileLocation;
			ob_end_flush();
			// print ob_get_clean();
			return TRUE;
		endif;
		print "'$fileLocation': File was not found."; 
		return FALSE;
	}
765574
public function minifyCommand()
    {
        $ManaPHPSrcDir = $this->alias->get('@manaphp');
        $ManaPHPDstDir = $ManaPHPSrcDir . '_' . date('ymd');
        $totalClassLines = 0;
        $totalInterfaceLines = 0;
        $totalLines = 0;
        $fileLines = [];
        $sourceFiles = $this->_getSourceFiles($ManaPHPSrcDir);
        foreach ($sourceFiles as $file) {
            $dstFile = str_replace($ManaPHPSrcDir, $ManaPHPDstDir, $file);

            $content = $this->_minify($this->filesystem->fileGet($file));
            $lineCount = substr_count($content, strpos($content, "\r") !== false ? "\r" : "\n");

            if (strpos($file, 'Interface.php')) {
                $totalInterfaceLines += $lineCount;
                $totalLines += $lineCount;
            } else {
                $totalClassLines += $lineCount;
                $totalLines += $lineCount;
            }

            $this->console->writeLn($content);
            $this->filesystem->filePut($dstFile, $content);
            $fileLines[$file] = $lineCount;
        }

        asort($fileLines);

        $i = 1;
        $this->console->writeLn('------------------------------------------------------');

        foreach ($fileLines as $file => $line) {
            $this->console->writeLn(sprintf('%3d %3d %.3f', $i++, $line, $line / $totalLines * 100) . ' ' . substr($file, strpos($file, 'ManaPHP')));
        }

        $this->console->writeLn('------------------------------------------------------');
        $this->console->writeLn('total     lines: ' . $totalLines);
        $this->console->writeLn('class     lines: ' . $totalClassLines);
        $this->console->writeLn('interface lines:  ' . $totalInterfaceLines);

        return 0;
    }
869372
public function loadAndCache($file, $cachekey, $args=NULL) {
		if (isset($this->objectCache[$cachekey])) {
			return $this->objectCache[$cachekey];
		}

		$_x = $this->load($file, $args);
		if ($_x !== FALSE) {
			$this->objectCache[$cachekey] = $_x;
		}
		return $_x;
	}
687665
protected function resize($args) {
		$target = $args['target'];
		$width  = $args['width'];
		$height = $args['height'];
		$x      = (int)$args['x'];
		$y      = (int)$args['y'];
		$mode   = $args['mode'];
		$bg     = null;
		$degree = (int)$args['degree'];
		
		if (($volume = $this->volume($target)) == false
		|| ($file = $volume->file($target)) == false) {
			return array('error' => $this->error(self::ERROR_RESIZE, '#'.$target, self::ERROR_FILE_NOT_FOUND));
		}

		return ($file = $volume->resize($target, $width, $height, $x, $y, $mode, $bg, $degree))
			? array('changed' => array($file))
			: array('error' => $this->error(self::ERROR_RESIZE, $volume->path($target), $volume->error()));
	}
480325
public function minify($src)
	{
		$body     = $this->generateRequestBody($src);
		$response = $this->query($body);
		if ($response === false)
		{
			throw new RuntimeException('Could not contact the Closure Compiler service');
		}

		return $this->decodeResponse($response);
	}
291754
static function generateCallback( $file, $args )
    {
        extract( $args );

        $res = eZNodeViewFunctions::generateNodeViewData( $tpl, $node, $object, $languageCode, $viewMode, $offset,
                                                          $viewParameters, $collectionAttributes, $validation );


        // Check if cache time = 0 (viewcache disabled)
        $store = $res['cache_ttl'] != 0;
        // or if explicitly turned off
        if ( !$viewCacheEnabled )
            $store = false;
        $retval = array( 'content' => $res,
                         'scope'   => 'viewcache',
                         'store'   => $store );
        if ( $store )
            $retval['binarydata'] = serialize( $res );

        return $retval;
    }
903227
protected function loadFile(string $file, array $options): ?Config
    {
        if (is_dir($file)) {
            return (bool)($options['recursive'] ?? false) ? $this->load($file, $options) : null;
        }

        return $this->getFileLoader()->load($file, $options);
    }
127787
public function javascriptMinify($file, $type = 'file')
    {
        $file = $this->getFile($file, $type);
        $file = preg_replace(["/\/\/(.*\s+)/", "/;+\}/"], ['', '}'], $file);
        $file = $this->cleanSpaces($file);
        $file = $this->removeComments($file);

        return $file;
    }
988341
public static function response(
        $file,
        $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT,
        $fileName = null
    ) {
        if (!class_exists('Symfony\\Component\\HttpFoundation\\Response')) {
            throw new MimeTypeException('HttpFoundation component not found, install it.');
        }

        if (
        !in_array(
            $disposition,
            [ResponseHeaderBag::DISPOSITION_INLINE, ResponseHeaderBag::DISPOSITION_ATTACHMENT],
            true
        )
        ) {
            $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT;
        }

        $info = static::info($file);
        $spl = $info->getSplFileObject();

        $response = new Response($spl->fread($spl->getSize()));

        $response->headers->set('Content-Type', $info->getMimeType());
        $disposition = $response->headers->makeDisposition(
            $disposition,
            null === $fileName ? $spl->getFileName() : $fileName
        );
        $response->headers->set('Content-Disposition', $disposition);

        return $response;
    }
279126
private static function checkArgs(array $args) {
        if ($_FILES) {
            foreach ($_FILES as $key => $f) {
                if (is_array($f['name'])) {
                    foreach ($f['tmp_name'] as $tmp) {
                        $args[ $key ][] = self::getfileSha1('@"' . $tmp . '"');
                    }
                } else {
                    $args[ $key ] = self::getfileSha1('@"' . $f['tmp_name'] . '"');
                }
            }
        }

        return $args;
    }