Documentation

CFOs
in package

[$cfos = $this->core->loadClass('CFOs',$integrationKey);] Class CFOs to handle CFO app for CloudFrameworkInterface https://www.notion.so/cloudframework/CFI-PHP-Class-c26b2a1dd2254ddd9e663f2f8febe038 last_update: 20240725

Table of Contents

Properties

$api  : CFOApi
$avoid_secrets  : mixed
$bqObjects  : mixed
$core  : Core7
$db_connection  : mixed
$dbObjects  : mixed
$dsObjects  : mixed
$error  : mixed
$errorCode  : mixed
$errorMsg  : mixed
$integrationKey  : string
$keyId  : mixed
$last_cfo  : mixed
$lastDBObject  : CloudSQL
$namespace  : mixed
$project_id  : mixed
$secrets  : mixed
$service_account  : mixed
$version  : mixed
$workFlows  : CFOWorkFlows

Methods

__construct()  : mixed
DataSQL constructor.
addError()  : bool
Add an error in the class
avoidSecrets()  : mixed
If ($avoid==true and if !$this->service_account) the secrets of Datastore, Bigquery, Database CFOs will be tried to be read. False by default
bq()  : DataBQ
Return a bq $object
bqInit()  : bool
Initialize BigQuery integration
bqQuery()  : array<string|int, mixed>|false
Execute a Direct query inside a $connection
db()  : DataSQL
Initialize or retrieve a database connection object for a given CFO ID
dbClose()  : mixed
Close Database Connections
dbConnection()  : CloudSQL|bool
dbInit()  : bool
Initialize a bq $object
dbQuery()  : array<string|int, mixed>|void
Execute a Direct query inside a $connection
ds()  : DataStore
Fetches the DataStore object for a given CFO ID
dsInit()  : bool
Create a (Datastore) $this->dsObjects[$object] element to be used by ds. If any error it creates a Datastore Foo Object with error message;
getCFOSecret()  : mixed
Return the PlatformSecret value of $secret only if $this->avoid_secrets is false. Else it will return empty array [] It $platform_secret_id does not exist it will return an error
getInterfaceModelFromDatastoreModel()  : array<string|int, mixed>
Return a structure with bigquery squema based on CF model
getPlatformSecret()  : mixed
Read a PlatformSecret into $this->secrets[] and return the value.
readCFOs()  : array<string|int, mixed>|false
resetCache()  : void
Reset the cache for the specified cache key or clear the entire cache if no key is provided.
resetError()  : void
Reset error status and clear error details in the class
setDBConnection()  : mixed
Set a default DB Connection for CloudSQL. It has to be an array and it will rewrite the secrets included in the CFOs for db
setDBCredentials()  : bool
Assign DB Credentials to stablish connection
setDBCredentialsFromPlatformSecret()  : bool
Try to read from CLOUD-PLATFORM $secret
setIntegrationKey()  : mixed
Set $this->integrationKey to connect with CFO models
setNameSpace()  : mixed
setProjectId()  : mixed
Set a default project_id overwritting the default project_id
setSecret()  : mixed
Set secrets to be used by Datastore, Bigquery, Database
setServiceAccount()  : mixed
Set a default service account for Datastore and BigQuery Objects. It has to be an array and it will rewrite the secrets includes in the CFOs for ds and bigquery
transformTXTInDatastoreModel()  : array<string|int, mixed>|void
Execute a Manual Query
useCFOSecret()  : mixed
If ($use==true and if !$this->service_account) the secrets of Datastore, Bigquery, Database CFOs will be tried to be read. False by default

Properties

$avoid_secrets

public mixed $avoid_secrets = \true

$bqObjects

public mixed $bqObjects = []

$core

public Core7 $core

$db_connection

public mixed $db_connection = \null

$dbObjects

public mixed $dbObjects = []

$dsObjects

public mixed $dsObjects = []

$error

public mixed $error = \false

$errorCode

public mixed $errorCode = \null

$errorMsg

public mixed $errorMsg = []

$integrationKey

