PHP code example of sinevia / php-library-workflow
1. Go to this page and download the library: Download sinevia/php-library-workflow library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sinevia / php-library-workflow example snippets
// Create application
$aplication = new Application;
// Create application workflow
$applicationWorkflow = new ApplicationWorkflow($application);
// Send email and update workflow
if(sendEmailToApplicant() == true){
$applicationWorkflow->completeStepStartApplication();
}
// Check what is the current step
echo $applicationWorkflow->getCurrentStep()->title;
// Check what is the current step
echo $applicationWorkflow->getProgress();
class ApplicationWorkflow extends Workflow {
protected $application = null;
function __construct($application) {
parent::__construct();
$step = new Step("StartApplication");
$step->type = "first";
$step->title = "Start application process";
$step->responsible = "Applicant";
$this->addStep($step);
$step = new Step("SignAgreement");
$step->title = "Signing agreement";
$step->responsible = "Applicant";
$this->addStep($step);
$step = new Step("SelectCourses");
$step->title = "Select Courses";
$step->responsible = "Applicant";
$this->addStep($step);
$step = new Step("UploadDiploma");
$step->title = "Upload Diploma";
$step->responsible = "Applicant";
$this->addStep($step);
$step = new Step("ConfirmFitsRequirements");
$step->title = "Confirm if applicant fits the tep->title = "Prepare papers needed for visa application";
$step->responsible = "Manager";
$this->addStep($step);
$step = new Step("ApplyForVisa");
$step->title = "Apply for Visa";
$step->responsible = "Applicant";
$this->addStep($step);
$step = new Step("ReceiveDecisionForVisa");
$step->title = "Receive decision for the visa";
$step->responsible = "Manager";
$this->addStep($step);
$step = new Step("FindAccommodation");
$step->title = "Find sutable accomodation";
$step->responsible = "Applicant";
$this->addStep($step);
$step = new Step("PrepareFilesForResidenceCard");
$step->title = "Prepare files for residence card.";
$step->responsible = "Applicant";
$this->addStep($step);
$step = new Step("ApplyForResidenceCard");
$step->title = "Apply for residence card";
$step->responsible = "Applicant";
$this->addStep($step);
$this->application = $application;
if ($application != null) {
$this->fromString($application->State);
}
}
function save() {
if ($this->application != null) {
$this->application->State = $this->toString();
return $this->application->save();
}
return false;
}
function completeStepStartApplication() {
$this->setCurrentStep("SignAgreement");
return $this->save();
}
function completeStepSignAgreement() {
$this->setCurrentStep("SelectCourses");
return $this->save();
}
}