Nette\DI\ContainerLoader::loadFile PHP 메소드

loadFile() 개인적인 메소드

private loadFile ( $class, $generator ) : void
리턴 void
    private function loadFile($class, $generator)
    {
        $file = "{$this->tempDirectory}/{$class}.php";
        if (!$this->isExpired($file) && @(include $file) !== FALSE) {
            // @ file may not exist
            return;
        }
        if (!is_dir($this->tempDirectory)) {
            @mkdir($this->tempDirectory);
            // @ - directory may already exist
        }
        $handle = fopen("{$file}.lock", 'c+');
        if (!$handle || !flock($handle, LOCK_EX)) {
            throw new Nette\IOException("Unable to acquire exclusive lock on '{$file}.lock'.");
        }
        if (!is_file($file) || $this->isExpired($file)) {
            list($toWrite[$file], $toWrite["{$file}.meta"]) = $this->generate($class, $generator);
            foreach ($toWrite as $name => $content) {
                if (file_put_contents("{$name}.tmp", $content) !== strlen($content) || !rename("{$name}.tmp", $name)) {
                    @unlink("{$name}.tmp");
                    // @ - file may not exist
                    throw new Nette\IOException("Unable to create file '{$name}'.");
                } elseif (function_exists('opcache_invalidate')) {
                    @opcache_invalidate($name, TRUE);
                    // @ can be restricted
                }
            }
        }
        if (@(include $file) === FALSE) {
            // @ - error escalated to exception
            throw new Nette\IOException("Unable to include '{$file}'.");
        }
        flock($handle, LOCK_UN);
    }