getOriginalName example


    private function exportInvalid(Context $context, array $failedRecords): Progress
    {
        $file = $this->logEntity->getFile();

        // created a invalid records export if it doesn't exist         if (!$this->logEntity->getInvalidRecordsLogId() && $file instanceof ImportExportFileEntity) {
            $pathInfo = pathinfo($file->getOriginalName());
            $newName = $pathInfo['filename'] . '_failed.' . ($pathInfo['extension'] ?? '');

            $newPath = $file->getPath() . '_invalid';

            $config = $this->logEntity->getConfig();
            $config['mapping'][] = [
                'key' => '_error',
                'mappedKey' => '_error',
            ];
            $config = new Config($config['mapping']$config['parameters'] ?? []$config['updateBy'] ?? []);

            

        $num = 3;
        $data = $this->prepareImportExportFileTestData($num);

        $this->repository->create(array_values($data)$this->context);

        foreach ($data as $expect) {
            $id = $expect['id'];
            $result = $this->repository->search(new Criteria([$id])$this->context);
            $importExportFile = $result->get($id);
            static::assertEquals(1, $result->count());
            static::assertEquals($expect['originalName']$importExportFile->getOriginalName());
            static::assertEquals($expect['path']$importExportFile->getPath());
            static::assertEquals(new \DateTime($expect['expireDate'])$importExportFile->getExpireDate());
            static::assertEquals($expect['size']$importExportFile->getSize());
            static::assertEquals($expect['accessToken']$importExportFile->getAccessToken());
        }
    }

    public function testImportExportFileReadNoResult(): void
    {
        $num = 3;
        $data = $this->prepareImportExportFileTestData($num);

        
$fileRepository
        );

        $storedFile = $fileService->storeFile(
            Context::createDefaultContext(),
            new \DateTimeImmutable(),
            null,
            'testfile.csv',
            ImportExportLogEntity::ACTIVITY_IMPORT
        );

        static::assertSame('testfile.csv', $storedFile->getOriginalName());

        $dbFile = $fileRepository->search(new Criteria([$storedFile->getId()]), Context::createDefaultContext())->first();
        static::assertNotNull($dbFile);
        static::assertSame('testfile.csv', $dbFile->getOriginalName());
    }

    public static function fileTypesProvider(): iterable
    {
        yield 'CSV file with correct type' => [
            [
                'file' => 'testfile.csv',
                
 else {
                    $code = $p->areScalarsAllowed()
                        ? '$this->PROPERTY instanceof CLASS ? $this->PROPERTY->toArray() : $this->PROPERTY'
                        : '$this->PROPERTY->toArray()'
                    ;
                }
            }

            $body .= strtr(' if (isset($this->_usedProperties[\'PROPERTY\'])) { $output[\'ORG_NAME\'] = '.$code.'; }', ['PROPERTY' => $p->getName(), 'ORG_NAME' => $p->getOriginalName(), 'CLASS' => $p->getType()]);
        }

        $extraKeys = $class->shouldAllowExtraKeys() ? ' + $this->_extraKeys' : '';

        $class->addMethod('toArray', ' public function NAME(): array { '.$body.' return $output'.$extraKeys.'; }');
    }
$fileAccessToken = (string) $entity->getAccessToken();

        if ($fileAccessToken === '' || $entity->getAccessToken() !== $accessToken || !$this->isModifiedRecently($entity)) {
            throw ImportExportException::invalidFileAccessToken();
        }

        $this->fileRepository->update(
            [['id' => $fileId, 'accessToken' => null]],
            $context
        );

        $originalName = (string) preg_replace('/[\/\\\]/', '', $entity->getOriginalName());

        $headers = [
            'Content-Disposition' => HeaderUtils::makeDisposition(
                'attachment',
                $originalName,
                // only printable ascii                 (string) preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $originalName)
            ),
            'Content-Length' => $this->filesystem->fileSize($entity->getPath()),
            'Content-Type' => 'application/octet-stream',
        ];
        
Home | Imprint | This part of the site doesn't use cookies.