trigger_type; /** @var AbstractTrigger $class */ $class = self::getTriggerClass($triggerType); $obj = $class::makeFromTriggerValue($trigger->trigger_value); return $obj; } /** * Returns the class name to be used for triggers with the given name * * @param string $triggerType * * @return TriggerInterface|string * @throws FireflyException */ public static function getTriggerClass(string $triggerType): string { $triggerTypes = self::getTriggerTypes(); if (!array_key_exists($triggerType, $triggerTypes)) { throw new FireflyException('No such trigger exists ("' . e($triggerType) . '").'); } $class = $triggerTypes[$triggerType]; if (!class_exists($class)) { throw new FireflyException('Could not instantiate class for rule trigger type "' . e($triggerType) . '" (' . e($class) . ').'); } return $class; } /** * Returns a map with triggertypes, mapped to the class representing that type */ protected static function getTriggerTypes() { if (!self::$triggerTypes) { self::$triggerTypes = Domain::getRuleTriggers(); } return self::$triggerTypes; } }