public string $integrationKey = ''

To connect with the ERP

$keyId

public mixed $keyId = \null

$last_cfo

public mixed $last_cfo = ''

$namespace

public mixed $namespace = 'default'

$project_id

public mixed $project_id = \null

$secrets

public mixed $secrets = []

$service_account

public mixed $service_account = \null

$version

public mixed $version = '202410161'

Methods

__construct()

DataSQL constructor.

public __construct(Core &$core[, mixed $integrationKey = '' ]) : mixed
Parameters
$core : Core
$integrationKey : mixed = ''

addError()

Add an error in the class

public addError(string $code, mixed $value) : bool
Parameters
$code : string

Code of error

$value : mixed
Return values
bool

Always return null to facilitate other return functions

avoidSecrets()

If ($avoid==true and if !$this->service_account) the secrets of Datastore, Bigquery, Database CFOs will be tried to be read. False by default

public avoidSecrets(bool $avoid) : mixed
Parameters
$avoid : bool

bq()

Return a bq $object

public bq( $cfoId) : DataBQ
Parameters
$cfoId :
Return values
DataBQ

bqInit()

Initialize BigQuery integration

public bqInit(string $cfoId[, string $project_id = '' ][, array<string|int, mixed> $service_account = [] ]) : bool
Parameters
$cfoId : string

CFO ID for the BigQuery integration

$project_id : string = ''

(optional) Project ID for BigQuery integration

$service_account : array<string|int, mixed> = []

(optional) Service account information for authentication

Return values
bool

Returns true if initialization is successful, false otherwise

bqQuery()

Execute a Direct query inside a $connection

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

db()

Initialize or retrieve a database connection object for a given CFO ID

public db(string $cfoId[, string $connection = 'default' ]) : DataSQL
Parameters
$cfoId : string

The ID of the CFO

$connection : string = 'default'

The name of the connection to use (default: 'default')

Return values
DataSQL

Returns the DataSQL object associated with the CFO ID

dbClose()

Close Database Connections

public dbClose([string $connection = '' ]) : mixed
Parameters
$connection : string = ''

Optional it specify to close a specific connection instead of all

dbConnection()

public dbConnection([string $connection = 'default' ]) : CloudSQL|bool
Parameters
$connection : string = 'default'
Return values
CloudSQL|bool

returns false if error

dbInit()

Initialize a bq $object

public dbInit(string $cfoId[, string $connection = 'default' ][, array<string|int, mixed> $db_credentials = [] ]) : bool
Parameters
$cfoId : string
$connection : string = 'default'

name of the connection

$db_credentials : array<string|int, mixed> = []

optional credentials for the connection

Return values
bool

dbQuery()

Execute a Direct query inside a $connection

public dbQuery( $q[, null $params = null ][, string $connection = 'default' ]) : array<string|int, mixed>|void
Parameters
$q :
$params : null = null
$connection : string = 'default'
Return values
array<string|int, mixed>|void

ds()

Fetches the DataStore object for a given CFO ID

public ds(string $cfoId) : DataStore
Parameters
$cfoId : string

The CFO ID for which to retrieve the DataStore object

Return values
DataStore

The DataStore object associated with the provided CFO ID

dsInit()

Create a (Datastore) $this->dsObjects[$object] element to be used by ds. If any error it creates a Datastore Foo Object with error message;

public dsInit(string $cfoId[, string $namespace = '' ][, string $project_id = '' ][, array<string|int, mixed> $service_account = [] ]) : bool
Parameters
$cfoId : string
$namespace : string = ''
$project_id : string = ''
$service_account : array<string|int, mixed> = []

Optional parameter to

Return values
bool

getCFOSecret()

Return the PlatformSecret value of $secret only if $this->avoid_secrets is false. Else it will return empty array [] It $platform_secret_id does not exist it will return an error

public getCFOSecret(string $platform_secret_id) : mixed
Parameters
$platform_secret_id : string

Secret to read with format {secret_id}.{varname}

Return values
mixed

return the secret value or null if error

