Oihana PHP

PathTrait

Provides path-related properties and helpers for controllers exposing resource routes.

This trait manages the controller's own path, its absolute fullPath, and an optional ownerPath used to build nested, owner-scoped resource URLs.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$fullPath  : string
The full path reference.
$ownerPath  : string|null
The path of an owner reference.
$path  : string
The path reference.

Methods

getFullOwnerPath()  : string
Returns the full owner path URL for a specific owner identifier.
initializePath()  : static
Sets the path properties of the controller.

Properties

$fullPath

The full path reference.

public string $fullPath

$ownerPath

The path of an owner reference.

public string|null $ownerPath = \oihana\enums\Char::EMPTY

$path

The path reference.

public string $path = \oihana\enums\Char::EMPTY

Methods

getFullOwnerPath()

Returns the full owner path URL for a specific owner identifier.

public getFullOwnerPath(string $id) : string

The result joins the ownerPath, the given owner $id and the controller path (e.g. owners/42/articles).

Parameters
$id : string

The owner identifier to inject between the owner path and the resource path.

Return values
string

The joined owner-scoped resource path.

initializePath()

Sets the path properties of the controller.

public initializePath([array<string|int, mixed> $init = [] ]) : static

Reads the path, fullPath and ownerPath values from the corresponding ControllerParam keys of the initialization array, falling back to sensible defaults when they are not provided.

Parameters
$init : array<string|int, mixed> = []

Optional initialization array.

Return values
static

Returns the current instance for method chaining.

On this page

Search results