Example #1
0
 /**
  * @param bool $append
  */
 protected function prepareWrite($append)
 {
     if (!is_resource($this->file->getFilePointer())) {
         $mode = $append ? FileManipulatorInterface::BOTTOM_TO_TOP_READ_ONLY : FileManipulatorInterface::TOP_TO_BOTTOM_READ_ONLY_OR_CREATE;
         $this->file->open($mode);
     }
 }
 /**
  * @param FileInterface $file
  * @param mixed         $content
  *
  * @return $this
  */
 public function writeContent(FileInterface $file, $content)
 {
     $this->setCallback(function () use($file, $content) {
         foreach ($content as $row) {
             $file->getWriter()->write($row);
         }
     });
     return $this;
 }
 /**
  * @param FileInterface $file
  * @param mixed         $data
  * @param bool          $unaccent
  *
  * @throws \RuntimeException
  *
  * @return StreamedFileResponse
  */
 protected function createResponse(FileInterface $file, $data, $unAccent = true)
 {
     if (null === $file->getFilename()) {
         throw new \RuntimeException('Filename must be set');
     }
     $response = new StreamedFileResponse(Urlizer::urlize($file->getFilename()) . $this->getFileExtension());
     if (true === $unAccent) {
         foreach ($data as $rowIndex => $row) {
             foreach ($row as $dataIndex => $dataValue) {
                 $data[$rowIndex][$dataIndex] = Urlizer::unaccent($dataValue);
             }
         }
     }
     return $response->writeContent($file, $data);
 }
Example #4
0
 /**
  * @return int
  */
 public function count()
 {
     return count(file($this->file->getPath()));
 }