Require a file.

@param   string  $file
@param   bool    $return
@return  void
@throws  Exception
501901
public function requireFile($file, $return = false)
    {
        if($this->findFile($file)) {
            if($return !== false) {
                return require($file);
            }
            else {
                require($file);
            }
        }
        else {
            throw new Exception($file." file is missing.");
            exit;
        }
    }
1064260
public function runMigration($file)
    {
        $migration = $this->getMigrationObjectByFileName($file);

        $this->disableBitrixIblockHelperCache();

        $this->checkTransactionAndRun($migration, function () use ($migration, $file) {
            if ($migration->up() === false) {
                throw new Exception("Migration up from {$file}.php returned false");
            }
        });

        $this->logSuccessfulMigration($file);
    }
573419
public function executeRedirection($return = false)
    {
        $html = $this->createForm();
        $html .= '<script>document.forms["'.$this->_setNameForm.'"].submit();</script>';

        if (!$return) {
            echo $html;

            return null;
        }

        return $html;
    }
557246
public function loadConfig($file, $env = self::ENV_COMMON)
    {
        $this->loadConfigFile($file, $env, false);
    }
29410
public function setRequired($required)
    {
        if (is_string($required)) {
            $this->_required = new PhingFile($required);
        } else {
            $this->_required = $required;
        }
    }
1369899
public function validateFile($file)
    {
        if (file_exists($file) !== true) {
            throw new Exception('File not found');
        }
        if (is_readable($file) !== true) {
            throw new Exception('File not readable');
        }

        $data = file_get_contents($file);
        if ($data === false) {
            throw new Exception('Failed get file');
        }

        return $this->validateFragment($data);
    }
578599
private function loadFromFile($path)
    {
        if ( ! is_file($path)) {
            return;
        }
        
        $config = require_once $path;
        
        if (is_array($config)) {
            $this->config = $config;
        }
    }
380595
public function fromFile(string $filename = '', bool $returnArray = false)
    {
        if (empty($filename)) {
            throw new InvalidArgumentException('File name must be specified');
        }

        \set_error_handler(
            function ($error, $message = '') use ($filename) {
                $exMsg = \sprintf('Error reading from "%s": %s', $filename, $message);
                throw new RuntimeException($exMsg, $error);
            },
            E_WARNING
        );

        try {
            $config = $this->transform(\file_get_contents($filename));
            \restore_error_handler();
            return $returnArray ? $config : new Config($config);
        } catch (RuntimeException $e) {
            \restore_error_handler();
            throw $e;
        }
    }
418179
public function load($file) {
		$this->file = $file;

		$msg = array();
		@include($file);

		$this->msg = $msg;
	}
502219
protected function loadFile($file, $data, $once = false)
    {
        $file = $this->basePath.'/'.ltrim($file, '/\\');

        if(!file_exists($file))
            throw new \Exedra\Exception\NotFoundException("File [$file] not found");

        extract($data);

        if($once)
            return require_once $file;
        else
            return require $file;

    }
38580
public function init($file)
	{
		try {
			
			$this->load($file);

		} catch (Exceptions\FileNotExists $e) {

			$this->create($file);
		}
	}
569464
public function loadHtmlFile($file)
    {
        $this->saveLocale();

        if (!$this->protocol && !$this->baseHost && !$this->basePath) {
            list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($file);
        }
        $protocol = strtolower($this->protocol);

        if ( !in_array($protocol, $this->allowedProtocols) ) {
            throw new Exception("Permission denied on $file. The communication protocol is not supported.");
        }

        if (!$this->options->isRemoteEnabled() && ($protocol != "" && $protocol !== "file://")) {
            throw new Exception("Remote file requested, but remote file download is disabled.");
        }

        if ($protocol == "" || $protocol === "file://") {
            $realfile = realpath($file);

            $chroot = realpath($this->options->getChroot());
            if ($chroot && strpos($realfile, $chroot) !== 0) {
                throw new Exception("Permission denied on $file. The file could not be found under the directory specified by Options::chroot.");
            }

            $ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
            if (!in_array($ext, $this->allowedLocalFileExtensions)) {
                throw new Exception("Permission denied on $file. This file extension is forbidden");
            }

            if (!$realfile) {
                throw new Exception("File '$file' not found.");
            }

            $file = $realfile;
        }

        list($contents, $http_response_header) = Helpers::getFileContent($file, $this->httpContext);
        $encoding = 'UTF-8';

        // See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
        if (isset($http_response_header)) {
            foreach ($http_response_header as $_header) {
                if (preg_match("@Content-Type:\s*[\w/]+;\s*?charset=([^\s]+)@i", $_header, $matches)) {
                    $encoding = strtoupper($matches[1]);
                    break;
                }
            }
        }

        $this->restoreLocale();

        $this->loadHtml($contents, $encoding);
    }
981826
protected function _addDependency(string $file): void
    {
        $file = str_replace('\\', '/', $file);
        if (!in_array($file, $this->_dependencies)) {
            $this->_dependencies[] = $file;
        }
    }
332233
public static function loadFile($file, $format = null)
    {
        if (!isset($format)) {
            $ext = pathinfo($file, PATHINFO_EXTENSION);
            $format = ArrayHelper::fetch(self::$FORMATS, $ext);
            if (!isset($format)) {
                throw new \InvalidArgumentException("Cannot infer format from file '{$file}'");
            }
        }
        if ($format == 'json') {
            return json_decode(file_get_contents($file), true);
        } elseif ($format == 'yaml') {
            return Yaml::parse(file_get_contents($file));
        } elseif ($format == 'php') {
            return require($file);
        } else {
            throw new \InvalidArgumentException("Invalid format '{$format}'");
        }
    }
802697
private function load($file, $dir = '')
    {
        $path = config_path().'/'.$dir;
        $handle = opendir($path);
        $ignore = ['.', '..'];
        while ($f = readdir($handle)) {
            if (!in_array($f, $ignore)) {
                if (is_dir($path.$f)) {
                    if (file_exists($path.$f.'/'.$file.'.php')) {
                        return $this->load($file, $f);
                    }
                } else {
                    $filename = explode('.', $f)[0];
                    if ($filename == $file) {
                        return require $path.'/'.$f;
                    }
                }
            }
        }
        closedir($handle);

        return false;
    }
118848
public static function Load($directory, $file)
    {
        self::CheckBackend();

        self::$backend->Load($directory, $file);
    }
1324259
def require( file )
      return if key?( file )

      self[ file ] = deps( file )
      self[ file ].each do |dependency|
        self.require dependency
      end
    end