Documentation

ReflectionComponent
in package

Represents an abstraction of a component

Tags
copyright

Cloudrexx AG

author

Michael Ritter michael.ritter@comvation.com

subpackage

core_core

version
3.1.0

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
todo

Wouldn't it be better to move this to Component class?

$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
throws
ReflectionComponentException
throws
BadMethodCallException

activate()

Activate this component

public activate() : void
Tags
TODO:

This should only do install() (see todo there) and the same as ModuleManager does Adds all missing database records, updates where necessary. Recreates all proxies on success. Fails if the component folder doesn't exist. When adding custom components, new module and access IDs are created. Note that most of the methods called within contain "custom" in their names. These also apply to standard components, but only do standard stuff, and return standard values for them. Standard component IDs are defined by the installer, and should be preserved whenever possible.

throws
ComponentException

on failure

todo

Backend navigation entry from meta.yml (rxqcmv1)

todo

Pages from meta.yml (rxqcmv1)

deactivate()

Deactivate this component

public deactivate() : mixed
Tags
TODO:

This should only do the same as ModuleManager does Removes Pages, as well as the component and module table entries. Doesn't touch the backend area with the access IDs.

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

install()

Installs this component from a zip file (if available)

public install() : mixed
Tags
todo

This should not do any FS action as these should be done by GIT or cx env component. Instead, this should do initializations like settings, DB tables, entries in modules and component tables, ...

todo

Uninstall should do the opposite of what's described above

todo

DB stuff (structure and data)

todo

check dependency versions

todo

activate templates

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
todo

Apparently unused; drop?

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
throws
ComponentException

on failure

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
throws
ComponentException

on failure

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
throws
ComponentException

on failure

Return values
int

addCustomPages()

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
see
loadPagesFromModuleRepository()

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
throws
Exception

On error

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
throws
ComponentException

on failure

Return values
int|null

getNextCustomAccessId()

Return the next available Access ID for a custom component

protected getNextCustomAccessId() : int

Returns an integer greater than or equal to 900.

Tags
throws
ComponentException

on failure

Return values
int

getNextCustomBackendAreaId()

Return the next available backend area ID for a custom component

protected getNextCustomBackendAreaId() : int

Returns an integer greater than or equal to 900.

Tags
throws
ComponentException

on failure

Return values
int

getNextCustomModuleId()

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
throws
ComponentException

on failure

Return values
int

getNextCustomOrdinal()

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
throws
ComponentException

on failure

Return values
int

importDataFromSql()

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
throws
ComponentException

on failure

Return values
bool

removeFromDb()

This completely removes this component from DB

protected removeFromDb() : mixed
Tags
todo

Test removing components tables (including doctrine schema)

todo

This contains duplicate code with $this->deactivate()

internal

Currently unused in this class; see remove() The only current usage is in Workbench's ReflectionComponent::internalRelocate()

removeSettings()

Removes all settings of this component

protected removeSettings() : void
Tags
throws
Exception

On error

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


        
On this page

Search results