[Partage] de fonctions dans la classe userFunction

Fonction pour effacer un CRON DANS ou A du moteur de tâche.

/*		Fonction permettant de supprimer un "DANS" ou "A" d'un scénario
**		Le "DANS" ou "A" est préalablement repéré par un tag(inAt)
**		La valeur du tag peut être composée du numéro de scénario et
**		d'un numéro d'ordre afin qu'elle reste unique.
**
** $_inAt	: Valeur du tag(inAt) créé juste avant le bloc A ou DANS
**
** Appel de la fonction --> removeInAtTag(204_002)
*/
public static function removeInAtTag($_inAt = '') {
	log::add(__CLASS__,'info','Fonction ' . __FUNCTION__ . '--------------------');
	log::add(__CLASS__,'info','Fonction ' . __FUNCTION__ . ' : CRON recherché --> ' . $_inAt);
	$crons = cron::searchClassAndFunction('scenario', 'doIn');
	if (is_array($crons)) {
		foreach ($crons as $cron) {
			$id = $cron->getId();
			$schedule = $cron->getSchedule();
			$option = $cron->getOption();
			$scenario_id = $option['scenario_id'];
			$scenarioElement_id = $option['scenarioElement_id'];
			$inAt = $option['tags']['#inAt#'];
			log::add(__CLASS__,'info','Fonction ' . __FUNCTION__ . " : CRON trouvé --> id : $id - Schedule : $schedule - Scénario : $scenario_id - Elément : $scenarioElement_id - TagInAt : $inAt");
			if ($inAt == $_inAt) {
				log::add(__CLASS__,'info','Fonction ' . __FUNCTION__ . ' : CRON effacé --> ' . $inAt);	
				$cron->remove();
				return 'Le CRON ' . $inAt . ' a été effacé';
			}
		}
	}
	log::add(__CLASS__,'warning','Fonction ' . __FUNCTION__ . ' : Aucun CRON à effacer!!!');
	return "Aucun CRON à effacer";
}

Blocs A ou DANS d’un scénario.

Commande tag pour effacer le CRON du moteur de tâche.

Log du scénario qui efface le CRON.

[2024-12-19 17:43:17][SCENARIO] Mise à jour du tag #inAtRemove# => Le CRON 204_002 a été effacé
1 « J'aime »