getInterfaceModelFromDatastoreModel()

Return a structure with bigquery squema based on CF model

public getInterfaceModelFromDatastoreModel(mixed $entity, mixed $model, mixed $group[, mixed $secret_id = '' ]) : array<string|int, mixed>
Parameters
$entity : mixed
$model : mixed
$group : mixed
$secret_id : mixed = ''
Return values
array<string|int, mixed>

getPlatformSecret()

Read a PlatformSecret into $this->secrets[] and return the value.

public getPlatformSecret(string $platform_secret_id[, mixed $platform_id = '' ]) : mixed

It $platform_secret_id does not exist it will return an error

Parameters
$platform_secret_id : string

Secret to read with format {secret_id}.{varname}

$platform_id : mixed = ''
Return values
mixed

return the secret value or null if error

readCFOs()

public readCFOs(string $cfos) : array<string|int, mixed>|false
Parameters
$cfos : string
Return values
array<string|int, mixed>|false

if there is no error return an array with the model structure

resetCache()

Reset the cache for the specified cache key or clear the entire cache if no key is provided.

public resetCache([string $cfo = '' ]) : void
Parameters
$cfo : string = ''

Cache key to reset the cache for. (Optional, default: '')

resetError()

Reset error status and clear error details in the class

public resetError() : void
Return values
void

No return value as it resets the error state without returning any specific value

setDBConnection()

Set a default DB Connection for CloudSQL. It has to be an array and it will rewrite the secrets included in the CFOs for db

public setDBConnection(array<string|int, mixed> $db_connection) : mixed
Parameters
$db_connection : array<string|int, mixed>

setDBCredentials()

Assign DB Credentials to stablish connection

public setDBCredentials(array<string|int, mixed> $credentials[, string $connection = 'default' ]) : bool
Parameters
$credentials : array<string|int, mixed>

Varaibles to establish a connection $credentials['dbServer'] $credentials['dbUser'] $credentials['dbPassword']??null); $credentials['dbName']??null); $credentials['dbSocket']??null); $credentials['dbProxy']??null); $credentials['dbProxyHeaders']??null); $credentials['dbCharset']??null); $credentials['dbPort']??'3306');

$connection : string = 'default'

Optional name of the connection. If empty it will be default

Return values
bool

setDBCredentialsFromPlatformSecret()

Try to read from CLOUD-PLATFORM $secret

public setDBCredentialsFromPlatformSecret(string $platform_secret_variable[, string $platform_id = '' ]) : bool
Parameters
$platform_secret_variable : string

name of the secret with se format: {secret-id}.{variable}

$platform_id : string = ''

optional platform id. If is not passed it will take $this->namespace

Return values
bool

setIntegrationKey()

Set $this->integrationKey to connect with CFO models

public setIntegrationKey( $key) : mixed
Parameters
$key :

setNameSpace()

public setNameSpace( $namespace) : mixed
Parameters
$namespace :

setProjectId()

Set a default project_id overwritting the default project_id

public setProjectId( $project_id) : mixed
Parameters
$project_id :

setSecret()

Set secrets to be used by Datastore, Bigquery, Database

public setSecret( $key, array<string|int, mixed> $value) : mixed
Parameters
$key :
$value : array<string|int, mixed>

setServiceAccount()

Set a default service account for Datastore and BigQuery Objects. It has to be an array and it will rewrite the secrets includes in the CFOs for ds and bigquery

public setServiceAccount(array<string|int, mixed> $service_account) : mixed
Parameters
$service_account : array<string|int, mixed>

transformTXTInDatastoreModel()

Execute a Manual Query

public transformTXTInDatastoreModel(string $txt, string $cfo) : array<string|int, mixed>|void
Parameters
$txt : string
$cfo : string
Return values
array<string|int, mixed>|void

useCFOSecret()

If ($use==true and if !$this->service_account) the secrets of Datastore, Bigquery, Database CFOs will be tried to be read. False by default

public useCFOSecret([bool $use = true ]) : mixed
Parameters
$use : bool = true

        
On this page

Search results