ObjectManager
extends Singleton
in package
This class will help you deal with objects
Table of Contents
Properties
- $fileName : mixed
- $instance : array<string|int, mixed>|null
- $confObject : mixed
- $filePath : mixed
- $objData : mixed
Methods
- __wakeup() : mixed
- AddRelation() : array<string|int, mixed>
- Adds object relation
- CreateObjectConfigFile() : bool
- create object config file
- DeleteRelation() : bool
- Deletes a relation
- DoesObjectFileExists() : bool
- checks if config file exists
- GenerateQueryForObject() : string
- GetAllRelations() : array<string|int, mixed>
- Gets all relations
- GetCreatedAtQuery() : string
- Gets alter table for adding created_at
- GetFullObjectData() : array<string|int, mixed>
- gets all objects from objects config file
- GetObjectData() : array<string|int, mixed>
- Gets objects data by the name
- GetObjectDataByTable() : array<string|int, mixed>
- Gets objects data by the name of its table
- GetObjectDetails() : array<string|int, mixed>
- Gets objects details by the name
- GetObjectFilePath() : string
- if object file path is not set, sets it to default config path
- GetObjectList() : array<string|int, mixed>
- gets the object list
- GetPublicMethods() : array<string|int, mixed>
- Gets the automatically generated methods
- GetPublicProperties() : array<string|int, mixed>
- Gets the public properties from object data
- GetRawRelations() : array<string|int, mixed>|null
- Gets raw relations config
- GetRelationByName() : array<string|int, mixed>
- Returns a relation by the name
- GetRelationsByObject() : array<string|int, mixed>
- Gets all relations from an object
- GetType() : string
- Get PHP type from database type
- GetTypesArr() : array<string|int, mixed>
- Get array of types
- GetUpdatedAtQuery() : string
- Gets alter table for adding updated_at
- Instance() : static|Singleton
- MockClass() : static|Singleton
- SaveObject() : bool
- Gets an object config and saves it
- SetInstance() : mixed
- SetObjectFilePath() : ObjectManager
- sets the object file
- UpdateRelation() : bool
- Updates a relation
- ValidateName() : bool
- Checks if the object name is a valid name
- __clone() : mixed
- __construct() : mixed
- ExtractRelFromRelArray() : array<string|int, mixed>
- gets a relation index and extracts the relation data
- GetObjectConfigFile() : ConfigFile
- returns a ConfigFile object with the object configuration
- GetObjectFileFolderPath() : string
- if object file path is not set, sets it to default config path returns full path without file name
- GetRelationIndexByName() : int
- returns the index of a relation by its name
- GetSQLTypeFromType() : string
- Gets a type and return the sql type for it (simplified)
- SaveRelationArray() : bool
Properties
$fileName
public
mixed
$fileName
= "magrathea_objects.conf"
$instance
protected
static array<string|int, mixed>|null
$instance
= []
$confObject
private
mixed
$confObject
$filePath
private
mixed
$filePath
$objData
private
mixed
$objData
Methods
__wakeup()
public
final __wakeup() : mixed
AddRelation()
Adds object relation
public
AddRelation(string $type, mixed $objBase, string $otherObject, string $field[, bool $isMirror = false ]) : array<string|int, mixed>
Parameters
- $type : string
-
Type, can be: "has_many", "belongs_to", "has_and_belongs_to_many"
- $objBase : mixed
- $otherObject : string
-
Object related
- $field : string
-
relation field
- $isMirror : bool = false
-
is a mirror relation?
Return values
array<string|int, mixed>CreateObjectConfigFile()
create object config file
public
CreateObjectConfigFile() : bool
Return values
bool —creates config file
DeleteRelation()
Deletes a relation
public
DeleteRelation(mixed $relation_name[, bool $is_mirror = false ]) : bool
Parameters
- $relation_name : mixed
- $is_mirror : bool = false
-
is a mirror relation>?
Return values
bool —success?
DoesObjectFileExists()
checks if config file exists
public
DoesObjectFileExists() : bool
Return values
bool —does file exist?
GenerateQueryForObject()
public
GenerateQueryForObject(string $object) : string
Parameters
- $object : string
Return values
stringGetAllRelations()
Gets all relations
public
GetAllRelations() : array<string|int, mixed>
Return values
array<string|int, mixed> —relations;
GetCreatedAtQuery()
Gets alter table for adding created_at
public
GetCreatedAtQuery(string $table) : string
Parameters
- $table : string
-
table name
Return values
string —query
GetFullObjectData()
gets all objects from objects config file
public
GetFullObjectData() : array<string|int, mixed>
Return values
array<string|int, mixed> —data
GetObjectData()
Gets objects data by the name
public
GetObjectData(string $name) : array<string|int, mixed>
Parameters
- $name : string
-
object name
Return values
array<string|int, mixed> —object data
GetObjectDataByTable()
Gets objects data by the name of its table
public
GetObjectDataByTable(mixed $table) : array<string|int, mixed>
Parameters
- $table : mixed
Return values
array<string|int, mixed> —object data
GetObjectDetails()
Gets objects details by the name
public
GetObjectDetails(string $name) : array<string|int, mixed>
Parameters
- $name : string
-
object name
Return values
array<string|int, mixed> —object details
GetObjectFilePath()
if object file path is not set, sets it to default config path
public
GetObjectFilePath() : string
Return values
string —full path with file name
GetObjectList()
gets the object list
public
GetObjectList() : array<string|int, mixed>
Return values
array<string|int, mixed>GetPublicMethods()
Gets the automatically generated methods
public
GetPublicMethods(mixed $obj_data) : array<string|int, mixed>
Parameters
- $obj_data : mixed
Return values
array<string|int, mixed> —public methods in format ["name", "description"]
GetPublicProperties()
Gets the public properties from object data
public
GetPublicProperties(array<string|int, mixed> $obj_data) : array<string|int, mixed>
Parameters
- $obj_data : array<string|int, mixed>
-
object data
Return values
array<string|int, mixed> —public properties in format ["name", "description", "type"]
GetRawRelations()
Gets raw relations config
public
GetRawRelations() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —raw relations data
GetRelationByName()
Returns a relation by the name
public
GetRelationByName(string $name) : array<string|int, mixed>
Parameters
- $name : string
-
name of the string
Return values
array<string|int, mixed> —relation
GetRelationsByObject()
Gets all relations from an object
public
GetRelationsByObject(string $obj) : array<string|int, mixed>
Parameters
- $obj : string
-
object name
Return values
array<string|int, mixed> —relations
GetType()
Get PHP type from database type
public
GetType(mixed $fieldType) : string
Parameters
- $fieldType : mixed
Return values
string —php type
GetTypesArr()
Get array of types
public
GetTypesArr() : array<string|int, mixed>
Return values
array<string|int, mixed>GetUpdatedAtQuery()
Gets alter table for adding updated_at
public
GetUpdatedAtQuery(string $table) : string
Parameters
- $table : string
-
table name
Return values
string —query
Instance()
public
static Instance() : static|Singleton
Return values
static|SingletonMockClass()
public
static MockClass(mixed $mocker) : static|Singleton
Parameters
- $mocker : mixed
Return values
static|SingletonSaveObject()
Gets an object config and saves it
public
SaveObject(string $objName, array<string|int, mixed> $properties) : bool
Parameters
- $objName : string
-
name of object
- $properties : array<string|int, mixed>
-
properties of the object
Return values
bool —success of the operation
SetInstance()
public
SetInstance(mixed $inst) : mixed
Parameters
- $inst : mixed
SetObjectFilePath()
sets the object file
public
SetObjectFilePath(mixed $file) : ObjectManager
Parameters
- $file : mixed
Return values
ObjectManagerUpdateRelation()
Updates a relation
public
UpdateRelation(string $relName, array<string|int, mixed> $newData) : bool
Parameters
- $relName : string
-
relation's name
- $newData : array<string|int, mixed>
-
new data to update (as from config file)
Return values
bool —success?
ValidateName()
Checks if the object name is a valid name
public
ValidateName(string $objName) : bool
Parameters
- $objName : string
-
object name
Return values
bool —is it valid?
__clone()
protected
final __clone() : mixed
__construct()
private
final __construct() : mixed
ExtractRelFromRelArray()
gets a relation index and extracts the relation data
private
ExtractRelFromRelArray(int $index) : array<string|int, mixed>
Parameters
- $index : int
-
relation index
Return values
array<string|int, mixed> —relation data
GetObjectConfigFile()
returns a ConfigFile object with the object configuration
private
GetObjectConfigFile() : ConfigFile
Return values
ConfigFileGetObjectFileFolderPath()
if object file path is not set, sets it to default config path returns full path without file name
private
GetObjectFileFolderPath() : string
Return values
stringGetRelationIndexByName()
returns the index of a relation by its name
private
GetRelationIndexByName(string $name) : int
Parameters
- $name : string
-
relation name
Return values
int —index inside magrathea_objects.conf
GetSQLTypeFromType()
Gets a type and return the sql type for it (simplified)
private
GetSQLTypeFromType(string $type) : string
Parameters
- $type : string
-
type
Return values
string —sqltype
SaveRelationArray()
private
SaveRelationArray(mixed $arr) : bool
Parameters
- $arr : mixed