Best Behat code snippet using OutputController.execute
helpers.php
Source:helpers.php  
...21	public static function getSettings($name) {22		$sql = 'SELECT value FROM Settings WHERE name = :name';23		$result = self::$handler->prepare($sql);24		$result->bindValue(':name', $name);25		if ($result->execute()) {26			$value = $result->fetch();27			$singleValue = $value['value'];28			return $singleValue;29		} else {30			$output = new OutputController($dbHandler);31			$this->output->displayPhpError();32		}33	}34	35	public function configDelete($table, $rowId) {36		if ($table == 'Zahlungsziel') {37			$sql = 'UPDATE '.$table.' SET active = 0 WHERE id = '.$rowId;38			$result=$this->dbHandler->prepare($sql);39		} else {40			$sql = 'UPDATE '.$table.' SET active = 0 WHERE id = '.$rowId;41			$result=$this->dbHandler->prepare($sql);42		}43		if ($result->execute()) {44		    return 'success';45		} else {46		    return 'false';47		}48	}49	50	public function configSave($object, $data) {51		$values = explode('<>', $object);52		$table = $values[0];53		$name = $values[1];54		if ($table == 'Zahlungsziel') {55		    $sql = "INSERT INTO Zahlungsziel (name, beschreibung, active) VALUES (:name, :description, 1)";56		    $result=$this->dbHandler->prepare($sql);57		    $result->bindValue(':name', $name);58		    $result->bindValue(':description', $data);59		} elseif ($table == 'Benutzer') {60		    $password = md5($data);61		    $mail = $values[2];62		    $role = $values[3];63		    $sql = "INSERT INTO Benutzer (name, mail, passwort, rolle_id, active) VALUES (:name, :mail, :password, :role, 1)";64		    $result=$this->dbHandler->prepare($sql);65		    $result->bindValue(':name', $name);66		    $result->bindValue(':mail', $mail);67		    $result->bindValue(':password', $password);68		    $result->bindValue(':role', $role);69		}70		if ($result->execute()) {71		    $id = $this->getLastId($table);72		    return $id;73		} else {74		    $error = 'Unable to save data';75		    return $error;76		}77	}78	79	public function configUpdate($object, $data) {80		$values = explode('<>', $object);81		$table = $values[0];82		$column = $values[1];83		$rowId = $values[2];84		$sql = "UPDATE ".$table." SET ".$column."= :value WHERE id = :rowId";85		$result=$this->dbHandler->prepare($sql);86		$result->bindValue(':value', $data);87		$result->bindValue(':rowId', $rowId);88		if ($result->execute()) {89		    return 'success';90		} else {91		    $error = 'No config change possible';92		    return $error;93		}94	}95	96	public function getAnsprechpartner() {97		$sql = 'SELECT id, name, vorname FROM Ansprechpartner';98		$result=$this->dbHandler->prepare($sql);99		if ($result->execute()) {100			$list = array();101			foreach ($result as $singleResult) {102				$list[] = array('id'=>$singleResult['id'], 'name'=>$singleResult["name"].' '.$singleResult["vorname"]);103			}104			$this->ansprechpartner = $list;105			return $list;106		} else {107			$output = new OutputController($dbHandler);108			$this->output->displayPhpError();109		}110	}111	112	public function getArt() {113		return $this->art;114	}115	116	public function getBenutzerList() {117		return $this->benutzerList;118	}119	120	public function getCompleteBenutzerList() {121		$sql = 'SELECT Benutzer.id as id, Benutzer.name as name, Rolle.name as rolle FROM Benutzer INNER JOIN Rolle ON Benutzer.rolle_id = Rolle.id WHERE active = 1';122		$result=$this->dbHandler->prepare($sql);123		if ($result->execute()) {124			foreach ($result as $singleResult) {125				$list[] = array('id' => $singleResult['id'], 'name' => $singleResult["name"], 'rolle' => $singleResult["rolle"]);126			}127			return $list;128		} else {129			$output = new OutputController($dbHandler);130			$this->output->displayPhpError();131		}132	}133	134	public function getDocuments($projectId) {135	    $sql = 'SELECT Akte.id as id, Akte.name as document, Benutzer.name as userName, Akte.bezeichnung as description, Akte.reg_date, Akte.file 136	        FROM Akte INNER JOIN Benutzer ON Akte.mitarbeiter = Benutzer.id WHERE projectId = :projectId ORDER BY Akte.name';137	    $result=$this->dbHandler->prepare($sql);138	    $result->bindValue(':projectId', $projectId);139	    if ($result->execute()) {140			$final = array();141			foreach ($result as $finalResult) {142			    if ($finalResult['description'] == null) {143				$finalResult['description'] = '';144			    }145			    $date = explode(' ', $finalResult['reg_date']);146			    $first = explode('-', $date[0]);147			    $second = explode(':', $date[1]);148			    $finalResult['reg_date'] = $first[2].'.'.$first[1].'.'.$first[0].' '.$second[0].':'.$second[1];149			    $final[] = array(150				'id' => $finalResult['id'],151				'documentName' => $finalResult['document'], 152				'userName' => $finalResult['userName'], 153				'date' => $finalResult['reg_date'],154				'description' => $finalResult['description'],155				'file' => $finalResult['file']156			    );157			}158			return $final;159	    } else {160			return 'false';161	    }162	}163	public function getInvoiceNumber($projectId, $file) {164		$sql = 'SELECT id FROM Rechnungsnummer WHERE projectId = :projectId AND file = :file';165		$result=$this->dbHandler->prepare($sql);166		$result->bindValue(':projectId', $projectId);167		$result->bindValue(':file', $file);168		if ($result->execute()) {169			$final = $result->fetch();170			return $final['id'];171		} else {172			return 'false';173		}174	}175	176	public function getKalkulationsfelder() {177		return $this->kalkulationsfelder;178	}179	180	private function getLastId($table) {181	    $sql = "SELECT id FROM ".$table." ORDER BY id DESC LIMIT 1";182	    $result=$this->dbHandler->prepare($sql);183	    if ($result->execute()) {184			$singleId = $result->fetch();185			return $singleId['id'];186	    } else {187			return 'false';188	    }189	}190	public function getLastInvoiceNumber($id) {191		$sql = 'SELECT id FROM Rechnungsnummer WHERE projectId = :id ORDER BY id DESC LIMIT 1';192		$result=$this->dbHandler->prepare($sql);193		$result->bindValue(':id', $id);194		if ($result->execute()) {195			$final = $result->fetch();196			return $final['id'];197		} else {198			return 'false';199		}200	}201	202	public function getMandant() {203		return $this->mandant;204	}205	206	public function getMachine() {207		return $this->machine;208	}209	public function getOfferNumber($projectId, $file) {210		$sql = 'SELECT id FROM Angebotsnummer WHERE projectId = :projectId AND file = :file';211		$result=$this->dbHandler->prepare($sql);212		$result->bindValue(':projectId', $projectId);213		$result->bindValue(':file', $file);214		if ($result->execute()) {215			$final = $result->fetch();216			return $final['id'];217		} else {218			return 'false';219		}220	}221	public function getOrderNumber($projectId, $file) {222		$sql = 'SELECT id FROM Auftragsnummer WHERE projectId = :projectId AND file = :file';223		$result=$this->dbHandler->prepare($sql);224		$result->bindValue(':projectId', $projectId);225		$result->bindValue(':file', $file);226		if ($result->execute()) {227			$final = $result->fetch();228			return $final['id'];229		} else {230			return 'false';231		}232	}233	234	public function getProjectUser($projectId) {235		$sql = 'SELECT benutzerId FROM Benutzer_Projekt WHERE projektId = :projectId ORDER BY benutzerId';236		$result=$this->dbHandler->prepare($sql);237		$result->bindValue(':projectId', $projectId);238		if ($result->execute()) {239			$userList = array();240			foreach ($result as $single) {241				$userList[] = array( 'userId' => $single['benutzerId']);242			}243			return $userList;244		} else {245			$output = new OutputController($dbHandler);246			$this->output->displayPhpError();247		}248	}249	public function getProjectUserName($projectId) {250		$sql = 'SELECT Benutzer.name, Benutzer.id FROM Benutzer INNER JOIN Benutzer_Projekt ON Benutzer.id = Benutzer_Projekt.benutzerId WHERE Benutzer_Projekt.projektId = :projectId ORDER BY Benutzer_Projekt.benutzerId';251		$result=$this->dbHandler->prepare($sql);252		$result->bindValue(':projectId', $projectId);253		if ($result->execute()) {254			$userList = array();255			foreach ($result as $single) {256				$userList[] = array( 'name' => $single['name'], 'id' => $single['id']);257			}258			return $userList;259		} else {260			$output = new OutputController($dbHandler);261			$this->output->displayPhpError();262		}263		264	}265	266	public function getSingleArt($id) {267		$sql='SELECT name FROM Art WHERE id = :id';268		$result=$this->dbHandler->prepare($sql);269		$result->bindValue(':id', $id);270		if ($result->execute()) {271			$name = $result->fetch();272			$singleName = $name['name'];273			return $singleName;274		} else {275			$output = new OutputController($dbHandler);276			$this->output->displayPhpError();277		}278	}279	280	public function getSingleBenutzer($id) {281		$sql='SELECT Benutzer.name as name, Rolle.id as rolleId, Rolle.name as rolleName FROM Benutzer INNER JOIN Rolle ON Benutzer.rolle_id = Rolle.id WHERE Benutzer.id = :id';282		$result=$this->dbHandler->prepare($sql);283		$result->bindValue(':id', $id);284		if ($result->execute()) {285			$date = $result->fetch();286			$dateArray = array ('name' => $date['name'], 'rolle_id' => $date['rolleId'], 'rolle_name' => $date['rolleName']);287			return $dateArray;288		} else {289			$output = new OutputController($dbHandler);290			$this->output->displayPhpError();291		}292		293	}294	public function getSingleStatus($id) {295		$sql = "SELECT id, name FROM Status WHERE id = :id";296		$result=$this->dbHandler->prepare($sql);297		$result->bindValue(':id', $id);298		if ($result->execute()) {299			$date = $result->fetch();300			$result = array('id' => $date['id'], 'name' => $date['name']);301			return $result;302		} else {303			$output = new OutputController($dbHandler);304			$this->output->displayPhpError();305		}306	}307	308	public function getSingleZahlungsziel($id) {309		$sql = "SELECT name FROM Zahlungsziel WHERE id = :id";310		$result=$this->dbHandler->prepare($sql);311		$result->bindValue(':id', $id);312		if ($result->execute()) {313			$date = $result->fetch();314			return $date['name'];315		} else {316			$output = new OutputController($dbHandler);317			$this->output->displayPhpError();318		}319	}320	public function getSingleZahlungszielDesc($id) {321		$sql = "SELECT beschreibung FROM Zahlungsziel WHERE id = :id";322		$result=$this->dbHandler->prepare($sql);323		$result->bindValue(':id', $id);324		if ($result->execute()) {325			$date = $result->fetch();326			return $date['beschreibung'];327		} else {328			$output = new OutputController($dbHandler);329			$this->output->displayPhpError();330		}331	}332	333	public function getRolle() {334		return $this->rolle;335	}336	public function getSingleSelect($name) {337		$dates = explode('-', $name);338		$table = $dates[0];339		$projectId = $dates[1];340		$sql = "SELECT name FROM ".$table." WHERE id = :id";341		$result=$this->dbHandler->prepare($sql);342		$result->bindValue(':id', $projectId);343		if ($result->execute()) {344			$name = $result->fetch();345			return $name['name'];346		} else {347			return 'false';348		}349	}350	351	public function getStatusList() {352		$sql = "SELECT id, name FROM Status";353		$result=$this->dbHandler->prepare($sql);354		if ($result->execute()) {355			$list = array();356			foreach ($result as $singleResult) {357				$list[] = array('id'=>$singleResult['id'], 'name'=>$singleResult["name"]);358			}359			$this->status = $list;360			return $list;361		} else {362			$output = new OutputController($dbHandler);363			$this->output->displayPhpError();364		}365	}366	public function getAjaxZahlungsziel() {367		$sql = 'SELECT id, name, beschreibung FROM Zahlungsziel WHERE active = 1';368		$result = $this->dbHandler->prepare($sql);369		if ($result->execute()) {370			$list = array();371			foreach ($result as $singleResult) {372				$list[] = array('id'=>$singleResult['id'], 'name'=>$singleResult["name"], 'beschreibung' => $singleResult["beschreibung"]);373			}374			echo json_encode($list);375		} else {376			$output = new OutputController($dbHandler);377			$this->output->displayPhpError();378		}379	}380	381	public function getZahlungsziel() {382		$sql = 'SELECT id, name, beschreibung FROM Zahlungsziel WHERE active = 1';383		$result = $this->dbHandler->prepare($sql);384		if ($result->execute()) {385			$ziel = array();386			foreach ($result as $singleResult) {387				$ziel[] = array("id" => $singleResult['id'], "name" => $singleResult['name'], "beschreibung" => $singleResult["beschreibung"]);388			}389			$this->zahlungsziel = $ziel;390			return $ziel;391		} else {392			$output = new OutputController($dbHandler);393			$this->output->displayPhpError();394		}395	}396	397	public function ifUserActive($projectId, $userId) {398		$sql = 'SELECT id FROM Benutzer_Projekt WHERE projektId = :projectId AND benutzerId = :userId';399		$result = $this->dbHandler->prepare($sql);400		$result->bindValue(':projectId', $projectId);401		$result->bindValue(':userId', $userId);402		if ($result->execute()) {403			$final = $result->fetch();404			return $final;405		} else {406			$output = new OutputController($dbHandler);407			$this->output->displayPhpError();408		}409	}410	411	public function manageProjectUser($date, $projectId, $userId) {412		$insertOrDelete = $this->ifUserActive($projectId, $userId);413		if (is_array($insertOrDelete)) {414			$success = $this->projectUserDelete($projectId, $userId);415		} elseif ($insertOrDelete == false) {416			$success = $this->projectUserInsert($projectId, $userId);417		}418		return $success;419	}420	private function projectUserDelete($projectId, $userId) {421		$sql = "DELETE FROM Benutzer_Projekt WHERE projektId = :projectId AND benutzerId = :userId";422		$result=$this->dbHandler->prepare($sql);423		$result->bindValue(':projectId', $projectId);424		$result->bindValue(':userId', $userId);425		if ($result->execute()) {426			return 'deleted successfully';427		} else {428			return 'false';429		}430	}431	private function projectUserInsert($projectId, $userId) {432		$sql = "INSERT INTO Benutzer_Projekt (projektId, benutzerId) VALUES (:projectId, :userId)";433		$result=$this->dbHandler->prepare($sql);434		$result->bindValue(':projectId', $projectId);435		$result->bindValue(':userId', $userId);436		if ($result->execute()) {437			return 'success';438		} else {439			return 'false';440		}441	}442	443	public function setArt() {444		$sql='SELECT id, name FROM Art';445		$result=$this->dbHandler->prepare($sql);446		if ($result->execute()) {447			$ziel = array();448			foreach ($result as $singleResult) {449				$artList[] = array("id" => $singleResult['id'], "name" => $singleResult['name']);450			}451			$this->art = $artList;452		} else {453			$output = new OutputController($dbHandler);454			$this->output->displayPhpError();455		}456	}457	public function setInvoiceNumber($projectId, $file) {458		$sql = 'INSERT INTO Rechnungsnummer (projectId, reg_date, file) VALUES (:id, NOW(), :file)';459		$result=$this->dbHandler->prepare($sql);460		$result->bindValue(':id', $projectId);461		$result->bindValue(':file', $file);462		if ($result->execute()) {463			return 'success';464		} else {465			return 'false';466		}467	}468	public function setOfferNumber($projectId, $file) {469		$sql = 'INSERT INTO Angebotsnummer (projectId, reg_date, file) VALUES (:id, NOW(), :file)';470		$result=$this->dbHandler->prepare($sql);471		$result->bindValue(':id', $projectId);472		$result->bindValue(':file', $file);473		if ($result->execute()) {474			return 'success';475		} else {476			return 'false';477		}478	}479	public function setOrderNumber($projectId, $file) {480		$sql = 'INSERT INTO Auftragsnummer (projectId, reg_date, file) VALUES (:id, NOW(), :file)';481		$result=$this->dbHandler->prepare($sql);482		$result->bindValue(':id', $projectId);483		$result->bindValue(':file', $file);484		if ($result->execute()) {485			return 'success';486		} else {487			return 'false';488		}489	}490	491	public function setBenutzerList() {492		$sql='SELECT id, name FROM Benutzer WHERE active = 1';493		$result=$this->dbHandler->prepare($sql);494		if ($result->execute()) {495			$list = array();496			$counter = 0;497			foreach ($result as $singleResult) {498				$list[] = array('id'=>$singleResult['id'], 'name'=>$singleResult["name"], 'counter' => $counter );499				$counter++;500			}501			$this->benutzerList = $list;502		} else {503			$output = new OutputController($dbHandler);504			$this->output->displayPhpError();505		}506	}507	508	public function setKalkulationsfelder() {509		$sql='SELECT id, name FROM Kalkulationsfelder';510		$result=$this->dbHandler->prepare($sql);511		if ($result->execute()) {512			$fields = array();513			foreach ($result as $singleResult) {514				$fields[] = array( 'id' => $singleResult["id"], 'name' => $singleResult["name"] );515			}516			$this->kalkulationsfelder = $fields;517			return $fields;518		} else {519			$output = new OutputController($dbHandler);520			$this->output->displayPhpError();521		}522	}523	524	public function setLieferant( $id = null ) {525		$sql='SELECT id, name FROM Lieferant';526		if (isset($id)) {527			$sql.= ' WHERE id = :id';528		}529		$result=$this->dbHandler->prepare($sql);530		if (isset($id)) {531			$result->bindValue(':id', $id);532		}533		if ($result->execute()) {534			$list = array();535			foreach ($result as $singleResult) {536				$list[] = array('id'=>$singleResult['id'], 'name'=>$singleResult["name"]);537			}538			$this->lieferant = $list;539			return $list;540		} else {541			$output = new OutputController($dbHandler);542			$this->output->displayPhpError();543		}544	}545	546	public function setMachine() {547		$sql='SELECT id, name FROM Maschine';548		$result=$this->dbHandler->prepare($sql);549		if ($result->execute()) {550			$list = array();551			foreach ($result as $singleResult) {552				$list[] = array('id'=>$singleResult['id'], 'name'=>$singleResult["name"]);553			}554			$this->machine = $list;555		} else {556			$output = new OutputController($dbHandler);557			$this->output->displayPhpError();558		}559	}560	561	public function setRolle($return = null) {562		$sql='SELECT id, name FROM Rolle';563		$result=$this->dbHandler->prepare($sql);564		if ($result->execute()) {565			$list = array();566			foreach ($result as $singleResult) {567				$list[] = array('id' => $singleResult['id'], 'name' => $singleResult["name"]);568			}569			$this->rolle = $list;570			if (isset($return) && $return = 'true') {571				return $list;572			}573		} else {574			$output = new OutputController($dbHandler);575			$this->output->displayPhpError();576		}577	}578	579	public static function settings($dbHandler, $row) {580		$sql = "SELECT value FROM Settings WHERE name = '".$row."'";581		$result = $dbHandler->prepare($sql);582		if ($result->execute()) {583			$final = $result->fetch();584			return $final['value'];585		} else {586			return 'false';587		}588	}589	590	public function standardText($text) {591	      $sql = 'UPDATE Settings SET value = :text WHERE name = "standardText"';592	      $result=$this->dbHandler->prepare($sql);593	      $result->bindValue(':text', $text);594	      if ($result->execute()) {595		    return 'success';596	      } else {597		    $error = 'No text change possible';598		    return $error;599	      }600	}601}...TrackerController.php
Source:TrackerController.php  
2use Carbon\Carbon;3use Phalcon\Mvc\Dispatcher;4use Phalcon\Mvc\Controller;5/**6 * Tracking class. Implementation of pixel-like urls that load and execute the same controllers/actions in the project.7 * The goal is to create a dataset related to the loaded page to be used as tracking data that can handle cached pages.8 *9 * How it works10 *11 * 1. User loads a normal page (IE: Index page with URL: `/?test=1`)12 * 2. Index page generates a tracking url using OutputController::afterExecuteRoute (IE: `/track/Lw--/YXNkeD0x`)13 * 3. Tracking url gets sent to browser in the form of either a `<img>` object or an ajax request14 * 4. Browser calls tracking url15 * 5. TrackerController handles the request, decoding url, matching it with a proper original controller16 * 6. Original controller generates the same dataset used to build the page17 * 7. TrackerController obtains a subset of page dataset using `getTracking()` method18 * 8. TrackerController generates a final tracking dataset, pushes it to a local queue19 * 9. TrackerController sends dummy data to browser20 */...Router.php
Source:Router.php  
...90        $this->app->post('/{driver}/fetch_input', 'Controller\\InputController::fetchInputAction')91            ->bind('fetch_input');92        /* Run */93        $this->app->get('/run', 'Controller\\DefaultController::runAction')94            ->bind('execute');95    }96}...schem.php
Source:schem.php  
...31//excel-Import32Route::get('/excelimport/index', 'Schem\ExcelImportController@index');33Route::post('/excelimport/getval3', 'Schem\ExcelImportController@ajaxGetVal4');34Route::post('/excelimport/output', 'Schem\ExcelImportController@excelImport');35Route::post('/excelimport/execute', 'Schem\ExcelImportController@execute');36Route::post('/excelimport/import', 'Schem\ExcelImportController@import');37Route::get('/excelimport/create', 'Schem\ExcelImportController@create');38Route::post('/excelimport/accept', 'Schem\ExcelImportController@accept');39Route::post('/excelimport/cancel ','Schem\ExcelImportController@cancel');40Route::get('/output/index', 'Schem\OutputController@index');41Route::post('/output/output', 'Schem\OutputController@output');42Route::get('/item/index', 'Schem\ItemController@index');43Route::get('/item/manage', 'Schem\ItemController@manage');44Route::post('/item/manage', 'Schem\ItemController@manage');45Route::post('/item/delete', 'Schem\ItemController@delete');46Route::get('/item/create', 'Schem\ItemController@create');47Route::get('/item/edit', 'Schem\ItemController@edit');48Route::get('/item/show', 'Schem\ItemController@show');49Route::post('/item/save', 'Schem\ItemController@save');50Route::get('/item/pmanage', 'Schem\ItemController@pmanage');51Route::get('/item/pedit', 'Schem\ItemController@pedit');52Route::get('/item/pshow', 'Schem\ItemController@pshow');53Route::post('/item/psave', 'Schem\ItemController@psave');54Route::get('/recalc/index', 'Schem\ReCalcController@index');55Route::post('/recalc/recalc', 'Schem\ReCalcController@recalc');56Route::get('/case/index', 'Schem\CaseController@index');57Route::get('/case/create', 'Schem\CaseController@create');58Route::post('/case/newsave', 'Schem\CaseController@newsave');59Route::get('/case/copy', 'Schem\CaseController@copy');60Route::post('/case/copysave', 'Schem\CaseController@copysave');61Route::get('/case/delete', 'Schem\CaseController@delete');62Route::post('/case/deletesave', 'Schem\CaseController@deletesave');63Route::get('/bdata/index', 'Schem\BDataController@index');64Route::post('/bdata/execute', 'Schem\BDataController@execute');65Route::get('/bdata/result', 'Schem\BDataController@result');66Route::get('/nitteireflect/index', 'Schem\NitteiReflectController@index');67Route::post('/nitteireflect/reflect', 'Schem\NitteiReflectController@reflect');OutputController.php
Source:OutputController.php  
1<?php2use Illuminate\Support\Arr;3use Phalcon\Mvc\Dispatcher;4use Phalcon\Mvc\Controller;5/**6 *7 */8class OutputController extends Controller {9    /**10     * To identify which controller handled the request, using dot notation11     */12    public function getInternalName() : string {13        // d($this);14        return trim(strtolower(sprintf(15            '%s.%s.%s',16            str_replace('\\','.', $this->di->getRouter()->getNameSpaceName()),17            $this->di->getRouter()->getControllerName(),18            $this->di->getRouter()->getActionName())19        ), '.');20    }21    /**22     * List of datapoints to enter the tracking flow, in dot notation23     *24     * @see OutputController::getTracking()25     */26    protected function getTrackableFields() : array {27        return [];28    }29    /**30     * Function to check if request is to be tracked31     *32     * @return bool33     */34    protected function isTrackingAllowed() : bool {35        return true;36    }37    /**38     * Generates a list of datapoints to track based on view data39     * List of datapoints can be defined in constant `TRACKING` withing controllers40     *41     * @return array42     */43    final public function getTracking() : array {44        $return = array();45        foreach ($this->getTrackableFields() as $field) {46            $val = Arr::get( $this->view->getParamsToView(), $field );47            if (!is_null($val)) {48                $return[ $field ] = $val;49            }50        }51        // d($return);52        return array_undot($return);53    }54    public function beforeExecuteRoute(Dispatcher $dispatcher) {55        Timing::start($this->getInternalName());56    }57    public function afterExecuteRoute(Dispatcher $dispatcher) {58        Timing::stop($this->getInternalName());59        $this->view->setVars(array_merge(60            // Dataset coming from controller61            $dispatcher->getReturnedValue(),62            // Defaults63            array(64                'config'  => $this->di->getConfig()->toArray(),65                'tracker' => $this->di->getUrl()->get([66                    'for' => 'tracker',67                    'url' => strtr(base64_encode(strtok($_SERVER["REQUEST_URI"], '?')), '+/=', '._-'),68                    'qs'  => strtr(base64_encode($_SERVER['QUERY_STRING']), '+/=', '._-'),69                ])70            )71        ));72        Timing::break('total');73        $metrics = array(74            't' => Timing::getTimings($round = 3, $slowThreshold = -INF)75        );76        77        // if ($timings[0]) {78        //     $metrics['timings'] = array(79        //         'slowest' => $timings[0],80        //         't' => $timings[1],81        //         'total' => Timing::getElapsed()82        //     );83        // }84        $this->response->setHeader('X-Metrics', json_encode($metrics) );85        if ($this->view->isDisabled()) {86            $this->response->setJsonContent( $this->view->getParamsToView(), JSON_PRETTY_PRINT ) ;87            // $this->response->setContent( json_encode($this->view->getParamsToView(), JSON_PRETTY_PRINT )) ;88            $dispatcher->setReturnedValue($this->response);89        } else {90            if (!$this->view->getMainView() ) {91                $file = sprintf('%s/%s/%s',92                    str_replace('\\', '/', $dispatcher->getNameSpaceName()),93                    $dispatcher->getControllerName(),94                    $dispatcher->getActionName()95                );96                $view = APP_PATH . '/views/' . $file . '.twig';97                if (!file_exists($view)) {98                    throw new Exception("View doesnt exist: $view");99                }100                $this->view->setMainView($file);101            }102        }103    }104}...ErrorController.php
Source:ErrorController.php  
1<?php2use Phalcon\Mvc\Dispatcher;3use Phalcon\Mvc\Controller;4class ErrorController extends OutputController5{6    private $httpError = 500;7    public function beforeExecuteRoute(Dispatcher $dispatcher) {8    }9    public function afterExecuteRoute(Dispatcher $dispatcher) {10        return false;11    }12    public function http410Action() : array {13        $this->httpError = 401;14        $this->response->setHeader('WWW-Authenticate', 'Basic realm=Secured');15        $this->response->setContent('Unauth');16        return [];17    }18    public function http404Action() : array {19        $this->httpError = 404;20        $this->response->setContent('404');21        $this->view->setMainView('errors/404');22        return [];23    }24    public function http500Action() : array {25        $this->httpError = 500;26        return [];27    }28}...Routes.php
Source:Routes.php  
1<?php2namespace Config;3use App\Controller\HomeController;4use App\Controller\OutputController;5class Routes6{7    public function __construct($url)8    {9        $this->Execute($url);10    }11    private function Execute($url)12    {13        switch ($url) {14            case '/':15                new HomeController();16                break;17            case 'output':18                new OutputController($_FILES['xmldata']['tmp_name']);19                break;20            default:21                echo "Nothing Found";22                break;23        }    24    }25} ...index.php
Source:index.php  
...3set_include_path(get_include_path() . PATH_SEPARATOR . realpath('..'));4// Handle output5require_once 'utils/OutputController.php';6$oc = new OutputController();7$oc->execute();...execute
Using AI Code Generation
1$controller = new OutputController();2$controller->execute();3$controller = new OutputController();4$controller->execute();5$controller = new OutputController();6$controller->execute();7$controller = new OutputController();8$controller->execute();9$controller = new OutputController();10$controller->execute();11$controller = new OutputController();12$controller->execute();13$controller = new OutputController();14$controller->execute();15$controller = new OutputController();16$controller->execute();17$controller = new OutputController();18$controller->execute();19$controller = new OutputController();20$controller->execute();21$controller = new OutputController();22$controller->execute();23$controller = new OutputController();24$controller->execute();25$controller = new OutputController();26$controller->execute();27$controller = new OutputController();28$controller->execute();29$controller = new OutputController();30$controller->execute();31$controller = new OutputController();32$controller->execute();33$controller = new OutputController();34$controller->execute();execute
Using AI Code Generation
1$obj = new OutputController();2$obj->execute();3$obj = new OutputController();4$obj->execute();5$obj = new OutputController();6$obj->execute();7$obj = new OutputController();8$obj->execute();9$obj = new OutputController();10$obj->execute();11$obj = new OutputController();12$obj->execute();13$obj = new OutputController();14$obj->execute();15$obj = new OutputController();16$obj->execute();17$obj = new OutputController();18$obj->execute();19$obj = new OutputController();20$obj->execute();21$obj = new OutputController();22$obj->execute();23$obj = new OutputController();24$obj->execute();25$obj = new OutputController();26$obj->execute();execute
Using AI Code Generation
1$controller = new OutputController();2$controller->execute();3{4    public function execute()5    {6        $output = new Output();7        $output->setOutput('Hello world!');8        $output->display();9    }10}11{12    private $output;13    public function setOutput($output)14    {15        $this->output = $output;16    }17    public function display()18    {19        echo $this->output;20    }21}execute
Using AI Code Generation
1$obj = new OutputController();2$obj->execute();3class OutputController{4  public function execute(){5    $this->render();6  }7  public function render(){8    echo "Hello World";9  }10}11$obj = new OutputController();12$obj->execute();13class OutputController{14  public function execute(){15    $this->render();16  }17  public function render(){18    echo "Hello World";19  }20}21$obj = new OutputController();22$obj->execute();23class OutputController{24  public function execute(){25    $this->render();26  }27  public function render(){28    echo "Hello World";29  }30}31$obj = new OutputController();32$obj->execute();33class OutputController{34  public function execute(){35    $this->render();36  }37  public function render(){38    echo "Hello World";39  }40}execute
Using AI Code Generation
1$controller = new OutputController();2$controller->execute();3$controller = new OutputController();4$controller->execute();5$controller = new OutputController();6$controller->execute();7$controller = new OutputController();8$controller->execute();9$controller = new OutputController();10$controller->execute();11$controller = new OutputController();12$controller->execute();13$controller = new OutputController();14$controller->execute();15$controller = new OutputController();16$controller->execute();17$controller = new OutputController();18$controller->execute();19$controller = new OutputController();20$controller->execute();21$controller = new OutputController();22$controller->execute();23$controller = new OutputController();24$controller->execute();25$controller = new OutputController();26$controller->execute();Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with execute on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!
