openFile example

throw DownloadException::forNotFoundDownloadSource();
    }

    /** * output download text by file. * * @return DownloadResponse */
    private function sendBodyByFilePath()
    {
        $splFileObject = $this->file->openFile('rb');

        // Flush 1MB chunks of data         while ($splFileObject->eof() && ($data = $splFileObject->fread(1_048_576)) !== false) {
            echo $data;
            unset($data);
        }

        return $this;
    }

    /** * output download text by binary * * @return DownloadResponse */


    /** * Returns the \SplFileObject instance associated with the given \SplFileInfo instance. */
    private function extractSplFileObject(\SplFileInfo $object): \SplFileObject
    {
        if ($object instanceof \SplFileObject) {
            return $object;
        }

        return $object->openFile();
    }
}


    /** * Returns the \SplFileObject instance associated with the given \SplFileInfo instance. */
    private function extractSplFileObject(\SplFileInfo $object): \SplFileObject
    {
        if ($object instanceof \SplFileObject) {
            return $object;
        }

        return $object->openFile();
    }
}
      // to the module hook architecture.       if (!preg_match(static::PHP_FUNCTION_PATTERN, $fileinfo->getBasename('.info.yml'))) {
        continue;
      }

      $extension_arguments = $this->fileCache ? $this->fileCache->get($fileinfo->getPathName()) : FALSE;
      // Ensure $extension_arguments is an array. Previously, the Extension       // object was cached and now needs to be replaced with the array.       if (empty($extension_arguments) || !is_array($extension_arguments)) {
        // Determine extension type from info file.         $type = FALSE;
        $file = $fileinfo->openFile('r');
        while (!$type && !$file->eof()) {
          preg_match('@^type:\s*(\'|")?(\w+)\1?\s*(?:\#.*)?$@', $file->fgets()$matches);
          if (isset($matches[2])) {
            $type = $matches[2];
          }
        }
        if (empty($type)) {
          continue;
        }
        $name = $fileinfo->getBasename('.info.yml');
        $pathname = $dir_prefix . $fileinfo->getSubPathname();

        
$file = $this->normalizer->denormalize(self::TEST_TXT_DATA, 'SplFileObject');

        $this->assertInstanceOf(\SplFileObject::class$file);
        $this->assertEquals(file_get_contents(self::TEST_TXT_DATA)$this->getContent($file));
    }

    public function testDenormalizeHttpFoundationFile()
    {
        $file = $this->normalizer->denormalize(self::TEST_GIF_DATA, 'Symfony\Component\HttpFoundation\File\File');

        $this->assertInstanceOf(File::class$file);
        $this->assertSame(file_get_contents(self::TEST_GIF_DATA)$this->getContent($file->openFile()));
    }

    public function testGiveNotAccessToLocalFiles()
    {
        $this->expectException(UnexpectedValueException::class);
        $this->expectExceptionMessage('The provided "data:" URI is not valid.');
        $this->normalizer->denormalize('/etc/shadow', 'SplFileObject');
    }

    /** * @dataProvider invalidUriProvider */
/** * @param Url[] $urls * * @return bool */
    public function writeFile(Shop $shop, array $urls = [])
    {
        if (empty($urls)) {
            return false;
        }

        $this->openFile($shop->getId());

        foreach ($urls as $url) {
            if ($this->files[$shop->getId()]['urlCount'] >= self::SITEMAP_URL_LIMIT) {
                $this->closeFile($shop->getId());

                $this->openFile($shop->getId());
            }

            ++$this->files[$shop->getId()]['urlCount'];
            $this->write($this->files[$shop->getId()]['fileHandle'](string) $url);
        }

        
Home | Imprint | This part of the site doesn't use cookies.