BasketHandler
extends ObjectHandler
in package
Implement basket object handler
In the fileAccess context most contents are children of this class. With this class the DAB for storage of baskets and related interactions are realized.
Tags
Table of Contents
- $ForcedSave : bool
- Buffer for forced content save state
- $_unit_types : array<string|int, mixed>|null
- $active_languages : array<string|int, mixed>|null
- The active languages buffer
- $affected : array<string|int, mixed>
- List of affected files and directories in recursion
- $assignableTypes : array<string|int, mixed>
- buffer of assignable types
- $attribute_options : array<string|int, mixed>
- static storage for attribute options
- $childTypes : array<string|int, mixed>
- Cache for child types
- $classes : array<string|int, mixed>
- Buffer for class exists tests
- $collator : int
- Cache if collators are available
- $context : AppContext|Request|CronJob|CommandLineContext
- Storage for current global context
- $countries : array<string|int, mixed>
- $db : array<string|int, mixed>
- Database connections
- $handlers : array<string|int, mixed>
- Handler storage
- $hooks : array<string|int, mixed>|null
- The hooks buffer
- $log_template : string
- The template for log messages in ::Log()
- $plugins : array<string|int, mixed>
- The plugin buffer
- $size_unit : array<string|int, mixed>
- Available file size short codes
- $translations : array<string|int, mixed>|null
- translation list buffer
- AddArticleToCurrent() : Result
- Add article
- AddCommentToCurrent() : Result
- Add or, replace comment Adds a comment to the basket object and calls the object saver
- AddFieldRules() : void
- Add field rules to certain type
- AddFieldsToType() : void
- Add fields to type
- AddHeadsToTypeTable() : void
- Add a list of heads to a table attribute
- AddTabToType() : void
- Add tab to type
- ArrayToObject() : stdClass|null
- Convert array to object
- BasketToPdf() : Result
- Create pfd file from basket
- BasketToPdfEncryped() : Result
- Create encrypted pfd file from basket
- CalculateFolderSize() : array<string|int, mixed>
- Calculate size of a specific folder use a recursive working function to calculate a folder size
- CallExecutable() : Result
- Execute a system command Uses installed executable to perform a system call
- CallHook() : bool
- Call hook
- ChangeArticleAmount() : Result
- Change article amount
- ChangeCurrentDeliveryMethod() : Result
- Change delivery method
- ChangeCurrentPaymentMethod() : Result
- Change payment method
- CheckAddress() : Result
- Check address data Validate the given data address components in checkout process
- CheckoutConfig() : object|null
- Get the checkout configuration
- Chmod() : bool
- Change the permissions of a file
- ClassExists() : bool
- Class exists
- CleanByRelation() : Result
- Delete entity from file system and git repo
- ClearCache() : void
- Clear the static cache
- CollatorExists() : bool
- Check if collators available Test if the ICU collator functions ae available. This function is cached.
- ConfigGetPreset() : Result
- Load a config preset Fetch a preset from default system storage location and return it decoded
- Context() : AppContext|Request|CronJob|CommandLineContext
- Get/Set the global context
- CopyFile() : Result
- Copy file Copy a single file with obtaining lock on index before
- CopyFolder() : Result
- Copy folder
- CreateEncrypedArchive() : Result
- Create an encrypted zip archive
- CurrentId() : string|null
- Set the current id or load it
- DataBase() : DBAL|null
- Debug() : void
- log debug object writs a formatted log message including back trace to the global log file
- DecodeJson() : Result
- Parse json from string to object or assoc
- DecodeJsonFile() : Result
- Parse json from file to object or assoc
- DeepDiff() : mixed
- Deep diff of old and new values
- DeleteFile() : bool
- Deletes single file This method deletes a single file, it will wait when the system is in git lock mode
- DeliveryMethod() : DeliveryMethod
- Get delivery method Load a method instance and fetch a legacy configuration on top on demand
- DeliveryMethodList() : array<string|int, DeliveryMethod>
- Get method list Get the list of registered delivery method handlers
- DropFolder() : array<string|int, mixed>
- Delete a full folder
- EncodeJson() : Result
- Serialize a given input to json representation
- ExtractAttributeNames() : array<string|int, mixed>
- Get attribute names
- ExtractAttributeOptions() : Result
- Get translated options list of attribute
- ExtractCountryCode() : string|null
- Extract some country code from address object data
- ExtractCountryName() : string|null
- Extract some country code from address object data
- ExtractExtension() : bool|string
- Extract file extension
- ExtractFileName() : string
- Extract file name
- ExtractFolder() : string
- Extract folder path from root
- ExtractFolderName() : string
- Extract folder name from root
- ExtractPrimaryRelationType() : string|null
- Extract the primary type from an object attribute relation
- FetchCountries() : Result
- Get list of countries
- FileExists() : bool|string
- Check if file exists
- FilterFolderFilesByModificationTime() : Result
- Get a list of files that are either older or newer a certain time point
- FilterListAssoc() : array<string|int, BaseContent>
- filter result list does a quick filtering in the given list, this method operates language independent results will be specified using a strpos() operation
- FilterTypeListAssoc() : Result
- filter result list by type does a quick filtering in the given list, this method operates language independant results will be determinated using a strpos() operation
- FindCountry() : Country|null
- FormatPrice() : string
- Format a price
- FormattedId() : string
- expose the formatted object id provide an interface to extract the current id with formatting options
- GenerateUUIDv4() : string
- Generate an unique id
- GetActiveLanguages() : array<string|int, mixed>|null
- Get active languages
- GetArticleStock() : float|int|null
- Get available amount in all storage locations for certain article
- GetAssignableEntityTypes() : Result
- Get entity type set of assignable contents
- GetChildTypes() : Result
- Get types and subtypes form storage
- GetClassNames() : array<string|int, mixed>
- List classes in folder Fetch a list of classes inside the folder
- GetCurrent() : Basket|null
- Get current basket object
- GetEntityAttributes() : Result
- Get entity form attributes
- GetEntityTypes() : Result
- Get entity type set
- GetLock() : Result
- Obtain lock try to obtain the lock indicated by lock file in var
- GetMailSetup() : Result
- Get a setup object
- GetNextOfSequence() : Result
- Interface function to get a set of ids
- GetObjectDirect() : BaseContent|null
- Get entity instance
- GetObjectLock() : bool
- GetRawMailSetup() : EmailSetup
- Get a setup object Get a email setup instance by given name
- GetRawObject() : Result
- Get entity form storage
- GetRawObjectDirect() : Result
- Get raw entity form storage Load the full object of a certain object type identified by id, only available for not named object types
- GetRelatedTypes() : Result
- Get plain list of related types (top and down)
- GetSortKey() : Result
- Calculate the sort key Using the ICU collator to create a sort key representation of the given string.
- GetTranslation() : string
- get translations fetch translation data from storage or add on demand
- GetTranslationObject() : Translation
- Fetch translation Load a single translation instance
- GetType() : Type|null
- Get certain content type by name
- GetTypeClassPath() : string
- Get path to class
- GzCompressFile() : Result
- GZIPs a file on disk (appending .gz to the name)
- HtmlToPdf() : Result
- Convert html to pdf
- IdToHex() : array<string|int, mixed>|null
- Convert an id to hexadecimal array with last 2 parts as value
- IdToPath() : string
- Convert id to path Convert the given numeric id to absolute path
- indexSort() : mixed
- IsBase64() : bool
- Guess if string is base64 will try to guess if the given string is base64
- IsEmptyDir() : bool|null
- Is empty folder
- KnownPlugins() : array<string|int, Plugin>
- Get the known plugins
- ListEntries() : Result
- list generic objects Read a list of groups from local storage Uses the generic object load to get the entry list
- ListFiles() : array<string|int, mixed>
- list files Iterate over directory and list the found files
- ListFolders() : array<string|int, mixed>
- List folder names in certain root folder
- ListIdFiles() : array<string|int, mixed>
- find file ids find a list of file ids inside a folder and its sub directories
- ListVoucherPresets() : array<string|int, mixed>
- Fetch voucher presets
- LoadTypesWithRelatedContentAttribute() : Result
- Get list of types that have an certain relation attribute
- Log() : void
- log object writs a formatted log message including back trace to the global log file
- MemoryBytesReadable() : string
- Memory readable Convert size of bytes in human-readable units
- MergePdfFiles() : Result
- Merge some pdf files
- MimeType() : string|bool
- Get mime type of file
- MkFolder() : string|null
- Create folder path
- Open() : Basket|null
- Open a basket by id
- OpenArticle() : Article|null
- Open article by id
- OpenByRoomBooking() : Basket|null
- OpenService() : Service|null
- OpenVoucher() : Voucher|null
- Open a single voucher preset
- OSName() : string
- PaymentMethod() : PaymentMethod|null
- Get payment method Load a method instance
- PaymentMethodList() : array<string|int, PaymentMethod>
- Get method list Get the list of registered payment method handlers
- Plugin() : Plugin|null
- Get plugin
- ReadCsv() : Result
- Read a CSV file to local storage
- ReadFile() : Result
- Read a single file
- ReadFixedColumnFile() : Result
- Read file with fixed column width
- ReadFolder() : array<string|int, File>
- Read folder
- RegisterBaseObject() : Result
- Register a basic content object by type Create a content object
- RegisterContentType() : Result
- Register a new content type
- RemoveFieldsFromType() : void
- Remove fields from type
- RemoveItemFromCurrent() : Result
- Delete article from basket
- RenameFolderOrFile() : Result
- Rename folder or file
- ResolveCountryCode() : string|null
- Get country iso code by id.
- ResolvedTypeFamily() : Result
- Get resolved family list of types
- resolveSubType() : stdClass|null
- Resolve a sub type using the given preset definition
- ResolveVoucherByCode() : Result
- RevokeLock() : Result
- release lock try to release the lock indicated by lock file in var
- RevokeObjectLock() : Result
- SelfLockedOrOpen() : bool
- StoreEncodedJson() : Result
- Serialize a given input and store it
- StripQueryAndAnchor() : string
- Extract file name
- SysLog() : bool
- Log message
- SystemInformation() : void
- Get system information
- TailLogfile() : Result
- tail a log file get set of lines inside a logfile
- TranslateArticleUnit() : string|stdClass|null
- TranslateAttributeName() : mixed|null
- TranslateAttributeOption() : string|null|stdClass
- Translate a single option by value
- TranslateSalutation() : string|stdClass|null
- Translate salutation
- TryGetLock() : bool
- TryUnLock() : bool
- Unlock try to disable the lock indicated by lock file in var
- TypeExists() : string|null
- Check if content type exists and return path to definition file
- UnlinkCurrent() : Result
- Unlink basket in session
- Unzip() : Result
- Unzip a file
- UpdateCurrentAddress() : Result
- Update a basket address Update the bill or delivery address of the current basket
- UpdateEntity() : Result
- update object apply changes to a certain object using the given change data set
- UUIdToPath() : string
- Convert uuid to path Convert the given uuid in version 4 to absolute path
- Version() : string
- VersionStringToNumber() : string
- Convert version number Converts the given number to a unified string e.g. 'v1.234.33' will become 102340033
- Warn() : void
- warn level log object writs a formatted log message including back trace to the global log file
- WriteCsv() : Result
- Write a array of entries to csv file
- WriteFile() : bool
- Write string to file
- Zip() : Result
- Create a zip archive from folder or file contents
- extractTitle() : string
- Get title Extract a translated title
- ListImplementedHandlers() : array<string|int, mixed>
- Get handler list Get the list of registered handlers
- RegisterPlugins() : mixed
- Register plugins
- CalculateFolderSizeRecurse() : bool
- Helper function to calculate size Recursively calculate size of a specific folder
- decrypt() : string
- Decrypt data
- DropFolderRecurse() : bool
- Delete a folder completely this method is the recursion helper for DropFolder()
- encrypt() : string
- Encrypt data
- listEntriesOfType() : Result
- List generic objects
- listFolderEntities() : array<string|int, mixed>
- List folder entries
- parseKeyFile() : null|string|array<string|int, mixed>
- recurseExtractAttributeOptions() : void
- resolveTypesWithRelatedContentAttribute() : mixed
- updateEntityAttribute() : void
- update object attribute apply changes to a certain object attribute using the given change dataset
- updateEntityAttributes() : void
- Update object attribute list
- updateEntityAttributeTable() : void
- update object attribute of type relation apply changes to a certain object attribute using the given change dataset
Properties
$ForcedSave
Buffer for forced content save state
public
static bool
$ForcedSave
= false
$_unit_types
private
static array<string|int, mixed>|null
$_unit_types
= null
$active_languages
The active languages buffer
private
static array<string|int, mixed>|null
$active_languages
= null
$affected
List of affected files and directories in recursion
private
static array<string|int, mixed>
$affected
= array()
The list of paths
$assignableTypes
buffer of assignable types
private
static array<string|int, mixed>
$assignableTypes
= array()
$attribute_options
static storage for attribute options
private
static array<string|int, mixed>
$attribute_options
= array()
$childTypes
Cache for child types
private
static array<string|int, mixed>
$childTypes
= []
$classes
Buffer for class exists tests
private
static array<string|int, mixed>
$classes
= array()
The status of the classes
$collator
Cache if collators are available
private
static int
$collator
= -1
Initial set to -1
$context
Storage for current global context
private
static AppContext|Request|CronJob|CommandLineContext
$context
= null
$countries
private
static array<string|int, mixed>
$countries
= []
$db
Database connections
private
static array<string|int, mixed>
$db
= []
$handlers
Handler storage
private
static array<string|int, mixed>
$handlers
= []
$hooks
The hooks buffer
private
static array<string|int, mixed>|null
$hooks
= null
$log_template
The template for log messages in ::Log()
private
static string
$log_template
= "Called from LINE %s IN Script: %s\n"
The template
$plugins
The plugin buffer
private
static array<string|int, mixed>
$plugins
= array()
$size_unit
Available file size short codes
private
static array<string|int, mixed>
$size_unit
= array('b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb')
Used in the readable form
$translations
translation list buffer
private
static array<string|int, mixed>|null
$translations
= null
Buffer with texts
Methods
AddArticleToCurrent()
Add article
public
static AddArticleToCurrent(array<string|int, mixed> $setup) : Result
Adds an article by id and type to the current basket This method can either add at the end or override the article by id and type
If a brand is defined the bundle configuration will be overwritten by null
Parameters
- $setup : array<string|int, mixed>
Return values
Result —A system result object
AddCommentToCurrent()
Add or, replace comment Adds a comment to the basket object and calls the object saver
public
static AddCommentToCurrent(string $content) : Result
Parameters
- $content : string
-
A comment string
Return values
Result —A system result object
AddFieldRules()
Add field rules to certain type
public
static AddFieldRules( $type, $rules) : void
Parameters
Return values
void —AddFieldsToType()
Add fields to type
public
static AddFieldsToType(object $type, array<string|int, mixed> $fields) : void
Add some fields to the element type.
Parameters
- $type : object
-
A simplified object type data set
- $fields : array<string|int, mixed>
-
A list of fields to add
Return values
void —AddHeadsToTypeTable()
Add a list of heads to a table attribute
public
static AddHeadsToTypeTable(stdClass $type, string $table, array<string|int, mixed> $fields) : void
Parameters
- $type : stdClass
-
The content type to extend
- $table : string
-
The table to extend
- $fields : array<string|int, mixed>
-
The attributes/heads
Return values
void —AddTabToType()
Add tab to type
public
static AddTabToType(object $type, object $tab) : void
Can be used in hook to assign a "virtual" tab to an existing content type definition
Parameters
- $type : object
-
A resolved type object
- $tab : object
-
A tab configuration to assign
Return values
void —ArrayToObject()
Convert array to object
public
static ArrayToObject(array<string|int, mixed> $array) : stdClass|null
Convert the given array element to object, using the json methods
Parameters
- $array : array<string|int, mixed>
-
The input values to convert
Return values
stdClass|null —The converted element as object
BasketToPdf()
Create pfd file from basket
public
static BasketToPdf(string $id, string $body[, string $name = 'rechnung.pdf' ]) : Result
Parameters
- $id : string
-
The basket id
- $body : string
-
The html body
- $name : string = 'rechnung.pdf'
Return values
Result —The result object
BasketToPdfEncryped()
Create encrypted pfd file from basket
public
static BasketToPdfEncryped(int $id, string $body) : Result
Parameters
- $id : int
-
The basket id
- $body : string
-
The html body
Return values
Result —The result object
CalculateFolderSize()
Calculate size of a specific folder use a recursive working function to calculate a folder size
public
static CalculateFolderSize(string $folder) : array<string|int, mixed>
Parameters
- $folder : string
-
The path to calculate the size of
Return values
array<string|int, mixed> —A assoc structure holding the folder information
CallExecutable()
Execute a system command Uses installed executable to perform a system call
public
static CallExecutable(string $cmd[, string $folder = '' ][, string $outfile = '' ]) : Result
Parameters
- $cmd : string
-
The command to execute
- $folder : string = ''
-
The working directory
- $outfile : string = ''
-
Optional output file of the call result
Return values
Result —A system result object
CallHook()
Call hook
public
static CallHook(string $name[, mixed|Result|BaseContent &$returns = false ][, mixed|BaseContent &$parameter = null ]) : bool
Calls the interfaces and plugins that are registered on this hook
Available system hooks are:
OnClearAllCache Called when all system caches are cleared at once, has no given argument
OnIndex Called in search index cron job. Has a reference to the job and the list of indexed elements. $parameter contains the content type (ct), the list of changes (list) and the name of the plugin (handler)
OnNewIndex Called in Cache::RecreateIndex with list of files inside the storage folder.
OnSyncronize Called on sync. Gets the list of changed files based on the history buffer. Arguments are similar to OnNewIndex.
RequestOnUrlParsed Called in request constructor, can be used to modify the request itself and the parsed url. Has a reference to the request and the parsed url
OnGetEntityAttributes Called in entity attribute loader. Can be used to modify the whole entity object e.g. add custom fields or tabs.
OnLoadEntityFormPreset Called when using the widget method to get a content type preset. Call is Widget::loadEntityFormPreset $returns is the parsed content type object with resolved attributes.
OnRegisterWidgetIncludes Called on TemplateEngine::renderExtension. Gets as argument the includes list in $param->returns
OnBasketLoadFieldPresetStatus Called in Basket::LoadFieldPresetStatus. Gets as argument the list of available status switches in $param->returns These include a label, value and a set of fields
OnDeleteContent Called in BaseContent when successfully deleted. Gets a reference to the status object and the deleted object. State is referenced in $returns, the deleted object in $parameter
OnAddOrUpdateContent Called in BaseContent when successfully updated or, created. Gets a reference to the status object and the object. State is referenced in $returns, the changed object in $parameter
OnBeforeAddOrUpdateContent Called in base content right before the saver operation State is referenced in $returns, the changed object in $parameter
OnBeforeUserAdminSave Called before saving user data. Gets a reference to the user data payload and a result object.
OnAfterUserAdminSave Called after saving user data. Gets a reference to the user, extras and the payload.
OnUserAdminLoad Called in users widget, when loading own user data (loadSingle). Gets return data and the widget as argument. $returns contains the plain user object, $parameter is a reference to the user widget.
OnUserOwnLoad Called in users widget, when loading own user data (LoadOwn, SendGoogleAuthMail). Gets return data and the widget as argument. $returns contains the plain user object, $parameter is a reference to the user widget.
BasketChangeStatus Hook is called when basket status was changed successfully. $returns contains reference to a system result object. $parameter is an object with the basket instance in key 'basket' and the changes in key 'payload' plus the language
OnBeforeConvertBasketToTask Called right before converting basket to task, has information about the basket and the payload for the new task
OnInitTaskWidget Called in project tasks widget after preparation of data in init call The returns contains an array with the preset data, parameter is the original user request
OnPrepareSiteMapLinks Called in site map generator with returns as result object and $parameter filled with list of links
OnProjectLoadEmployeeRoles Called in project widget when loading employee roles, $returns is the list of roles
OnAfterSendMail Called after successful sending email
OnBeforeResendSendMail Called before sending email to customer (again)
OnAfterPermissionCheck Called in check access to directory, The argument is of type AccessHookArgument, the result a result
OnGetAccessList Called when fetching the user session as last step. Arguments are the response and the user object
OnAfterBasketRegisterUser Called in basket widget after registration of basket is done. Arguments are the result object and an array with user_id and payload as values
OnPreImportContents Called when executing the import cronjob Argument is a file entry after the unzip process
OnRenameFolder Called when renaming the folder by short attribute update or when moving it entirely Called with Result object as return and a FolderMoveHookArgument as parameter
OnDisplay404 Called right before serving the 404 page. Allows the plugins to do some checks before. Argument is the Request object, return is a result object.
OnAddOrUpdateTask Called in task widget on create or update of task Called with Result object as return and a Task as parameter
OnAddService Called on create new service Returns is a result object and param is class with relation and payload
OnCleanupGarbage Called in garbage collect cron job Called with Result object as return and a Job as parameter
OnGetLoginRedirectUrl Called in the getter for the redirect url after successful login Called with Result object as return and the original request url as parameter
OnAfterRelationDelete Called after relation was deleted Called with Result object as return and the combination of relation and content as parameter
OnExecuteSearchUser Call in user search handler Gets the result object nd the search parameters as arguments
OnGetSearchFieldsUser Called after fetch user fields for search The returns argument is the fields of the user
OnUserStatusChange Called after the user active status is change but before saving the user Param is array with user from and target status
OnAfterUserLoginByPassword Called after user password check, param is object with user, credentials and a found indication
OnAfterUserRegisterSession Called after session registration, this is the point where the user is actually logged in Param is the user object.
OnPreUserRegisterSession Called before session registration is done, param is the user object
OnMapArrayIncludes Called after static assets are parsed in template handling Param is the list of links and the result object
OnRenderLoginExtraPre / OnRenderLoginExtra Called on rendering the login template, Response my be usd to add an additional html content
OnAfterRestUserPassword Called after password reset, with arguments result and the user object
OnSearchRelationAttributeList Called in relation attribute search handler when a service related attribute list is queried Parameter is the action with post body payload and the language
OnEmployeeAssignmentStatusChange Called when the assignment status of an employee is changed. Param are the task and the result object
OnBeforeRegisterUser Called on before the user is registered, can be used to modify the user data upfront
OnAfterRegisterUser Called after registration of user was done, param is the user itself
OnBeforeMarkSubscriptionForSwitch Called before users subscription should be changed, param is the user and returns is the result object
OnAfterMarkSubscriptionForSwitch Called when users subscription should be changed, param is the user and returns is the result object
OnMarkSubscriptionForTermination Called when users subscription should be changed, param is the user and returns is the result object
OnNewsletterUserRequiresNotification Called right before new newsletters are queued for a user, the argument is a class with the user and th related newsletter object
OnCronJobRegistered On new cron job from table. Argument is the cron job instance
OnCronJobCompleted On complete cron job from table. Argument is the cron job instance
OnCronJobStarted On start cron job from table. Argument is the cron job instance
OnCronJobProgressChanged Called when the progress was changed and persisted. Argument is the cron job
OnAfterSendMail After email was send, param is the email instance
OnMailRegistered Right after email was registered for sending by cronjob. Param is the email instance
Parameters
- $name : string
-
Name of hook
- $returns : mixed|Result|BaseContent = false
-
Return reference, regularly a Result object
- $parameter : mixed|BaseContent = null
-
Secondary argument, use to add additional information for the call
Return values
bool —ChangeArticleAmount()
Change article amount
public
static ChangeArticleAmount(int $index, int $amount) : Result
This method changes the relation amount in the assigned articles list to the given number. Method will fail when the index is out of boundaries
Parameters
- $index : int
-
The index of the article inside the basket
- $amount : int
-
The new amount, can be either positive or negative
Return values
Result —A system result object
ChangeCurrentDeliveryMethod()
Change delivery method
public
static ChangeCurrentDeliveryMethod(string $method) : Result
Changes the delivery method of the current basket object The given id must match an active registered delivery method and the basket must be registered in the session.
Parameters
- $method : string
-
The new method name
Return values
Result —A system result object
ChangeCurrentPaymentMethod()
Change payment method
public
static ChangeCurrentPaymentMethod(string $method) : Result
Changes the payment method of the current basket object The given id must match an active registered payment method and the basket must be registered in the session.
Parameters
- $method : string
-
The new method name
Return values
Result —A system result object
CheckAddress()
Check address data Validate the given data address components in checkout process
public
static CheckAddress(array<string|int, mixed> $data[, string $type = 'bill' ][, bool $no_mail = false ]) : Result
Parameters
- $data : array<string|int, mixed>
-
The given request payload
- $type : string = 'bill'
-
The address type
- $no_mail : bool = false
-
When true, do not check the email address
Return values
Result —A system result object
CheckoutConfig()
Get the checkout configuration
public
static CheckoutConfig() : object|null
Return values
object|null —Chmod()
Change the permissions of a file
public
static Chmod(string $file, int $octal) : bool
Parameters
- $file : string
- $octal : int
Return values
bool —ClassExists()
Class exists
public
static ClassExists(string $className) : bool
A cached version of class exists to prevent autoloader from starting
Parameters
- $className : string
-
The name of the class
Return values
bool —Status is existing
CleanByRelation()
Delete entity from file system and git repo
public
static CleanByRelation(BaseContent $relation) : Result
This method can delete a content object from our local storage system
Parameters
- $relation : BaseContent
-
The reference to the system content
Return values
Result —A default system result set
ClearCache()
Clear the static cache
public
static ClearCache() : void
Return values
void —CollatorExists()
Check if collators available Test if the ICU collator functions ae available. This function is cached.
public
static CollatorExists() : bool
Return values
bool —True when collator is available
ConfigGetPreset()
Load a config preset Fetch a preset from default system storage location and return it decoded
public
static ConfigGetPreset(string $name[, bool $mode = true ]) : Result
Parameters
- $name : string
-
The preset name
- $mode : bool = true
-
Decode to assoc or boolean
Return values
Result —A system result object
Context()
Get/Set the global context
public
static Context([AppContext|null $context = null ]) : AppContext|Request|CronJob|CommandLineContext
Parameters
- $context : AppContext|null = null
Return values
AppContext|Request|CronJob|CommandLineContext —CopyFile()
Copy file Copy a single file with obtaining lock on index before
public
static CopyFile(string $source, string $target[, bool $override = true ]) : Result
Parameters
- $source : string
-
Absolute path to source
- $target : string
-
Absolute path to target
- $override : bool = true
-
Override forced even if file names are equal
Return values
Result —A system result object
CopyFolder()
Copy folder
public
static CopyFolder(string $source, string $target[, bool $override = true ]) : Result
This method copies the source folder to the target folder path. The folder itself is not copied but all of its contents. This method creates the target folder if it is not present.
Parameters
- $source : string
-
The source folder destination
- $target : string
-
The target folder name
- $override : bool = true
-
Override forced even if file names are equal
Return values
Result —A system result object
CreateEncrypedArchive()
Create an encrypted zip archive
public
static CreateEncrypedArchive(string $pdf_path) : Result
Takes the path and creates a zip archive
Parameters
- $pdf_path : string
-
The absolute path to the source file
Return values
Result —The zip result
CurrentId()
Set the current id or load it
public
static CurrentId([string|null $id = null ]) : string|null
Parameters
- $id : string|null = null
-
The id or null as getter
Return values
string|null —Either the set result or the basket id
DataBase()
public
static DataBase(string $name) : DBAL|null
Parameters
- $name : string
Return values
DBAL|null —Debug()
log debug object writs a formatted log message including back trace to the global log file
public
static Debug(mixed $object) : void
Parameters
- $object : mixed
-
The object to be logged
Return values
void —DecodeJson()
Parse json from string to object or assoc
public
static DecodeJson(string $data[, bool $mode = true ][, array<string|int, mixed>|string|null $crypt = null ]) : Result
Use the json parse function to decode a string to assoc or object It will use the given code in crypt to decrypt or fall back to system key
Parameters
- $data : string
-
The payload to decode
- $mode : bool = true
-
Parse as assoc or object, default is true and therefor assoc array
- $crypt : array<string|int, mixed>|string|null = null
-
The key or, an array with cipher, key and the iv
Return values
Result —A default system result object
DecodeJsonFile()
Parse json from file to object or assoc
public
static DecodeJsonFile(string $path[, bool $mode = true ][, string|null $crypt = null ]) : Result
Use the json parse to fetch text data from a given path and return it as object with assoc or object payload
Parameters
- $path : string
-
The absolute path to a certain storage file
- $mode : bool = true
-
Parse as assoc or object, default assoc
- $crypt : string|null = null
-
Decrypt string before parsing
Return values
Result —A default system result object
DeepDiff()
Deep diff of old and new values
public
static DeepDiff(array<string|int, mixed> &$diffs, string $prefix, array<string|int, mixed> $old, array<string|int, mixed> $new[, null|array<string|int, mixed> $ignore = null ]) : mixed
Parameters
- $diffs : array<string|int, mixed>
-
The list of diffs
- $prefix : string
-
The key prefix
- $old : array<string|int, mixed>
-
The list of current values
- $new : array<string|int, mixed>
-
The list of original values
- $ignore : null|array<string|int, mixed> = null
-
List of fields to ignore
Return values
mixed —DeleteFile()
Deletes single file This method deletes a single file, it will wait when the system is in git lock mode
public
static DeleteFile(string $path) : bool
Parameters
- $path : string
-
The target file path
Return values
bool —True on success otherwise false
DeliveryMethod()
Get delivery method Load a method instance and fetch a legacy configuration on top on demand
public
static DeliveryMethod(string $name[, string $version = null ]) : DeliveryMethod
Parameters
- $name : string
-
The method name
- $version : string = null
-
A git hash with the used delivery method version
Return values
DeliveryMethod —The delivery method or null
DeliveryMethodList()
Get method list Get the list of registered delivery method handlers
public
static DeliveryMethodList() : array<string|int, DeliveryMethod>
Return values
array<string|int, DeliveryMethod> —A list of registered handlers
DropFolder()
Delete a full folder
public
static DropFolder(string $folder[, bool $full = false ]) : array<string|int, mixed>
this method clears or delete a folder recursively, side effect will fill list of delete folders and files
Parameters
- $folder : string
-
The path to delete
- $full : bool = false
-
Also remove the root folder
Return values
array<string|int, mixed> —List of deleted folders and files
EncodeJson()
Serialize a given input to json representation
public
static EncodeJson(mixed $data[, int $mode = JSON_PRETTY_PRINT ][, array<string|int, mixed>|string|null $crypt = null ]) : Result
use the json parse function to decode an assoc or object
Parameters
- $data : mixed
-
The payload to encode
- $mode : int = JSON_PRETTY_PRINT
-
Serialize readable or not formatted
- $crypt : array<string|int, mixed>|string|null = null
-
Encrypt key or, array with key cipher and iv
Return values
Result —A default system result object
ExtractAttributeNames()
Get attribute names
public
static ExtractAttributeNames(string $type_id[, string|null $language = FAA_DEFAULT_LANGUAGE ][, string|null $prefix = null ]) : array<string|int, mixed>
Get just the list of translated attributes of a content type. This method is cached locally.
Parameters
- $type_id : string
-
Name of the type to resolve
- $language : string|null = FAA_DEFAULT_LANGUAGE
-
Translate language
- $prefix : string|null = null
Return values
array<string|int, mixed> —The list of attributes
ExtractAttributeOptions()
Get translated options list of attribute
public
static ExtractAttributeOptions(string $type_id, string $attribute_name[, string|null $language = null ][, int|string $table_index = -1 ]) : Result
Extract list of labels from a certain attribute from a certain content type. This method is cached in static context of this class.
Parameters
- $type_id : string
-
The content type id
- $attribute_name : string
-
The target attribute name
- $language : string|null = null
-
The language to translate for, when given default "__" the item labels are not resolved
- $table_index : int|string = -1
-
The index in the table heads. may be -1 for regular resolve, can be a string as well
Return values
Result —A system result object
ExtractCountryCode()
Extract some country code from address object data
public
static ExtractCountryCode(array<string|int, mixed>|null $address) : string|null
Parameters
- $address : array<string|int, mixed>|null
Return values
string|null —ExtractCountryName()
Extract some country code from address object data
public
static ExtractCountryName(array<string|int, mixed>|object|null $address, string $language[, string $field = 'name' ]) : string|null
Parameters
- $address : array<string|int, mixed>|object|null
-
The address object
- $language : string
-
The target language
- $field : string = 'name'
Return values
string|null —ExtractExtension()
Extract file extension
public
static ExtractExtension(string $path) : bool|string
May return false if no extension could be found
Parameters
- $path : string
-
A complete file path
Return values
bool|string —The file extension or, false if not matched
ExtractFileName()
Extract file name
public
static ExtractFileName(string $path[, bool $without_extension = false ]) : string
Parameters
- $path : string
-
A complete file path
- $without_extension : bool = false
Return values
string —The file name
ExtractFolder()
Extract folder path from root
public
static ExtractFolder(string $path) : string
With input /var/www/school/test.json will result in /var/www/school/
Parameters
- $path : string
-
A complete file path
Return values
string —The file root folder
ExtractFolderName()
Extract folder name from root
public
static ExtractFolderName(string $path) : string
Parameters
- $path : string
-
A complete file path
Return values
string —The file root folder
ExtractPrimaryRelationType()
Extract the primary type from an object attribute relation
public
static ExtractPrimaryRelationType(object $attr[, bool $must_be_single = true ]) : string|null
Parameters
- $attr : object
- $must_be_single : bool = true
Return values
string|null —FetchCountries()
Get list of countries
public
static FetchCountries([string|null $language = null ]) : Result
Parameters
- $language : string|null = null
-
Language for result
Return values
Result —The search result
FileExists()
Check if file exists
public
static FileExists(string $fileName[, bool $caseSensitive = true ]) : bool|string
Does check if a file is existing, will also check if the file exists as lower case by glob as fallback.
Parameters
- $fileName : string
-
The path to the file
- $caseSensitive : bool = true
-
Use case-sensitive path, defaults to true
Return values
bool|string —File exists
FilterFolderFilesByModificationTime()
Get a list of files that are either older or newer a certain time point
public
static FilterFolderFilesByModificationTime(string $root, int $timestamp[, bool $older = true ]) : Result
Parameters
- $root : string
-
The start point for the recursion
- $timestamp : int
-
The time point to flip
- $older : bool = true
-
When true result list files are older than the time stamp otherwise newer
Return values
Result —A system result object containing the files
FilterListAssoc()
filter result list does a quick filtering in the given list, this method operates language independent results will be specified using a strpos() operation
public
static FilterListAssoc(array<string|int, BaseContent> $list, array<string|int, mixed> $filters[, string $language = '' ]) : array<string|int, BaseContent>
Parameters
- $list : array<string|int, BaseContent>
-
A array of system objects
- $filters : array<string|int, mixed>
-
The search filters with value and matcher type
- $language : string = ''
-
The language to search in
Return values
array<string|int, BaseContent> —A list of system content objects
FilterTypeListAssoc()
filter result list by type does a quick filtering in the given list, this method operates language independant results will be determinated using a strpos() operation
public
static FilterTypeListAssoc(string $type, array<string|int, mixed> $filters[, string $language = '' ]) : Result
Parameters
- $type : string
-
A array of system object types or a string with a single type name
- $filters : array<string|int, mixed>
-
The search parameter
- $language : string = ''
-
The language to search in
Return values
Result —A result objects with found values
FindCountry()
public
static FindCountry(string $code) : Country|null
Parameters
- $code : string
Return values
Country|null —FormatPrice()
Format a price
public
static FormatPrice(array<string|int, mixed>|null $price[, int|float $count = 1 ][, bool $tax = false ][, string $dec = ',' ][, string $tho = '.' ]) : string
Parameters
- $price : array<string|int, mixed>|null
-
The price as number
- $count : int|float = 1
-
The amount of items, can be a float as well for certain goods
- $tax : bool = false
-
The tax level is included?
- $dec : string = ','
-
Decimal separation
- $tho : string = '.'
-
Thousands separation
Return values
string —The number_format of the given price
FormattedId()
expose the formatted object id provide an interface to extract the current id with formatting options
public
static FormattedId(int $id, string $prefix[, string $pad_string = '0' ][, int $pad_length = 5 ][, int $pad_type = STR_PAD_LEFT ]) : string
Parameters
- $id : int
-
A object id
- $prefix : string
-
A prefix
- $pad_string : string = '0'
-
The pad character
- $pad_length : int = 5
-
The padding length
- $pad_type : int = STR_PAD_LEFT
-
The padding type
Tags
Return values
string —The formatted id
GenerateUUIDv4()
Generate an unique id
public
static GenerateUUIDv4() : string
Return values
string —GetActiveLanguages()
Get active languages
public
static GetActiveLanguages() : array<string|int, mixed>|null
Create a list of active languages and return as array of strings. This method is cached locally
Return values
array<string|int, mixed>|null —The active language keys
GetArticleStock()
Get available amount in all storage locations for certain article
public
static GetArticleStock(string $id[, string $type = 'article' ]) : float|int|null
Parameters
- $id : string
-
The article primary key
- $type : string = 'article'
-
The type foreign key
Return values
float|int|null —GetAssignableEntityTypes()
Get entity type set of assignable contents
public
static GetAssignableEntityTypes([string|null $language = null ][, bool $plain = false ]) : Result
Load the list of registered system content types that have tha assignable flag. The list can be either objects or simple names of types. This method is cached.
Parameters
- $language : string|null = null
-
The language code or null for raw view
- $plain : bool = false
-
When true, return only names of the elements
Return values
Result —A system result object
GetChildTypes()
Get types and subtypes form storage
public
static GetChildTypes(array<string|int, mixed>|string $typename) : Result
load the list of registered and related object types This method is cached
Parameters
- $typename : array<string|int, mixed>|string
-
A system type name or, a list of names
Return values
Result —A system result object
GetClassNames()
List classes in folder Fetch a list of classes inside the folder
public
static GetClassNames(array<string|int, mixed> $paths[, string|null $ignore = null ]) : array<string|int, mixed>
Parameters
- $paths : array<string|int, mixed>
-
List of paths to search
- $ignore : string|null = null
-
A regular expression to filter
Return values
array<string|int, mixed> —A list of class names found in the folder
GetCurrent()
Get current basket object
public
static GetCurrent([bool $create_on_demand = false ]) : Basket|null
Parameters
- $create_on_demand : bool = false
Return values
Basket|null —GetEntityAttributes()
Get entity form attributes
public
static GetEntityAttributes(string $typeName[, string|null $language = null ][, bool $parent_resolve = false ][, array<string|int, mixed> $recurse = array() ][, bool $skip_attributes = false ][, bool $skip_hook = false ]) : Result
Load the attribute set of a certain object type Will resolve parent attributes and tas as well, when defined
Parameters
- $typeName : string
-
The content type key
- $language : string|null = null
-
The language code or null for raw view
- $parent_resolve : bool = false
-
When true, resolve with parents
- $recurse : array<string|int, mixed> = array()
-
List of called parent object types
- $skip_attributes : bool = false
-
When set to true we skip attributes
- $skip_hook : bool = false
-
When set to true we skip the hook calls
Return values
Result —A system result object
GetEntityTypes()
Get entity type set
public
static GetEntityTypes([string|null $language = null ][, bool $skip_attributes = false ][, bool $with_parent = false ]) : Result
Load the list of registered system content types
Parameters
- $language : string|null = null
-
The language code or null for raw view
- $skip_attributes : bool = false
-
Skip attributes when true
- $with_parent : bool = false
-
Resolve with parents
Return values
Result —A system result object
GetLock()
Obtain lock try to obtain the lock indicated by lock file in var
public
static GetLock() : Result
Return values
Result —A default system result object
GetMailSetup()
Get a setup object
public
static GetMailSetup(string $name, string|null $language) : Result
Get a email setup instance by given name
Parameters
- $name : string
-
The name of the requested preset
- $language : string|null
-
Base language
Return values
Result —A system result object
GetNextOfSequence()
Interface function to get a set of ids
public
static GetNextOfSequence(string $type) : Result
Parameters
- $type : string
-
The system object type
Return values
Result —A result object with a numeric unique id as payload
GetObjectDirect()
Get entity instance
public
static GetObjectDirect(int|string|null $id, string $type[, string|null $hash = '' ]) : BaseContent|null
Load the full object of a certain object type identified by id, only available for not named object types. Can fetch versions of the object. Will return null in case of error.
Parameters
- $id : int|string|null
-
The object id
- $type : string
-
The object type
- $hash : string|null = ''
-
When set the system will try to fetch a certain version of the object from storage
Return values
BaseContent|null —The content instance or, null
GetObjectLock()
public
static GetObjectLock(BaseContent $content) : bool
Parameters
- $content : BaseContent
Return values
bool —GetRawMailSetup()
Get a setup object Get a email setup instance by given name
public
static GetRawMailSetup(string $name, string $language) : EmailSetup
Parameters
- $name : string
-
The name of the requested preset
- $language : string
-
Base language
Return values
EmailSetup —The email setup or null
GetRawObject()
Get entity form storage
public
static GetRawObject(string|int $id, string|array<string|int, string> $type) : Result
Load the attributes of a certain object type identified by id
Parameters
- $id : string|int
-
The object id
- $type : string|array<string|int, string>
-
The object type
Return values
Result —A default system result object
GetRawObjectDirect()
Get raw entity form storage Load the full object of a certain object type identified by id, only available for not named object types
public
static GetRawObjectDirect(int|string|null $id, string $type[, string|null $hash = '' ][, bool $tolerate_error = true ]) : Result
Parameters
- $id : int|string|null
-
The object id
- $type : string
-
The object type
- $hash : string|null = ''
-
When set the system will try to fetch a certain version of the object from storage
- $tolerate_error : bool = true
-
Tolerate missing version reference
Return values
Result —A default system result object
GetRelatedTypes()
Get plain list of related types (top and down)
public
static GetRelatedTypes(string $typename) : Result
Parameters
- $typename : string
-
The key of the type
Return values
Result —A system result object when found, with array of types in payload
GetSortKey()
Calculate the sort key Using the ICU collator to create a sort key representation of the given string.
public
static GetSortKey(string $text[, string $collation = FAA_LOCALE ][, bool $encode = false ]) : Result
Parameters
- $text : string
-
The text to convert to sort key
- $collation : string = FAA_LOCALE
-
The collation to use for convert e.g. en_US or, de
- $encode : bool = false
-
When set to true, convert the sort key to urlencoded representation
Return values
Result —A default system result object
GetTranslation()
get translations fetch translation data from storage or add on demand
public
static GetTranslation(string $data, string $l[, string $type = 'code' ][, string $src = '' ]) : string
Parameters
- $data : string
-
Pointer to text for translation
- $l : string
-
Language code
- $type : string = 'code'
-
Type of translation
- $src : string = ''
-
Relative path to source file
Return values
string —GetTranslationObject()
Fetch translation Load a single translation instance
public
static GetTranslationObject(string $id) : Translation
Parameters
- $id : string
-
Object id
Return values
Translation —A system translation object or null
GetType()
Get certain content type by name
public
static GetType(string $typename) : Type|null
Parameters
- $typename : string
-
The key of the type
Return values
Type|null —The resolved type object or null when not found
GetTypeClassPath()
Get path to class
public
static GetTypeClassPath(string $typeName[, bool $system = false ]) : string
Resolve the path to a certain content type, either to a system or a additional type
Parameters
- $typeName : string
-
Name of the content type
- $system : bool = false
-
When true search in system path
Return values
string —GzCompressFile()
GZIPs a file on disk (appending .gz to the name)
public
static GzCompressFile(string $source[, int $level = 9 ][, bool $clean = true ][, scalar $suffix = null ]) : Result
From http://stackoverflow.com/questions/6073397/how-do-you-create-a-gz-file-using-php Based on function by Kioob at: http://www.php.net/manual/en/function.gzwrite.php#34955
Parameters
- $source : string
-
Path to file that should be compressed
- $level : int = 9
-
GZIP compression level (default: 9)
- $clean : bool = true
-
Clean source file after compression (default: true)
- $suffix : scalar = null
-
Additional suffix for the target
Return values
Result —A default system result object
HtmlToPdf()
Convert html to pdf
public
static HtmlToPdf(string $target_path, string $body, string $name[, bool $crypt = false ]) : Result
Convert the given html body to pdf file, uses wkhtmltopdf In case of a encryption needed a zip archive will be wrapped around. Next to the output target the password will be generated into a file
Parameters
- $target_path : string
-
Output storage path
- $body : string
-
The html to render to pdf
- $name : string
-
Name of the output file
- $crypt : bool = false
-
Save as encrypted version
Return values
Result —A default system result object
IdToHex()
Convert an id to hexadecimal array with last 2 parts as value
public
static IdToHex(int $id[, bool $reverse = true ]) : array<string|int, mixed>|null
For example 5126 = 1406 will result in [6, 6] When set to reverse false it returns [1, 4]
Parameters
- $id : int
-
The id to convert
- $reverse : bool = true
-
When set to false the first parts will return
Return values
array<string|int, mixed>|null —IdToPath()
Convert id to path Convert the given numeric id to absolute path
public
static IdToPath(int $id, string $type[, string $root = FAA_PATHS_DATAABS ][, bool $mkdir = true ][, bool $reverse = true ][, bool $wrapping = false ]) : string
Parameters
- $id : int
-
A content id
- $type : string
-
The content type
- $root : string = FAA_PATHS_DATAABS
-
The data root folder, defaults is system data storage folder
- $mkdir : bool = true
-
Create directory on demand
- $reverse : bool = true
-
When set to false the first parts will return (old format)
- $wrapping : bool = false
-
Add the id itself asi last segment
Return values
string —The absolute folder path
indexSort()
public
static indexSort(mixed $a, mixed $b) : mixed
Parameters
- $a : mixed
- $b : mixed
Return values
mixed —IsBase64()
Guess if string is base64 will try to guess if the given string is base64
public
static IsBase64(string $string[, bool $simple = true ]) : bool
Parameters
- $string : string
-
The string to check
- $simple : bool = true
-
Use a simple method to check the given content with fallback to complex check
Return values
bool —True on success otherwise false
IsEmptyDir()
Is empty folder
public
static IsEmptyDir(string $dir) : bool|null
Parameters
- $dir : string
-
Path to folder
Return values
bool|null —KnownPlugins()
Get the known plugins
public
static KnownPlugins() : array<string|int, Plugin>
Return values
array<string|int, Plugin> —ListEntries()
list generic objects Read a list of groups from local storage Uses the generic object load to get the entry list
public
static ListEntries([string|null $dir = null ][, string|array<string|int, mixed> $types = 'generic' ][, string|null $language = null ][, bool $raw = false ]) : Result
Parameters
- $dir : string|null = null
-
Absolute path to source dir or, null
- $types : string|array<string|int, mixed> = 'generic'
-
The requested object type or a list of types
- $language : string|null = null
-
The language code or null for not translated view
- $raw : bool = false
-
Return entries as raw objects or normalized
Return values
Result —A default system result set
ListFiles()
list files Iterate over directory and list the found files
public
static ListFiles(string $dir[, string $ext = '/^json$/' ][, bool $full = false ]) : array<string|int, mixed>
Parameters
- $dir : string
-
The root folder path to search in
- $ext : string = '/^json$/'
-
Filter by extension (can be empty, a string or a regex)
- $full : bool = false
-
Check the full name of the file or just the extension when false
Return values
array<string|int, mixed> —A list containing the found files
ListFolders()
List folder names in certain root folder
public
static ListFolders(string $path) : array<string|int, mixed>
Parameters
- $path : string
-
The absolute path to the folder
Return values
array<string|int, mixed> —The found folder names that are children of the given folder
ListIdFiles()
find file ids find a list of file ids inside a folder and its sub directories
public
static ListIdFiles(string $dir[, string $ext = 'json' ][, bool $to_int = true ]) : array<string|int, mixed>
Parameters
- $dir : string
-
The root folder path to search in
- $ext : string = 'json'
-
Filter by extension
- $to_int : bool = true
-
Convert to integer when set to true
Return values
array<string|int, mixed> —A list containing the found id's
ListVoucherPresets()
Fetch voucher presets
public
static ListVoucherPresets([string|null $language = null ]) : array<string|int, mixed>
Parameters
- $language : string|null = null
-
A language id
Return values
array<string|int, mixed> —The list
LoadTypesWithRelatedContentAttribute()
Get list of types that have an certain relation attribute
public
static LoadTypesWithRelatedContentAttribute(string $base_relation[, bool $include_childs = true ][, string|null $language = null ]) : Result
This function loads all content types that have an attribute which contains defined as relation. For example in case of asset shop articles or news with a main image or a list of images.
Parameters
- $base_relation : string
-
The searched type
- $include_childs : bool = true
-
When true, include child types
- $language : string|null = null
-
The resolver target language
Return values
Result —A system result object with list of asset containing objects
Log()
log object writs a formatted log message including back trace to the global log file
public
static Log(mixed $object[, string|null $msg = null ]) : void
Parameters
- $object : mixed
-
The object to be logged
- $msg : string|null = null
-
Additional message
Return values
void —MemoryBytesReadable()
Memory readable Convert size of bytes in human-readable units
public
static MemoryBytesReadable(int|float $size) : string
Parameters
- $size : int|float
-
The size in bytes
Return values
string —The calculated size
MergePdfFiles()
Merge some pdf files
public
static MergePdfFiles(array<string|int, mixed> $files, string $name) : Result
Takes the given list, merges them together and writes it to the assets folder
Parameters
- $files : array<string|int, mixed>
-
The files to merge
- $name : string
-
The target name
Return values
Result —The merge result
MimeType()
Get mime type of file
public
static MimeType(string $file) : string|bool
Parameters
- $file : string
-
The absolute file path
Return values
string|bool —The mime type of the file or, false if not resolvable
MkFolder()
Create folder path
public
static MkFolder(string $root, array<string|int, mixed> $components[, bool $make = true ]) : string|null
When the make argument set to true this function will try to create the folder Return the folder components without root part
Parameters
- $root : string
-
The path to the base folder
- $components : array<string|int, mixed>
-
The list of folder components
- $make : bool = true
-
Try to create the folder
Return values
string|null —The combined relative path as string, includes tailing /
Open()
Open a basket by id
public
static Open(int|string $id[, bool $locked = false ]) : Basket|null
Parameters
- $id : int|string
-
The basket id
- $locked : bool = false
-
Lock the basket for this process
Return values
Basket|null —OpenArticle()
Open article by id
public
static OpenArticle(string $id[, string|null $type = null ]) : Article|null
Parameters
- $id : string
-
The article primary key
- $type : string|null = null
-
The type foreign key when set to null the loader will try to find the article manually
Return values
Article|null —OpenByRoomBooking()
public
static OpenByRoomBooking(string $room_id, string $article_id) : Basket|null
Parameters
- $room_id : string
- $article_id : string
Return values
Basket|null —OpenService()
public
static OpenService(string $id[, string|null $type = null ]) : Service|null
Parameters
- $id : string
- $type : string|null = null
Return values
Service|null —OpenVoucher()
Open a single voucher preset
public
static OpenVoucher(string $id) : Voucher|null
Parameters
- $id : string
Return values
Voucher|null —OSName()
public
static OSName() : string
Return values
string —PaymentMethod()
Get payment method Load a method instance
public
static PaymentMethod(string $name) : PaymentMethod|null
Parameters
- $name : string
-
The method name
Return values
PaymentMethod|null —The payment method or null
PaymentMethodList()
Get method list Get the list of registered payment method handlers
public
static PaymentMethodList() : array<string|int, PaymentMethod>
Return values
array<string|int, PaymentMethod> —A list of registered handlers
Plugin()
Get plugin
public
static Plugin(string $name) : Plugin|null
Get one of the registered plugins. This function uses the cache
Parameters
- $name : string
-
Get plugin instance
Return values
Plugin|null —A plugin instance or null when not registered
ReadCsv()
Read a CSV file to local storage
public
static ReadCsv(string $path[, string $delimiter = ';' ][, string $enclosure = "'" ][, int $length = 100000 ][, string $escape = "\" ][, bool $check_head = true ]) : Result
Fetch the file and add it to a local result object file is parsed with php function to get csv from file, arguments of this methods align with official one
Parameters
- $path : string
-
The absolute path to file to open
- $delimiter : string = ';'
-
Have a look at http://php.net/manual/de/function.fgetcsv.php delimiter
- $enclosure : string = "'"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php enclosure
- $length : int = 100000
-
Have a look at http://php.net/manual/de/function.fgetcsv.php length
- $escape : string = "\"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php escape
- $check_head : bool = true
-
When set, check the first line as head and validate following line lengths
Return values
Result —A system result object
ReadFile()
Read a single file
public
static ReadFile(string $path) : Result
Parameters
- $path : string
-
The absolute path to a certain storage file
Return values
Result —A default system result object
ReadFixedColumnFile()
Read file with fixed column width
public
static ReadFixedColumnFile(string $path[, int $length = 10000 ]) : Result
Automatic file parser based on the heads and assuming a " " space is used to make the cols equal
Parameters
- $path : string
-
Absolute link to the file to open
- $length : int = 10000
-
Limiter for line length
Return values
Result —A system result object
ReadFolder()
Read folder
public
static ReadFolder(string $dir) : array<string|int, File>
Will list all files and folders of a folder
Parameters
- $dir : string
-
Path to root folder
Return values
array<string|int, File> —An array of file objects
RegisterBaseObject()
Register a basic content object by type Create a content object
public
static RegisterBaseObject(string $type[, Array|array<string|int, string> $base_type = null ]) : Result
Parameters
- $type : string
-
The content type name, lowercase
- $base_type : Array|array<string|int, string> = null
-
Alternative list of filter content types or a string with the root type
Return values
Result —A default system result object
RegisterContentType()
Register a new content type
public
static RegisterContentType( $payload) : Result
Creates a new content type preset element This method is capable of creation internal or additional content type presets. It will generate the basic code part and the structure json.
Parameters
Return values
Result —A system result object
RemoveFieldsFromType()
Remove fields from type
public
static RemoveFieldsFromType(object $type, array<string|int, mixed> $fields) : void
Remove some fields from the element type e.g. when inherited from parent.
Parameters
- $type : object
-
A simplified object type data set
- $fields : array<string|int, mixed>
-
A list of fields to remove
Return values
void —RemoveItemFromCurrent()
Delete article from basket
public
static RemoveItemFromCurrent(int $index) : Result
Removes the element by index from array of articles and calls the object saver afterwards. Method will fail when the index is out of boundaries
Parameters
- $index : int
-
The index of the article inside the basket
Return values
Result —A system result object
RenameFolderOrFile()
Rename folder or file
public
static RenameFolderOrFile(string $source, string $target[, bool $skip_existing = true ]) : Result
Parameters
- $source : string
-
Absolute path to source
- $target : string
-
Absolute path to target
- $skip_existing : bool = true
Return values
Result —A system result object
ResolveCountryCode()
Get country iso code by id.
public
static ResolveCountryCode(string|null $id[, string $attribute = 'code' ][, string|null $lang = null ]) : string|null
Should be an upper case wit standard (ISO 3166)
Parameters
- $id : string|null
-
The country uuid
- $attribute : string = 'code'
- $lang : string|null = null
Return values
string|null —The found code or, null
ResolvedTypeFamily()
Get resolved family list of types
public
static ResolvedTypeFamily(string $root[, string|null $language = null ]) : Result
Parameters
- $root : string
-
Name of the root type to resolve
- $language : string|null = null
-
The language to resolve for
Return values
Result —A system result object
resolveSubType()
Resolve a sub type using the given preset definition
public
static resolveSubType(Result|null &$res, string|array<string|int, string> $hide_child_fields, string $direct_relation_type[, string|null $language = null ][, bool $parent_resolve = true ][, array<string|int, mixed> $recurse = array() ][, bool $skipattributes = false ][, bool $skiphook = false ]) : stdClass|null
Parameters
- $res : Result|null
-
The Result object
- $hide_child_fields : string|array<string|int, string>
-
List of fields to hide
- $direct_relation_type : string
-
The name of the type
- $language : string|null = null
-
The language to resolve for
- $parent_resolve : bool = true
-
With parent attributes
- $recurse : array<string|int, mixed> = array()
-
Recursion depth tester
- $skipattributes : bool = false
-
Skip resolving of attributes
- $skiphook : bool = false
-
Skip hooks
Return values
stdClass|null —The parse content type
ResolveVoucherByCode()
public
static ResolveVoucherByCode(string $code) : Result
Parameters
- $code : string
Return values
Result —RevokeLock()
release lock try to release the lock indicated by lock file in var
public
static RevokeLock([string|null $lockfile = null ][, bool $in_memory = true ]) : Result
Parameters
- $lockfile : string|null = null
- $in_memory : bool = true
Return values
Result —A default system result object
RevokeObjectLock()
public
static RevokeObjectLock(BaseContent $content) : Result
Parameters
- $content : BaseContent
Return values
Result —SelfLockedOrOpen()
public
static SelfLockedOrOpen( $pid[, $path = null ]) : bool
Parameters
Return values
bool —StoreEncodedJson()
Serialize a given input and store it
public
static StoreEncodedJson(string $path, mixed $data[, int $mode = JSON_PRETTY_PRINT ][, bool|null $crypt = false ]) : Result
use the json parse function to create json representation and store it in a certain file this method does an encryption also on demand, the .key file must exist for this to happen
Parameters
- $path : string
-
The target file path
- $data : mixed
-
The payload to encode
- $mode : int = JSON_PRETTY_PRINT
-
Serialize readable or not formatted
- $crypt : bool|null = false
-
Encrypt the result after serialisation
Return values
Result —A default system result object
StripQueryAndAnchor()
Extract file name
public
static StripQueryAndAnchor(string $path) : string
Parameters
- $path : string
-
A complete file path
Return values
string —The file name without additional parts
SysLog()
Log message
public
static SysLog(string $level, mixed $object[, string|null $prefix = null ][, bool $stack = true ]) : bool
Writs a formatted log message including back trace on severe levels to the global log file
Parameters
- $level : string
-
Name of the log level
- $object : mixed
-
The object to be logged
- $prefix : string|null = null
-
Extra prefix
- $stack : bool = true
-
Print with stack trace on demand
Return values
bool —Status if write to log worked
SystemInformation()
Get system information
public
static SystemInformation(Response $response) : void
Parameters
- $response : Response
Return values
void —TailLogfile()
tail a log file get set of lines inside a logfile
public
static TailLogfile(string $path[, int $max = 200 ][, int $buffer = 4096 ]) : Result
Parameters
- $path : string
-
The target log file path
- $max : int = 200
-
Maximum buffer length of array
- $buffer : int = 4096
-
Maximum buffer length of line characters
Return values
Result —A default system result object
TranslateArticleUnit()
public
static TranslateArticleUnit(string|null $value[, string|null $language = null ]) : string|stdClass|null
Parameters
- $value : string|null
- $language : string|null = null
Return values
string|stdClass|null —TranslateAttributeName()
public
static TranslateAttributeName(string $type_id, $attribute[, string $language = FAA_DEFAULT_LANGUAGE ][, null $prefix = null ]) : mixed|null
Parameters
Return values
mixed|null —TranslateAttributeOption()
Translate a single option by value
public
static TranslateAttributeOption(string $type_id, string $attribute_name, string|array<string|int, string> $value[, string|null $language = null ][, int|string $table_index = -1 ]) : string|null|stdClass
Parameters
- $type_id : string
-
The content type id
- $attribute_name : string
-
The target attribute name
- $value : string|array<string|int, string>
-
The value to translate
- $language : string|null = null
-
The language to translate for, when given default "__" the item labels are not resolved
- $table_index : int|string = -1
-
The index in the table heads. may be -1 for regular resolve, can be a string as well
Return values
string|null|stdClass —The translated attribute option or when no language was given the object label
TranslateSalutation()
Translate salutation
public
static TranslateSalutation(string|null $value[, string|null $language = null ]) : string|stdClass|null
Translate the given salutation key to the target language
Parameters
- $value : string|null
-
The salutation key
- $language : string|null = null
-
The target language
Return values
string|stdClass|null —The translated salutation or null
TryGetLock()
public
static TryGetLock([string|null $path = null ][, string|int|null $pid = null ][, int $try_count = FAA_WRITE_RETRY ][, float $seconds = 0.25 ][, bool $in_memory = true ]) : bool
Parameters
- $path : string|null = null
- $pid : string|int|null = null
- $try_count : int = FAA_WRITE_RETRY
- $seconds : float = 0.25
- $in_memory : bool = true
Return values
bool —TryUnLock()
Unlock try to disable the lock indicated by lock file in var
public
static TryUnLock([string|null $path = null ]) : bool
Parameters
- $path : string|null = null
-
Path to lock file to obtain lock at
Return values
bool —A default system result object
TypeExists()
Check if content type exists and return path to definition file
public
static TypeExists(string $typeName) : string|null
Parameters
- $typeName : string
Return values
string|null —UnlinkCurrent()
Unlink basket in session
public
static UnlinkCurrent() : Result
Return values
Result —Unzip()
Unzip a file
public
static Unzip(string $file[, string|null $target = null ][, bool $chunks = false ]) : Result
Take the archive, unzip it and place the results in the defined folder or an automated one
Parameters
- $file : string
-
Absolute path to file
- $target : string|null = null
-
The output folder or, null for dynamic one
- $chunks : bool = false
Return values
Result —The unzip result
UpdateCurrentAddress()
Update a basket address Update the bill or delivery address of the current basket
public
static UpdateCurrentAddress(string $type, array<string|int, mixed> $address) : Result
Parameters
- $type : string
-
The address type, either bill or delivery
- $address : array<string|int, mixed>
-
New address values, defined in address content type
Return values
Result —A system result object
UpdateEntity()
update object apply changes to a certain object using the given change data set
public
static UpdateEntity(BaseContent|null &$entity, array<string|int, mixed> $data[, bool|string $validate = false ]) : Result
Parameters
- $entity : BaseContent|null
-
A system object ob base content or children
- $data : array<string|int, mixed>
-
An associative array containing the values for update
- $validate : bool|string = false
-
Interpret results with attribute rules
Return values
Result —A system result object
UUIdToPath()
Convert uuid to path Convert the given uuid in version 4 to absolute path
public
static UUIdToPath(string $id, string $type[, string $root = FAA_PATHS_DATAABS ][, bool $mkdir = true ][, bool $wrapping = false ]) : string
Parameters
- $id : string
-
A content unique id (uuid v4)
- $type : string
-
The content type
- $root : string = FAA_PATHS_DATAABS
-
The data root folder, defaults is system data storage folder
- $mkdir : bool = true
-
Create directory on demand
- $wrapping : bool = false
-
Add the id itself asi last segment
Return values
string —The absolute folder path
Version()
public
static Version() : string
Return values
string —VersionStringToNumber()
Convert version number Converts the given number to a unified string e.g. 'v1.234.33' will become 102340033
public
static VersionStringToNumber(string $number[, string $regex = '/[^0-9\.]/i' ][, string $replace = '' ][, int $pads = 4 ]) : string
Parameters
- $number : string
-
The version number to calculate
- $regex : string = '/[^0-9\.]/i'
-
Replacement expression to clear the number upfront
- $replace : string = ''
-
Replacement string for regex_replace
- $pads : int = 4
-
Add this amount of zeros to the left
Return values
string —The cleared version number
Warn()
warn level log object writs a formatted log message including back trace to the global log file
public
static Warn(mixed $object[, bool $stack = true ]) : void
Parameters
- $object : mixed
-
The object to be logged
- $stack : bool = true
Return values
void —WriteCsv()
Write a array of entries to csv file
public
static WriteCsv(string|null $path, array<string|int, mixed> $list[, string $delimiter = ';' ][, string $enclosure = "'" ][, string $escape = "\" ]) : Result
Parameters
- $path : string|null
-
The absolute path to file to open
- $list : array<string|int, mixed>
-
The source to write
- $delimiter : string = ';'
-
Have a look at http://php.net/manual/de/function.fgetcsv.php delimiter
- $enclosure : string = "'"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php enclosure
- $escape : string = "\"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php escape
Return values
Result —The result
WriteFile()
Write string to file
public
static WriteFile(string $path, scalar $data, int $flags) : bool
This method writes the given data to the defined file, it will wait when the system is in git lock mode. This method returns valid result also for writing empty strings unlike file put contents default behavior
Parameters
- $path : string
-
The target file path
- $data : scalar
-
The payload to store in the target file
- $flags : int
-
File put content flags (http://php.net/manual/de/function.file-put-contents.php)
Return values
bool —True on success
Zip()
Create a zip archive from folder or file contents
public
static Zip(string $source, string $target) : Result
Parameters
- $source : string
- $target : string
Return values
Result —extractTitle()
Get title Extract a translated title
protected
static extractTitle(object|null $content, string $language) : string
Parameters
- $content : object|null
-
A content object
- $language : string
-
The content language
Return values
string —The translated title
ListImplementedHandlers()
Get handler list Get the list of registered handlers
protected
static ListImplementedHandlers(string $type) : array<string|int, mixed>
Parameters
- $type : string
-
The handler folder to search in
Return values
array<string|int, mixed> —A list of registered handlers
RegisterPlugins()
Register plugins
protected
static RegisterPlugins() : mixed
Load the plugins from filesystem and register them for hook calling This function is cached.
Return values
mixed —CalculateFolderSizeRecurse()
Helper function to calculate size Recursively calculate size of a specific folder
private
static CalculateFolderSizeRecurse(string $folder, int &$file_count, int &$directory_count, int &$size) : bool
Parameters
- $folder : string
-
The path to calculate the size of
- $file_count : int
-
Pointer to file count
- $directory_count : int
-
Pointer to folder count
- $size : int
-
Pointer to file size
Return values
bool —The iteration result status
decrypt()
Decrypt data
private
static decrypt(string $encrypted[, string|array<string|int, mixed> $mc_key = FAA_CODE ]) : string
will try to decrypt the given data with the system encryption code or a customer defined one The function does a blowfish decryption and a base64 conversion on demand
Parameters
- $encrypted : string
-
The string to decrypt (must be base64 encoded)
- $mc_key : string|array<string|int, mixed> = FAA_CODE
-
The key or, an array with cipher, key and the iv
Return values
string —The decrypted string
DropFolderRecurse()
Delete a folder completely this method is the recursion helper for DropFolder()
private
static DropFolderRecurse(string $folder[, bool $full = false ]) : bool
Parameters
- $folder : string
-
The path to delete
- $full : bool = false
-
Also remove the root folder
Return values
bool —The delete status
encrypt()
Encrypt data
private
static encrypt(string $plain[, string|array<string|int, mixed> $mc_key = FAA_CODE ][, mixed &$tag = null ]) : string
Method will try to encrypt the given data with the system encryption code or a customer defined one The function does a blowfish encryption and a base64 conversion
Parameters
- $plain : string
-
The string to encrypt
- $mc_key : string|array<string|int, mixed> = FAA_CODE
-
The key or, an array with cipher, key and the iv
- $tag : mixed = null
Return values
string —The encrypted string base64 encoded
listEntriesOfType()
List generic objects
private
static listEntriesOfType(string $dir, string $type, string|null $language, bool $raw) : Result
Read a list of groups from local storage Uses the generic object load to get the entry list
Parameters
- $dir : string
-
Absolute path to source dir or, null
- $type : string
-
The requested object type
- $language : string|null
-
The language code or null for not translated view
- $raw : bool
-
Return entries as raw objects or normalized
Return values
Result —A default system result set, values contain the object
listFolderEntities()
List folder entries
private
static listFolderEntities(string $dir, string $type) : array<string|int, mixed>
Using a given directory this function can return the id's of all files in the folder this method is cached by object cache
Parameters
- $dir : string
-
Path to folder (absolute)
- $type : string
-
Type of store elements (raw / plain)
Return values
array<string|int, mixed> —List of folder files
parseKeyFile()
private
static parseKeyFile(string $path) : null|string|array<string|int, mixed>
Parameters
- $path : string
Return values
null|string|array<string|int, mixed> —recurseExtractAttributeOptions()
private
static recurseExtractAttributeOptions(array<string|int, mixed> $children, string $language) : void
Parameters
- $children : array<string|int, mixed>
- $language : string
Return values
void —resolveTypesWithRelatedContentAttribute()
private
static resolveTypesWithRelatedContentAttribute( &$found, Result &$res, $content_typ, $include_childs, $restrict[, null $suffix = null ]) : mixed
Parameters
- $found :
- $res : Result
- $content_typ :
- $include_childs :
- $restrict :
- $suffix : null = null
Return values
mixed —updateEntityAttribute()
update object attribute apply changes to a certain object attribute using the given change dataset
private
static updateEntityAttribute(BaseContent &$entity, Result &$result, object $attr, mixed $data, bool|string $validate[, string|null $prefix = '' ]) : void
Parameters
- $entity : BaseContent
-
A system object ob base content or children
- $result : Result
-
A system result object
- $attr : object
-
An object containing the attribute definitions
- $data : mixed
-
The new value for this attribute
- $validate : bool|string
-
Interpret results with attribute rules
- $prefix : string|null = ''
-
A prefix in child mode
Return values
void —updateEntityAttributes()
Update object attribute list
private
static updateEntityAttributes(BaseContent &$entity, Result &$result, array<string|int, mixed> $attrSet, mixed $data, bool|string $validate[, string|null $prefix = '' ]) : void
Apply changes to a certain object using the given change dataset
Parameters
- $entity : BaseContent
-
A system object ob base content or children
- $result : Result
-
A system result object
- $attrSet : array<string|int, mixed>
-
An object containing the attribute definitions
- $data : mixed
-
The new value for this attribute
- $validate : bool|string
-
Interpret results with attribute rules
- $prefix : string|null = ''
-
A prefix in child mode
Return values
void —updateEntityAttributeTable()
update object attribute of type relation apply changes to a certain object attribute using the given change dataset
private
static updateEntityAttributeTable(BaseContent &$entity, Result $result, stdClass $attr, array<string|int, mixed> $data[, string|null $field_key = '' ]) : void
Parameters
- $entity : BaseContent
-
A system object ob base content or children
- $result : Result
-
A system result object
- $attr : stdClass
-
An object containing the attribute definitions
- $data : array<string|int, mixed>
-
The new value for this attribute
- $field_key : string|null = ''
-
When this is a sub element, the path to the attribute