Skip to content

PathsInterface

Alexander Saal edited this page Aug 4, 2025 · 1 revision

PathsInterface

Interface & Methods

interface PathsInterface
{
    /**
     * Return the JobRouter data path.
     *
     * @param string|null $relativePath Optional relative path inside the data path
     * @param string|null $processName Optional process name
     * @param int|null $processVersion Optional process version
     *
     * @return string the data path with the optional relative path, optional process name and there optional process version.
     *
     * @throws \IllegalFilesystemAccessException
     */
    public function getDataPath(?string $relativePath = '', ?string $processName = '', ?int $processVersion = null): string;

    /**
     * Return the JobRouter functions path.
     *
     * @param string|null $relativePath Optional relative path inside the functions path
     * @param string|null $processName Optional process name
     * @param int|null $processVersion Optional process version
     *
     * @return string the data path with the optional relative path, optional process name and there optional process version.
     *
     * @throws \IllegalFilesystemAccessException
     */
    public function getFunctionsPath(?string $relativePath = '', ?string $processName = '', ?int $processVersion = null): string;

    /**
     * Return the JobRouter URL with corresponding slash (/) at the end.
     *
     * @return string the JobRouter URL
     *
     * @throws \JobRouterException
     */
    public function getJobRouterUrl(): string;

    /**
     * Return the JobRouter output path.
     *
     * @param string $relativePath Optional relative path inside the output path
     *
     * @throws \IllegalFilesystemAccessException
     */
    public function getOutputPath(string $relativePath = ''): string;

    /**
     * Return the JobRouter temp path.
     *
     * @param string $relativePath Optional relative path inside the temp path
     *
     * @throws \IllegalFilesystemAccessException
     */
    public function getTempPath(string $relativePath = ''): string;

    /**
     * Return the JobRouter upload path.
     *
     * @param string $relativePath Optional relative path inside the upload path
     * @param bool|null $skipAssert Optional to skip assertion
     *
     * @throws \IllegalFilesystemAccessException
     */
    public function getUploadPath(string $relativePath = '', ?bool $skipAssert = false): string;
}

Example

<?php

use JobRouter\Sdk\PathsInterface;

return function (PathsInterface $pathsInterface): void {
    echo '<h1 style="color: #fc0">JobRouter SDK paths interface example!</h1>';

    try {
        echo '<pre>JobRouter URL: ' . print_r($pathsInterface->getJobRouterUrl(), true) . '</pre>';
        echo '<pre>Data path: ' . print_r($pathsInterface->getDataPath('extra/data/path', 'Example_Proccess', '1'), true) . '</pre>';
        echo '<pre>Functions path: ' . print_r($pathsInterface->getFunctionsPath(), true) . '</pre>';
        echo '<pre>Temp path: ' . print_r($pathsInterface->getTempPath(), true) . '</pre>';
        echo '<pre>Upload path: ' . print_r($pathsInterface->getUploadPath(), true) . '</pre>';
    } catch (\IllegalFilesystemAccessException|\JobRouterException $e) {
        echo '<h3 style="color: #f44;">JobRouter Helper error!</h3>';
        echo '<p style="color: #f44;">Message: ' . $e->getMessage() .  '</p>';
    }
};

Response

JobRouter SDK paths interface example!

JobRouter URL: http://localhost/jobrouter
Data path: /var/jobrouter/data/Example_Proccess/1/extra/data/path
Functions path: /var/jobrouter/functions/
Temp path: /var/jobrouter/output/temp/
Upload path: /var/jobrouter/uploads/

Clone this wiki locally