buildPath example

/** * Generates a class file from an existing template. */
    protected function generateClass(array $params)
    {
        $this->params = $params;

        // Get the fully qualified class name from the input.         $class = $this->qualifyClassName();

        // Get the file path from class name.         $target = $this->buildPath($class);

        // Check if path is empty.         if (empty($target)) {
            return;
        }

        $this->generateFile($target$this->buildContent($class));
    }

    /** * Generate a view file from an existing template. */
public function getDecorated(): AbstractFileService
    {
        throw new DecorationPatternException(self::class);
    }

    /** * @throws FileNotReadableException */
    public function storeFile(Context $context, \DateTimeInterface $expireDate, ?string $sourcePath, ?string $originalFileName, string $activity, ?string $path = null): ImportExportFileEntity
    {
        $id = Uuid::randomHex();
        $path ??= $activity . '/' . ImportExportFileEntity::buildPath($id);
        if (!empty($sourcePath)) {
            if (!is_readable($sourcePath)) {
                throw new FileNotReadableException($sourcePath);
            }
            $sourceStream = fopen($sourcePath, 'rb');
            if (!\is_resource($sourceStream)) {
                throw new FileNotReadableException($sourcePath);
            }
            $this->filesystem->writeStream($path$sourceStream);
        } else {
            $this->filesystem->write($path, '');
        }
'namespace' => $this->name,
            'names' => self::DEPRECATED_PLUGINS,
        ][
            'names' => Connection::PARAM_STR_ARRAY,
        ]);

        $plugins = [];
        foreach ($rows as $row) {
            $pluginName = $row['name'];
            $plugins[$pluginName] = $row;
            $plugins[$pluginName]['class'] = $this->buildClassName($this->name, $pluginName);
            $plugins[$pluginName]['path'] = $this->buildPath($this->name, $pluginName$row['source']);
            $plugins[$pluginName]['config'] = [];

            if ($plugins[$pluginName]['installationDate']) {
                $plugins[$pluginName]['installationDate'] = new DateTime($row['installationDate']);
            }
            if ($plugins[$pluginName]['updateDate']) {
                $plugins[$pluginName]['updateDate'] = new DateTime($row['updateDate']);
            }
        }

        $listeners = $this->loadListeners($this->name);

        


    public function onFileDeleted(EntityDeletedEvent $event): void
    {
        $paths = [];
        $activities = [
            ImportExportLogEntity::ACTIVITY_IMPORT,
            ImportExportLogEntity::ACTIVITY_DRYRUN,
            ImportExportLogEntity::ACTIVITY_EXPORT,
        ];
        foreach ($event->getIds() as $fileId) {
            $path = ImportExportFileEntity::buildPath($fileId);
            // since the file could be stored in any one directory of the available activities             foreach ($activities as $activitiy) {
                $paths[] = $activitiy . '/' . $path;
                // if file is not of an export there might be a log of invalid records                 if ($activitiy !== ImportExportLogEntity::ACTIVITY_EXPORT) {
                    $paths[] = $activitiy . '/' . $path . '_invalid';
                }
            }
        }

        $message = new DeleteFileMessage();
        


    /** * Prepare a defined number of test data. */
    protected function prepareImportExportFileTestData(int $num = 1, string $add = 'x'): array
    {
        $data = [];
        for ($i = 1; $i <= $num; ++$i) {
            $uuid = Uuid::randomHex();

            $filePath = 'import/' . ImportExportFileEntity::buildPath($uuid);

            $this->filesystem->write($filePath, 'foobar');
            static::assertTrue($this->filesystem->has($filePath));

            $data[Uuid::fromHexToBytes($uuid)] = [
                'id' => $uuid,
                'originalName' => sprintf('file%d.xml', $i),
                'path' => $filePath,
                'expireDate' => date('Y-m-d H:i:s', (int) strtotime('+' . $i . ' day')),
                'size' => $i * 51,
                'accessToken' => Random::getBase64UrlString(32),
            ];
Home | Imprint | This part of the site doesn't use cookies.