ReflectionComponent
in package
Represents an abstraction of a component
Tags
Table of Contents
Properties
- $componentName : string
- Name of the component this instance is an abstraction of
- $componentType : string
- Type of the component this instance is an abstraction of
- $componentTypes : array<string|int, mixed>
- List of all available component types
- $cx : Cx
- $db : object
- Database object
- $packageFile : string
- Fully qualified filename for/of the package file
Methods
- __construct() : mixed
- Two different ways to instanciate this are supported: 1. Supply an instance of \Cx\Core\Core\Model\Entity\Component 2. Supply a install package zip filename 3. Supply a component name and type
- activate() : void
- Activate this component
- deactivate() : mixed
- Deactivate this component
- exists() : bool
- Returns wheter this component exists or not in the system Note : It not depends the component type
- getColumnsAndDataFromSql() : array<string|int, mixed>
- parse the mysql query and return the columns and data from the given query.
- getDirectory() : string
- Returns the absolute path to this component's location in the file system
- getName() : string
- Returns the components name
- getNameSpace() : string
- Return namespace of the component
- getType() : string
- Returns the components type
- install() : mixed
- Installs this component from a zip file (if available)
- isInstalled() : bool
- Returns wheter this component installed or not
- isLegacy() : bool
- Tells wheter this is a legacy component or not
- isValid() : bool
- Returns wheter this component is valid or not. A valid component will work as expected
- isValidComponentName() : bool
- Check if the provided string is a valid component name
- remove() : mixed
- Removes this component
- addCustomBackendArea() : mixed
- Add a backend area table record for any component
- addCustomComponent() : void
- Add a custom component table entry
- addCustomModule() : int
- Add or update a module table record, and return the module ID
- addCustomPages() : void
- Add default Pages for a component
- createSettings() : void
- Creates the settings specified in the Component.yml
- createTablesFromYaml() : mixed
- Import table's from the yml files
- getComponentTables() : array<string|int, mixed>
- Get the component related tables
- getModuleIdFromBackendArea() : int|null
- Return the module ID for this component from the backend areas table
- getNextCustomAccessId() : int
- Return the next available Access ID for a custom component
- getNextCustomBackendAreaId() : int
- Return the next available backend area ID for a custom component
- getNextCustomModuleId() : int
- Return the next available ID for a custom module
- getNextCustomOrdinal() : int
- Return the next ordinal for the given parent backend area ID
- importDataFromSql() : mixed
- import component data's to database from sql dump file
- importStructureFromSql() : mixed
- Imports table structure to database from sql dump file
- isCustomized() : bool
- Tells wheter this component is customized or not
- loadPagesFromModuleRepository() : bool
- Creates application Pages from the module repository
- removeFromDb() : mixed
- This completely removes this component from DB
- removeSettings() : void
- Removes all settings of this component
- repalceDataInQuery() : mixed
- replace data in the existing data by the given replacements and return the sql query
Properties
$componentName
Name of the component this instance is an abstraction of
protected
string
$componentName
= null
Component name
$componentType
Type of the component this instance is an abstraction of
protected
string
$componentType
= null
Component type
$componentTypes
List of all available component types
protected
static array<string|int, mixed>
$componentTypes
= array('core', 'core_module', 'module', 'lib')
List of component types
Tags
$cx
protected
Cx
$cx
Current instance of Cx
$db
Database object
protected
object
$db
= null
$packageFile
Fully qualified filename for/of the package file
protected
string
$packageFile
= null
ZIP package filename
Methods
__construct()
Two different ways to instanciate this are supported: 1. Supply an instance of \Cx\Core\Core\Model\Entity\Component 2. Supply a install package zip filename 3. Supply a component name and type
public
__construct(mixed $arg1[, string|null $arg2 = null ]) : mixed
Parameters
- $arg1 : mixed
-
Either an instance of \Cx\Core\Core\Model\Entity\Component or the name of a component
- $arg2 : string|null = null
-
(only if a component name was supplied as $arg1) Component type (one of core_module, module, core, lib)
Tags
activate()
Activate this component
public
activate() : void
Tags
deactivate()
Deactivate this component
public
deactivate() : mixed
Tags
exists()
Returns wheter this component exists or not in the system Note : It not depends the component type
public
exists([bool $allowCustomizing = true ]) : bool
Parameters
- $allowCustomizing : bool = true
-
(optional) Set to false if you want to ignore customizings
Return values
bool —True if it exists, false otherwise
getColumnsAndDataFromSql()
parse the mysql query and return the columns and data from the given query.
public
getColumnsAndDataFromSql(string $sqlQuery) : array<string|int, mixed>
Parameters
- $sqlQuery : string
-
Mysql query
Return values
array<string|int, mixed>getDirectory()
Returns the absolute path to this component's location in the file system
public
getDirectory([bool $allowCustomizing = true ][, bool $forceCustomized = false ]) : string
Parameters
- $allowCustomizing : bool = true
-
(optional) Set to false if you want to ignore customizings
- $forceCustomized : bool = false
-
(optional) If true, the directory in customizing folder is returned, default false
Return values
string —Path for this component
getName()
Returns the components name
public
getName() : string
Return values
string —Component name
getNameSpace()
Return namespace of the component
public
getNameSpace() : string
Return values
stringgetType()
Returns the components type
public
getType() : string
Return values
string —Component type
install()
Installs this component from a zip file (if available)
public
install() : mixed
Tags
isInstalled()
Returns wheter this component installed or not
public
isInstalled() : bool
Return values
bool —True if it exists, false otherwise
isLegacy()
Tells wheter this is a legacy component or not
public
isLegacy() : bool
Return values
bool —True if its a legacy one, false otherwise
isValid()
Returns wheter this component is valid or not. A valid component will work as expected
public
isValid() : bool
Return values
bool —True if valid, false otherwise
isValidComponentName()
Check if the provided string is a valid component name
public
isValidComponentName(mixed $name) : bool
Parameters
- $name : mixed
Return values
bool —True if sring $name is a valid component name
remove()
Removes this component
public
remove() : mixed
This might not work perfectly for legacy components, since there could be files outside the component's directory! Be sure there is no other component relying on this one!
Tags
addCustomBackendArea()
Add a backend area table record for any component
protected
addCustomBackendArea(int $moduleId) : mixed
Searches for the component by its "uri" column. For existing records, updates the module ID only. Adds default values for new ones.
Parameters
- $moduleId : int
Tags
addCustomComponent()
Add a custom component table entry
protected
addCustomComponent(int $moduleId) : void
This is a noop for legacy components. Doesn't touch existing records. Note: As the component ID column is AUTO_INCREMENT, and there's no setId() method available on SystemComponent, the ID is forcibly updated to the $moduleId after creation. That SHOULD not be an issue, since there are at most as many records for components as in the module table (legacy). However, any orphan records will inevitably lead to a conflict at some point.
Parameters
- $moduleId : int
Tags
addCustomModule()
Add or update a module table record, and return the module ID
protected
addCustomModule() : int
Existing entries will only have their status and flags reset to defaults.
Tags
Return values
intaddCustomPages()
Add default Pages for a component
protected
addCustomPages(int $moduleId) : void
Only applies to modules; for other types, this is a noop. Does nothing if any page exists for the module already. If no content is found in the module repository, creates a default application page.
Parameters
- $moduleId : int
Tags
createSettings()
Creates the settings specified in the Component.yml
protected
createSettings() : void
In order for this to work the version needs to be >= 2.1.
Tags
createTablesFromYaml()
Import table's from the yml files
protected
createTablesFromYaml() : mixed
getComponentTables()
Get the component related tables
protected
getComponentTables() : array<string|int, mixed>
Return values
array<string|int, mixed> —component related tables
getModuleIdFromBackendArea()
Return the module ID for this component from the backend areas table
protected
getModuleIdFromBackendArea() : int|null
Returns null if there's no such entry. Mind that deactivate() won't remove that record, thus allowing to (re-)activate components using the same module ID. Otherwise, standard components would be installed using a custom ID (900 and up).
Tags
Return values
int|nullgetNextCustomAccessId()
Return the next available Access ID for a custom component
protected
getNextCustomAccessId() : int
Returns an integer greater than or equal to 900.
Tags
Return values
intgetNextCustomBackendAreaId()
Return the next available backend area ID for a custom component
protected
getNextCustomBackendAreaId() : int
Returns an integer greater than or equal to 900.
Tags
Return values
intgetNextCustomModuleId()
Return the next available ID for a custom module
protected
getNextCustomModuleId() : int
For existing modules, returns their current ID. This may be taken from the modules table, or, if not present there, from the backend areas table. If neither can be found, returns the next available ID greater than or equal to 900.
Tags
Return values
intgetNextCustomOrdinal()
Return the next ordinal for the given parent backend area ID
protected
getNextCustomOrdinal(int $parentAreaId) : int
Increases the previously highest ordinal by one, or returns 1 if none.
Parameters
- $parentAreaId : int
Tags
Return values
intimportDataFromSql()
import component data's to database from sql dump file
protected
importDataFromSql(int $moduleId) : mixed
Parameters
- $moduleId : int
importStructureFromSql()
Imports table structure to database from sql dump file
protected
importStructureFromSql() : mixed
isCustomized()
Tells wheter this component is customized or not
protected
isCustomized() : bool
Return values
bool —True if customized (and customizings are active)
loadPagesFromModuleRepository()
Creates application Pages from the module repository
protected
loadPagesFromModuleRepository(int $moduleId) : bool
Returns false if there are no pages in the repository for that module, true otherwise.
Parameters
- $moduleId : int
Tags
Return values
boolremoveFromDb()
This completely removes this component from DB
protected
removeFromDb() : mixed
Tags
removeSettings()
Removes all settings of this component
protected
removeSettings() : void
Tags
repalceDataInQuery()
replace data in the existing data by the given replacements and return the sql query
protected
repalceDataInQuery(string $table, array<string|int, mixed> $data, array<string|int, mixed> $replacements) : mixed
Parameters
- $table : string
-
Table name
- $data : array<string|int, mixed>
-
Data array
- $replacements : array<string|int, mixed>
-
Replacement data array