Documentation

ApiManager
in package
Uses Singleton, ExtendableTrait

Manages all the API nodes.

Tags
author

Saifur Rahman Mohsin

Table of Contents

$extendableCallbacks  : array<string|int, mixed>
$extendableGuardProperties  : bool
$extendableStaticMethods  : array<string|int, mixed>
$extensionData  : array<string|int, mixed>
$instance  : mixed
$nodes  : collection
$pluginManager  : PluginManager
$prefix  : API
$router  : CoreRouter
__clone()  : mixed
__wakeup()  : mixed
addDynamicMethod()  : mixed
Programmatically adds a method to the extendable class
addDynamicProperty()  : mixed
Programmatically adds a property to the extendable class
asExtension()  : mixed
Short hand for `getClassExtension()` method, except takes the short extension name, example:
clearExtendedClasses()  : void
Clear the list of extended classes so they will be re-extended.
discoverNewNodes()  : void
Registers the API nodes exposed by various plugins
extendableCall()  : mixed
Magic method for `__call()`
extendableCallStatic()  : mixed
Magic method for `__callStatic()`
extendableConstruct()  : mixed
This method should be called as part of the constructor.
extendableExtendCallback()  : void
Helper method for `::extend()` static method
extendableGet()  : string
Magic method for `__get()`
extendableSet()  : string
Magic method for `__set()`
extendClassWith()  : void
Dynamically extend a class with a specified behavior
forgetInstance()  : mixed
Forget this singleton's instance if it exists
getClassExtension()  : mixed
Returns a behavior object from an extendable class, example:
getClassMethods()  : array<string|int, mixed>
Get a list of class methods, extension equivalent of get_class_methods()
getDynamicProperties()  : array<string|int, mixed>
Returns all dynamic properties and their values
getPrefix()  : mixed
instance()  : mixed
Create a new instance of this singleton.
isClassExtendedWith()  : bool
Check if extendable class is extended with a behavior object
methodExists()  : bool
Checks if a method exists, extension equivalent of method_exists()
propertyExists()  : bool
Checks if a property exists, extension equivalent of `property_exists()`
registerNodes()  : void
Registers the API nodes exposed by a plugin into the system.
registerNodesWithRouter()  : mixed
__construct()  : mixed
Constructor.
extendableIsAccessible()  : bool
Checks if a property is accessible, property equivalent of `is_callable()`
extensionExtractMethods()  : void
Extracts the available methods from a behavior and adds it to the list of callable methods.
init()  : mixed
Initialize this singleton.
registerApiNodes()  : void
Register the API nodes with the app router

Properties

$extendableCallbacks

protected static array<string|int, mixed> $extendableCallbacks = []

Used to extend the constructor of an extendable class. Eg:

Class::extend(function($obj) { })

$extendableGuardProperties

protected static bool $extendableGuardProperties = true

Indicates if dynamic properties can be created.

$extendableStaticMethods

protected static array<string|int, mixed> $extendableStaticMethods = []

Collection of static methods used by behaviors.

$extensionData

protected array<string|int, mixed> $extensionData = ['extensions' => [], 'methods' => [], 'dynamicMethods' => [], 'dynamicProperties' => []]

Class reflection information, including behaviors.

$nodes

protected collection $nodes = []

Cache of the registered API nodes.

$pluginManager

protected PluginManager $pluginManager

$prefix

protected API $prefix

prefix TODO: Replace with customizable value.

Methods

__clone()

public __clone() : mixed
Return values
mixed

__wakeup()

public __wakeup() : mixed
Return values
mixed

addDynamicMethod()

Programmatically adds a method to the extendable class

public addDynamicMethod(string $dynamicName, callable $method[, string $extension = null ]) : mixed
Parameters
$dynamicName : string
$method : callable
$extension : string = null
Return values
mixed

addDynamicProperty()

Programmatically adds a property to the extendable class

public addDynamicProperty(string $dynamicName[, string $value = null ]) : mixed
Parameters
$dynamicName : string
$value : string = null
Return values
mixed

