protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) { // scheme code $code = $input->getOption(self::OPT_CODE); // dealer offset $offset = $input->getOption(self::OPT_OFFSET); // Start the simulation $result = \Akzo\Scheme\Service::getInstance()->initiateSimulation($code, $offset); // Check if the scheme has been executed for all dealers, otherwise replay this command with the new offset if (isset($result['moreDealersLeft']) && $result['moreDealersLeft']) { $cmd = 'php ' . __DIR__ . '/../manageSchemes.php simulate -c ' . $code . ' -o ' . $result['moreDealersOffset']; // FIXME: Use Symfony Process instead of plain exec //$process = new \Symfony\Component\Process\Process( //$cmd //); //$process->start(); if ($offset == 670) { if (function_exists('xdebug_start_trace')) { xdebug_start_trace(); } $cmd = 'php ' . __DIR__ . '/../manageSchemesX.php simulate -c ' . $code . ' -o ' . $result['moreDealersOffset']; } $GLOBALS['logger']->info("Starting scheme for more dealers from offset ** {$result['moreDealersOffset']} **" . PHP_EOL . "Command: {$cmd}"); $output = array(); $returnVal = 123; exec($cmd . ' >/dev/null 2>&1 &', $output, $returnVal); $GLOBALS['logger']->info("Got output :" . PHP_EOL . print_r($output, 1) . PHP_EOL . "Return val: " . $returnVal); } }
/** * _default * * @param mixed $request Request to use * * @access public * @return void */ public function _default($request) { global $logger; $data = array(); $data['nonce'] = urlencode($GLOBALS['app']->getSessionManager()->getActiveSession()->getAttribute('nonce')); $data['qcOperator'] = array("GREATER_THAN_EQUALS" => "Greater Than or Equal to", "LESS_THAN" => "Less than"); $data['qcBasevalue'] = array("HISTORICAL" => "Historical", "TARGET" => "Target", "GROWTH" => "Growth", "ACTUAL" => "Actual", "TARGET_ACHIEVEMENT" => "Target Achievement", "RATIO" => "Ratio"); $schemeId = $request->getParam("schemeId"); if (!empty($schemeId)) { // TODO: Fix this hack of checking for scheme $scheme = \Akzo\Scheme\Service::getInstance()->getInitiatedScheme($this->user, $schemeId); $data['userType'] = "initiator"; if (empty($scheme)) { $scheme = \Akzo\Scheme\Service::getInstance()->getToBeReviewedScheme($this->user, $schemeId); $data['userType'] = "reviewer"; } if (empty($scheme)) { $scheme = \Akzo\Scheme\Service::getInstance()->getToBeApprovedScheme($this->user, $schemeId); $data['userType'] = "approver"; } $data["schemeDataRaw"] = $scheme->data; $data["schemeData"] = json_decode($scheme->data, 1); // $this->logger->info("Scheme default: " . print_r($data['schemeData'], 1)); $data["state"] = $scheme->state; $data["schemeCode"] = $scheme->code; } $dealers = array(array("name" => "<>", "code" => "<>", "address" => "<>")); $data['dealers'] = $dealers; $this->__sendResponse('none', new \Native5\UI\TwigRenderer('schemePDF.tmpl'), $data); }
protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) { // Get the next scheme action to execute $actionToExecute = \Akzo\Scheme\CommandQueue::getInstance()->getNextSchemeAction(\Akzo\Scheme\Cache\KeyType::GENERATE_PDF); if (empty($actionToExecute) || !isset($actionToExecute[\Akzo\Scheme\ExecuteActionAttribute::CODE])) { return; } $GLOBALS['logger']->info("Got action to execute: " . print_r($actionToExecute, 1)); // FIXME: Read this from the action $groupDealersByCreditCode = true; // $config = $this->app->getConfiguration()->getRawConfiguration( // 'pdf' // ); $config = array(); $config['path'] = '/pdf'; // Execute the action //function generatePDFforDealers($schemeId, $path, $offset = 0, $count = 50) $result = \Akzo\Scheme\Service::getInstance()->generatePDFforDealers($actionToExecute[\Akzo\Scheme\ExecuteActionAttribute::CODE], getcwd() . $config['path'], $actionToExecute[\Akzo\Scheme\ExecuteActionAttribute::DEALER_OFFSET]); $GLOBALS['logger']->info("Got resulttttttt " . print_r($result, 1)); // Check if the scheme has been executed for all dealers if (isset($result['moreDealersLeft']) && $result['moreDealersLeft']) { // If not completed, replay for remaining dealers \Akzo\Scheme\CommandQueue::getInstance()->setSchemeAction($actionToExecute[\Akzo\Scheme\ExecuteActionAttribute::CODE], \Akzo\Scheme\Cache\KeyType::GENERATE_PDF, null, $result['moreDealersOffset'], \Akzo\Scheme\Cache\ExecuteActionState::WAITING, 0); } else { // If completed, remove Scheme Action $GLOBALS['logger']->info("Removed Scheme Action fffffffffffffffffffffffffffffffffffffffffffff"); \Akzo\Scheme\CommandQueue::getInstance()->removeSchemeAction($actionToExecute[\Akzo\Scheme\ExecuteActionAttribute::CODE], $actionToExecute[\Akzo\Scheme\ExecuteActionAttribute::TYPE], \Akzo\Scheme\Cache\KeyType::GENERATE_PDF); } //// scheme code //$code = $input->getOption(self::OPT_CODE); //// dealer offset //$offset = $input->getOption(self::OPT_OFFSET); //// Start the simulation //$result = \Akzo\Scheme\Service::getInstance()->initiateSimulation($code, $offset); //// Check if the scheme has been executed for all dealers, otherwise replay this command with the new offset //if (isset($result['moreDealersLeft']) && $result['moreDealersLeft']) { //$cmd = 'php '.__DIR__.'/../manageSchemes.php simulate -c '.$code.' -o '.$result['moreDealersOffset']; //// FIXME: Use Symfony Process instead of plain exec ////$process = new \Symfony\Component\Process\Process( ////$cmd ////); ////$process->start(); //if ($offset == 670) { //if (function_exists('xdebug_start_trace')) { //xdebug_start_trace(); //} //$cmd = 'php '.__DIR__.'/../manageSchemesX.php simulate -c '.$code.' -o '.$result['moreDealersOffset']; //} //$GLOBALS['logger']->info("Starting scheme for more dealers from offset ** {$result['moreDealersOffset']} **".PHP_EOL."Command: $cmd"); //$output = array(); $returnVal = 123; //exec($cmd.' >/dev/null 2>&1 &', $output, $returnVal); //$GLOBALS['logger']->info("Got output :".PHP_EOL.print_r($output, 1).PHP_EOL."Return val: ".$returnVal); //} }
/** * _default * * @param mixed $request Request to use * * @access public * @return void */ public function _default($request) { //$this->testEmail(); global $logger; $data = array(); $schemeService = \Akzo\Scheme\Service::getInstance(); $data['scheme'] = $schemeService->getSchemesPendingApproval($this->user); // $data['schemesPendingApproval'] = array_slice($schemesPendingApproval, 0, 10); $data['states'] = array("staged" => \Akzo\Scheme\State::STAGED, "initiated" => \Akzo\Scheme\State::TO_BE_REVIEWED, "reviewed" => \Akzo\Scheme\State::TO_BE_APPROVED, "approved" => \Akzo\Scheme\State::APPROVED, "updateRequested" => \Akzo\Scheme\State::UPDATE_REQUESTED); // TODO: Remove Dummy data $data['nonce'] = urlencode($GLOBALS['app']->getSessionManager()->getActiveSession()->getAttribute('nonce')); $GLOBALS['logger']->info("SChemes: " . PHP_EOL . print_r($data['schemesPendingApproval'], 1)); $this->__sendResponse('none', new \Native5\UI\TwigRenderer('schemeDescription.tmpl'), $data); }
public function _save($request) { $rawSchemeData = file_get_contents('php://input'); $schemeData = json_decode($rawSchemeData); $saveDir = __DIR__ . '/../logs/schemes'; if (!file_exists($saveDir)) { mkdir($saveDir); } $saveNS = date("m-d-Y_H-i-s", time()) . '-' . $this->user->username; file_put_contents($saveDir . '/' . $saveNS . '-rawSchemeData.log', $rawSchemeData); file_put_contents($saveDir . '/' . $saveNS . '-schemeDataArray.log', print_r($schemeData, true)); // Call create scheme API $schemeCreationStatus = \Akzo\Scheme\Service::getInstance()->createScheme($this->user, $rawSchemeData); $this->_sendResponse(null, array('status' => $schemeCreationStatus), 'json'); //$GLOBALS['logger']->info("Request is: ".print_r($request, 1)); //// $schemeData = $request->getParam('schemedata'); //$rawSchemeData = file_get_contents('php://input'); //$schemeData = json_decode($rawSchemeData); //$GLOBALS['logger']->info('schemedata: '.PHP_EOL.print_r($rawSchemeData, 1)); //$path = __DIR__.'/../tests/unit/Akzo/Test/Scheme/schemeData.json'; //file_put_contents($path, json_encode($schemeData)); }
public function _getSchemeStates($render = true) { $data = array(); $schemeService = \Akzo\Scheme\Service::getInstance(); $schemesPendingApproval = $schemeService->getSchemesPendingApproval($this->user); $data['schemesPendingApproval'] = $schemesPendingApproval; // $data['schemesPendingApproval'] = array_slice($schemesPendingApproval, 0, 10); $data['states'] = array("staged" => \Akzo\Scheme\State::STAGED, "initiated" => \Akzo\Scheme\State::TO_BE_REVIEWED, "reviewed" => \Akzo\Scheme\State::TO_BE_APPROVED, "approved" => \Akzo\Scheme\State::APPROVED, "updateRequested" => \Akzo\Scheme\State::UPDATE_REQUESTED); $data['nonce'] = urlencode($GLOBALS['app']->getSessionManager()->getActiveSession()->getAttribute('nonce')); file_put_contents(getcwd() . '/logs/schemes.log', "schemes: " . PHP_EOL . print_r($data['schemesPendingApproval'], 1)); $this->__sendResponse('json', new \Native5\UI\TwigRenderer('schemeDetails.tmpl'), $data); }
/** * _requestApprovedUpdate Request review for a reviewed scheme * * @param mixed $request * @access public * @return void */ public function _requestApprovedUpdate($request) { $comment = $request->getParam('comment'); $code = $request->getParam('schemeCode'); $scheme = \Akzo\Scheme\Service::getInstance()->editApprovedScheme($this->user, $code, $comment); $this->__sendResponse('json', null, array('status' => true)); }
public function _downloadDealerWisePDFs($request) { global $logger; $schemeId = $request->getParam('schemeId'); $generateDir = __DIR__ . '/../pdf'; $schemeService = \Akzo\Scheme\Service::getInstance(); list($files, $uid) = $schemeService->getGeneratedPDFs($schemeId, $generateDir); $zip = new ZipArchive(); $filename = $generateDir . "/" . $uid . ".zip"; if ($zip->open($filename, ZipArchive::CREATE) !== TRUE) { exit("cannot open <{$filename}>\n"); } if (!empty($files)) { foreach ($files as $key => $file) { $zip->addFile($file, basename($file)); } } else { $zip->addFromString('ERROR.md', 'No PDF found'); } $zip->close(); $this->_streamFile($filename); }
public function _simulationDump($request) { global $logger; $simResult = array(); $count = 0; $code = $request->getParam('code'); $uid = $request->getParam('uid'); $actuals = $request->getParam('actuals'); $executionType = \Akzo\Scheme\ExecuteActionDataType::TARGET; if ($request->hasParam('actuals') && $request->getParam('actuals') === 'true') { $executionType = \Akzo\Scheme\ExecuteActionDataType::ACTUAL; $this->logger->info("ACTUALS:: true "); } // TODO: Send this as parameter from the front-end $groupDealersByCreditCode = true; // $request->getParam('groupByCreditCode'); $simulationResult = \Akzo\Scheme\Service::getInstance()->getSchemeExecutionResult($code, $executionType, $groupDealersByCreditCode); if ($groupDealersByCreditCode) { $titles = array("Serial No.", "Dealer Credit Code"); } else { $titles = array("Serial No.", "Dealer Code"); } $GLOBALS['logger']->info("sidfljgnz/lfkbnsl/xvndkfgndkjfbg;dflkhlsrgjdfkhgndflkgh: :" . print_r($simulationResult, 1)); if (isset($simulationResult['cumulatedData']) && isset($simulationResult['newData'])) { if (is_array($simulationResult['cumulatedData']['inBills'])) { $titles = array_merge($titles, array_keys($simulationResult['cumulatedData']['inBills'])); } if (is_array($simulationResult['cumulatedData']['ppiOutputs'])) { $ppiTitles = array(); foreach (array_keys($simulationResult['cumulatedData']['ppiOutputs']) as $key => $value) { $ppiTitles[] = $value . '(without QC)'; $ppiTitles[] = $value . '(with QC)'; } $titles = array_merge($titles, $ppiTitles); } if (is_array($simulationResult['cumulatedData']['priOutputs'])) { $priTitles = array(); foreach (array_keys($simulationResult['cumulatedData']['priOutputs']) as $key => $value) { $priTitles[] = $value . '(without QC)'; $priTitles[] = $value . '(with QC)'; } $titles = array_merge($titles, $priTitles); } if (is_array($simulationResult['cumulatedData']['slabOutputs'])) { $slabTitles = array(); foreach (array_keys($simulationResult['cumulatedData']['slabOutputs']) as $key => $value) { $slabTitles[] = $value . '(without QC)'; $slabTitles[] = $value . '(with QC)'; } $titles = array_merge($titles, $slabTitles); } if (is_array($simulationResult['cumulatedData']['slabV2Outputs'])) { $slabV2Titles = array(); foreach (array_keys($simulationResult['cumulatedData']['slabV2Outputs']) as $key => $value) { $slabV2Titles[] = $value . '(without QC)'; $slabV2Titles[] = $value . '(with QC)'; } $titles = array_merge($titles, $slabV2Titles); } foreach ($simulationResult['newData'] as $idx => $data) { $simResult[$count] = array(); array_push($simResult[$count], $count + 1, $idx); // $GLOBALS['logger']->info("In Loop: ".$idx.PHP_EOL.print_r($simulationResult['cumulatedData']['inBills'],1)); if (is_array($simulationResult['cumulatedData']['inBills'])) { foreach ($simulationResult['cumulatedData']['inBills'] as $i => $d) { if (!isset(json_decode($data, true)['inBills'][$i]['WITHOUT_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['inBills'][$i]['WITHOUT_QC']); // $GLOBALS['logger']->info("Inside the loop Loop: ".print_r($simResult, 1)); } } } if (is_array($simulationResult['cumulatedData']['ppiOutputs'])) { foreach ($simulationResult['cumulatedData']['ppiOutputs'] as $i => $d) { if (!isset(json_decode($data, true)['ppiOutputs'][$i]['WITHOUT_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['ppiOutputs'][$i]['WITHOUT_QC']); } if (!isset(json_decode($data, true)['ppiOutputs'][$i]['WITH_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['ppiOutputs'][$i]['WITH_QC']); } } } if (is_array($simulationResult['cumulatedData']['priOutputs'])) { foreach ($simulationResult['cumulatedData']['priOutputs'] as $i => $d) { if (!isset(json_decode($data, true)['priOutputs'][$i]['WITHOUT_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['priOutputs'][$i]['WITHOUT_QC']); } if (!isset(json_decode($data, true)['priOutputs'][$i]['WITH_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['priOutputs'][$i]['WITH_QC']); } } } if (is_array($simulationResult['cumulatedData']['slabOutputs'])) { foreach ($simulationResult['cumulatedData']['slabOutputs'] as $i => $d) { if (!isset(json_decode($data, true)['slabOutputs'][$i]['WITHOUT_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['slabOutputs'][$i]['WITHOUT_QC']); } if (!isset(json_decode($data, true)['slabOutputs'][$i]['WITH_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['slabOutputs'][$i]['WITH_QC']); } } } if (is_array($simulationResult['cumulatedData']['slabV2Outputs'])) { foreach ($simulationResult['cumulatedData']['slabV2Outputs'] as $i => $d) { if (!isset(json_decode($data, true)['slabV2Outputs'][$i]['WITHOUT_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['slabV2Outputs'][$i]['WITHOUT_QC']); } if (!isset(json_decode($data, true)['slabV2Outputs'][$i]['WITH_QC'])) { array_push($simResult[$count], "-"); } else { array_push($simResult[$count], json_decode($data, true)['slabV2Outputs'][$i]['WITH_QC']); } } } $count++; // $GLOBALS['logger']->info("simRESULTS: ".PHP_EOL.print_r($simResult[$count-1],1)); } } // $GLOBALS['logger']->info("simRESULTS: ".PHP_EOL.print_r($titles,1)); $dir = "./tmp"; if (!file_exists($dir) && !is_dir($dir)) { mkdir($dir); } $file = "{$dir}/csvdata-" . round(microtime(true) * 1000) . ".csv"; $fp = fopen($file, 'w'); fputcsv($fp, $titles); foreach ($simResult as $idx => $res) { // $GLOBALS['logger']->info("res ".$idx.": ".print_r($res,1)); fputcsv($fp, $res); } fclose($fp); $this->_streamFile($file, $uid . ".csv"); }
public function getGeneratedPDFs($schemeId, $path) { $scheme = \Akzo\Scheme\Service::getInstance()->getSchemeByCode($schemeId); $uid = $scheme->uid; $pattern = $path . "/" . $uid . "_*"; return [glob($pattern), $uid]; }
public function __construct(\Akzo\Scheme $scheme) { $this->_scheme = $scheme; parent::__construct($this->_scheme); $stateMachineDescription = array('class' => '\\Akzo\\Scheme', 'states' => array(\Akzo\Scheme\State::CREATED => array('type' => \Finite\State\StateInterface::TYPE_INITIAL, 'properties' => array('deletable' => true, 'editable' => true)), \Akzo\Scheme\State::STAGED => array('type' => \Finite\State\StateInterface::TYPE_NORMAL, 'properties' => array('deletable' => true, 'editable' => true)), \Akzo\Scheme\State::TO_BE_REVIEWED => array('type' => \Finite\State\StateInterface::TYPE_NORMAL, 'properties' => array('deletable' => false, 'editable' => false)), \Akzo\Scheme\State::TO_BE_APPROVED => array('type' => \Finite\State\StateInterface::TYPE_NORMAL, 'properties' => array('deletable' => false, 'editable' => false)), \Akzo\Scheme\State::APPROVED => array('type' => \Finite\State\StateInterface::TYPE_FINAL, 'properties' => array('deletable' => false, 'editable' => false)), \Akzo\Scheme\State::UPDATE_REQUESTED => array('type' => \Finite\State\StateInterface::TYPE_NORMAL, 'properties' => array('deletable' => true, 'editable' => true))), 'transitions' => array(\Akzo\Scheme\StateTransition::STAGE_SCHEME => array('from' => array(\Akzo\Scheme\State::CREATED), 'to' => \Akzo\Scheme\State::STAGED), \Akzo\Scheme\StateTransition::UPDATE_STAGED_SCHEME => array('from' => array(\Akzo\Scheme\State::STAGED), 'to' => \Akzo\Scheme\State::STAGED), \Akzo\Scheme\StateTransition::INITIATE_CREATED_SCHEME => array('from' => array(\Akzo\Scheme\State::CREATED), 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED), \Akzo\Scheme\StateTransition::INITIATE_STAGED_SCHEME => array('from' => array(\Akzo\Scheme\State::STAGED), 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED), \Akzo\Scheme\StateTransition::REVIEW_SCHEME => array('from' => array(\Akzo\Scheme\State::TO_BE_REVIEWED), 'to' => \Akzo\Scheme\State::TO_BE_APPROVED), \Akzo\Scheme\StateTransition::APPROVE_SCHEME => array('from' => array(\Akzo\Scheme\State::TO_BE_APPROVED), 'to' => \Akzo\Scheme\State::APPROVED), \Akzo\Scheme\StateTransition::REQUEST_SCHEME_UPDATE => array('from' => array(\Akzo\Scheme\State::TO_BE_REVIEWED, \Akzo\Scheme\State::TO_BE_APPROVED), 'to' => \Akzo\Scheme\State::UPDATE_REQUESTED), \Akzo\Scheme\StateTransition::REQUEST_SCHEME_REVIEW => array('from' => array(\Akzo\Scheme\State::TO_BE_APPROVED), 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED), \Akzo\Scheme\StateTransition::UPDATE_SCHEME => array('from' => array(\Akzo\Scheme\State::UPDATE_REQUESTED), 'to' => \Akzo\Scheme\State::UPDATE_REQUESTED), \Akzo\Scheme\StateTransition::INITIATE_UPDATED_SCHEME => array('from' => array(\Akzo\Scheme\State::UPDATE_REQUESTED), 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED), \Akzo\Scheme\StateTransition::EDIT_APPROVED_SCHEME => array('from' => array(\Akzo\Scheme\State::APPROVED), 'to' => \Akzo\Scheme\State::UPDATE_REQUESTED)), 'callbacks' => array('after' => array(array('from' => \Akzo\Scheme\State::CREATED, 'to' => \Akzo\Scheme\State::STAGED, 'do' => function ($scheme, $event) { \Akzo\Scheme\Service::getInstance()->createSaveScheme($scheme); }), array('from' => \Akzo\Scheme\State::STAGED, 'to' => \Akzo\Scheme\State::STAGED, 'do' => function ($scheme, $event) { \Akzo\Scheme\Service::getInstance()->updateSaveScheme($scheme); }), array('from' => \Akzo\Scheme\State::UPDATE_REQUESTED, 'to' => \Akzo\Scheme\State::UPDATE_REQUESTED, 'do' => function ($scheme, $event) { \Akzo\Scheme\Service::getInstance()->updateSaveScheme($scheme); }), array('from' => \Akzo\Scheme\State::CREATED, 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED, 'do' => function ($scheme, $event) { \Akzo\Scheme\Service::getInstance()->createSaveScheme($scheme); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::STAGED, 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED, 'do' => function ($scheme, $event) { \Akzo\Scheme\Service::getInstance()->updateSaveScheme($scheme); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::UPDATE_REQUESTED, 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED, 'do' => function ($scheme, $event) { \Akzo\Scheme\Service::getInstance()->updateSaveScheme($scheme); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::TO_BE_REVIEWED, 'to' => \Akzo\Scheme\State::UPDATE_REQUESTED, 'do' => function ($scheme, $event) { // Just update the state of scheme in the database $scheme->save(); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::TO_BE_REVIEWED, 'to' => \Akzo\Scheme\State::TO_BE_APPROVED, 'do' => function ($scheme, $event) { // Just update the state of scheme in the database $scheme->save(); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::TO_BE_APPROVED, 'to' => \Akzo\Scheme\State::UPDATE_REQUESTED, 'do' => function ($scheme, $event) { // Just update the state of scheme in the database $scheme->save(); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::TO_BE_APPROVED, 'to' => \Akzo\Scheme\State::TO_BE_REVIEWED, 'do' => function ($scheme, $event) { // Just update the state of scheme in the database $scheme->save(); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::TO_BE_APPROVED, 'to' => \Akzo\Scheme\State::APPROVED, 'do' => function ($scheme, $event) { // Just update the state of scheme in the database $scheme->save(); $schemeID = $scheme->code; $schemeService = \Akzo\Scheme\Service::getInstance(); $schemeService->initiatePDFCreation($schemeID); // Send notification to initiator, reviewer, approver for intimating that scheme has been approved \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); }), array('from' => \Akzo\Scheme\State::APPROVED, 'to' => \Akzo\Scheme\State::UPDATE_REQUESTED, 'do' => function ($scheme, $event) { // Just update the state of scheme in the database $scheme->save(); // TODO: Merge this will the below savePublicTransition function // Send notification to initiator, reviewer, approver for sending request for re-review of scheme \Akzo\Scheme\Notifier::sendNotification($scheme, $event->getTransition()); // TODO: Merge this will the above sendNotification function // Save the state transition \Akzo\Scheme\Service::getInstance()->savePublicTransition($scheme, $event->getTransition()); })))); $loader = new \Finite\Loader\ArrayLoader($stateMachineDescription); $loader->load($this); $this->initialize(); }