Abstract Class luya\admin\openapi\BasePathParser

Inheritanceluya\admin\openapi\BasePathParser
Subclassesluya\admin\openapi\ActionRouteParser, luya\admin\openapi\UrlRuleRouteParser
Available since version3.2.0
Source Code https://github.com/luyadev/luya-module-admin/blob/master/src/openapi/BasePathParser.php

Base Class to convert Data into Paths.

Terminology:

  • Absolute Route: admin/user/index or admin/api-cms-admin/create
  • Controller Map Route: admin/api-cms-admin or admin/api-cms-nav

Public Methods

Hide inherited methods

Method Description Defined By
generateOperationId() Generate a readable operation id for current route and verb. luya\admin\openapi\BasePathParser
getPath() Returns the path which should be associated with this endpoint. luya\admin\openapi\BasePathParser
getPathItem() Return a PathItem. luya\admin\openapi\BasePathParser
isValid() Whether this Parser is valid or not. luya\admin\openapi\BasePathParser
normalizeTag() Generate a normalized tag from a given route. luya\admin\openapi\BasePathParser
routes() Returns all absolute controller map routes which are covered by this parser. luya\admin\openapi\BasePathParser

Method Details

Hide inherited methods

generateOperationId() public method

Generate a readable operation id for current route and verb.

public string generateOperationId ( $verb )
$verb string

                public function generateOperationId($verb)
{
    $path = ltrim(str_replace(["admin/api-", "admin/api", "admin/"], '', $this->getPath()), '/');
    $operation = $verb . '-'. str_replace("/", " ", $path); // replace slashes with newlines
    $camelCase = Inflector::slug($operation, '-', true, false);
    return Generator::generateUniqueOperationId(Inflector::id2camel($camelCase));
}

            
getPath() public abstract method

Returns the path which should be associated with this endpoint.

This is the actual route which then recieves the request.

public abstract string getPath ( )

                abstract public function getPath(): string;

            
getPathItem() public abstract method

Return a PathItem.

A PathItem represents a path within the openapi definition. A path (or maybe also named as endpoint/route) can have multiple verbs. Like post, get, put

public abstract \cebe\openapi\spec\PathItem getPathItem ( )

                abstract public function getPathItem(): PathItem;

            
isValid() public abstract method

Whether this Parser is valid or not.

public abstract boolean isValid ( )

                abstract public function isValid(): bool;

            
normalizeTag() public method

Generate a normalized tag from a given route.

public string normalizeTag ( $route )
$route string

                public function normalizeTag($route)
{
    $route = str_replace(["admin/"], '', $route);
    return ltrim(trim($route, '/'));
}

            
routes() public abstract method

Returns all absolute controller map routes which are covered by this parser.

For example the update and post route are difference and covered, it would be:

  • admin/api-admin-user/create
  • admin/api-admin-user/update
public abstract array routes ( )

                abstract public function routes(): array;