asExtension()

Short hand for `getClassExtension()` method, except takes the short extension name, example:

public asExtension(string $shortName) : mixed

$this->asExtension('FormController')

Parameters
$shortName : string
Return values
mixed

clearExtendedClasses()

Clear the list of extended classes so they will be re-extended.

public static clearExtendedClasses() : void
Return values
void

discoverNewNodes()

Registers the API nodes exposed by various plugins

public discoverNewNodes() : void
Return values
void

extendableCall()

Magic method for `__call()`

public extendableCall(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
$name : string
$params : array<string|int, mixed> = null
Return values
mixed

extendableCallStatic()

Magic method for `__callStatic()`

public static extendableCallStatic(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
$name : string
$params : array<string|int, mixed> = null
Return values
mixed

extendableConstruct()

This method should be called as part of the constructor.

public extendableConstruct() : mixed
Return values
mixed

extendableExtendCallback()

Helper method for `::extend()` static method

public static extendableExtendCallback(callable $callback) : void
Parameters
$callback : callable
Return values
void

extendableGet()

Magic method for `__get()`

public extendableGet(string $name) : string
Parameters
$name : string
Return values
string

extendableSet()

Magic method for `__set()`

public extendableSet(string $name, string $value) : string
Parameters
$name : string
$value : string
Return values
string

extendClassWith()

Dynamically extend a class with a specified behavior

public extendClassWith(string $extensionName) : void
Parameters
$extensionName : string
Return values
void

forgetInstance()

Forget this singleton's instance if it exists

public final static forgetInstance() : mixed
Return values
mixed

getClassExtension()

Returns a behavior object from an extendable class, example:

public getClassExtension(string $name) : mixed

$this->getClassExtension('Backend.Behaviors.FormController')

Parameters
$name : string

Fully qualified behavior name

Return values
mixed

getClassMethods()

Get a list of class methods, extension equivalent of get_class_methods()

public getClassMethods() : array<string|int, mixed>
Return values
array<string|int, mixed>

getDynamicProperties()

Returns all dynamic properties and their values

public getDynamicProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

['property' => 'value']

getPrefix()

public getPrefix() : mixed
Return values
mixed

instance()

Create a new instance of this singleton.

public final static instance() : mixed
Return values
mixed

isClassExtendedWith()

Check if extendable class is extended with a behavior object

public isClassExtendedWith(string $name) : bool
Parameters
$name : string

Fully qualified behavior name

Return values
bool

methodExists()

Checks if a method exists, extension equivalent of method_exists()

public methodExists(string $name) : bool
Parameters
$name : string
Return values
bool

propertyExists()

Checks if a property exists, extension equivalent of `property_exists()`

public propertyExists(string $name) : bool
Parameters
$name : string
Return values
bool

registerNodes()

Registers the API nodes exposed by a plugin into the system.

public registerNodes(string $owner, array<string|int, mixed> $nodes) : void

The argument is an array of the nodes and their configurations.

Parameters
$owner : string

Specifies the menu items owner plugin or module in the format Author.Plugin.

$nodes : array<string|int, mixed>

An array of the nodes the plugin exposes.

Return values
void

registerNodesWithRouter()

public registerNodesWithRouter(object $node) : mixed
Parameters
$node : object
Return values
mixed

__construct()

Constructor.

protected final __construct() : mixed
Return values
mixed

extendableIsAccessible()

Checks if a property is accessible, property equivalent of `is_callable()`

protected extendableIsAccessible(mixed $class, string $propertyName) : bool
Parameters
$class : mixed
$propertyName : string
Return values
bool

extensionExtractMethods()

Extracts the available methods from a behavior and adds it to the list of callable methods.

protected extensionExtractMethods(string $extensionName, object $extensionObject) : void
Parameters
$extensionName : string
$extensionObject : object
Return values
void

init()

Initialize this singleton.

protected init() : mixed
Return values
mixed

registerApiNodes()

Register the API nodes with the app router

protected registerApiNodes() : void
Return values
void

Search results