The name of the table to store the jobs
The name of the table to store the logs per job. If it's empty then it is not used
The list of database columns used by the job
The List of database columns used by the log of the job
It indicates a special field to set the reference of the job.
It indicates extra fields/states
It sets the method called when the job change state
- $changeStateTrigger param callable $changeStateTrigger (callable)
It sets the method called when the job starts
- $startTrigger param callable $startTrigger (callable)
It sets the method called when job is paused
- $pauseTrigger param callable $pauseTrigger (callable)
It sets the method called when the job stop
- $stopTrigger param callable $stopTrigger (callable)
$tmp=$statemachineone->setStopTriggerthis();
It sets a function to returns the number of the process. By default, it is obtained by the database or via an internal counter.
- $getNumberTrigger param callable $getNumberTrigger (callable)
add a new transition
- $state0 Initial state (string)
- $state1 Ending state (string)
- $conditions Conditions, it could be a function or a string 'instock = "hello"' (mixed)
- $duration Duration of the transition in seconds. (int)
- $result =['change','pause','continue','stop'][$i] (string)
We clear all transitions.
Returns true if the database is active
It sets the database as active. When we call setDb() then it is set as true automatically.
- $dbActive param bool $dbActive (bool)
Returns true if is in debug mode.
Set the debug mode. By default the debug mode is false.
- $debug param bool $debug (bool)
Returns the job queue.
Set the job queue
- $jobQueue param Job[] $jobQueue (Job[])
- $defaultInitState param int $defaultInitState (int)
Gets an array with the states
Set the array with the states
- $states param array $states (array)
Constructor of the class. By default, the construct set default triggers. StateMachineOne constructor.
It sets the database
- $server server ip, example "localhost" (string)
- $user user of the database, example "root" (string)
- $pwd password of the database, example "123456" (string)
- $db database(schema), example "sakila" (string)
It returns the current connection. If there is not a connection then it generates a new one.
Loads a job from the database
- $idJob param $idJob ()
It loads all jobs from the database with all active state but none and stopped.
It loads all jobs from the database regardless its active state.
- $job param Job $job (Job)
(optional), it creates a database table, including indexes.
- $drop if true, then the table will be dropped. (bool)
It saves a job in the database. It only saves a job that is marked as new or updated
- $job param Job $job (Job)
Insert a new job log into the database.
- $idJob param $idJob ()
- $arr param $arr ()
It saves all jobs in the database that are marked as new or updated.
It creates a new job.
- $idRef Every job must refence some object/operation/entity/individual. (int[])
- $fields param array $fields (array)
- $active=['none','inactive','active','pause','stop'][$i] param string $active=['none','inactive','active','pause','stop'][$i] (string)
- $initState param mixed $initState (mixed)
- $dateStart param int|null $dateStart (int|null)
- $durationSec Duration (maximum) in seconds of the event (int|null)
- $expireSec param int|null $expireSec (int|null)
It gets a job by id.
- $idJob param int $idJob (int)
It checks a specific job and proceed to change state. We check a job and we change the state
- $idJob param $idJob ()
It checks all jobs available (if the active state of the job is any but none or stop)
It changes the state of a job manually. It changes the state manually.
- $job param Job $job (Job)
- $newState param mixed $newState (mixed)
- $time timestamp with microseconds (int|null)
It adds a log of the job.
- $idJob param int $idJob (int)
- $type=['ERROR','WARNING','INFO','DEBUG'][$i] param string $type=['ERROR','WARNING','INFO','DEBUG'][$i] (string)
- $description param string $description (string)
It removes a jobs of the queue.
- $job param Job $job (Job)
$tmp=$statemachineone->removeJobthis();
We check if the states are consistents. It is only for testing.
$tmp=$statemachineone->checkConsistencethis();