action_type; $class = self::getActionClass($actionType); return new $class($action); } /** * Returns the class name to be used for actions with the given name * * @param string $actionType * * @return ActionInterface|string * @throws FireflyException */ public static function getActionClass(string $actionType): string { $actionTypes = self::getActionTypes(); if (!array_key_exists($actionType, $actionTypes)) { throw new FireflyException('No such action exists ("' . e($actionType) . '").'); } $class = $actionTypes[$actionType]; if (!class_exists($class)) { throw new FireflyException('Could not instantiate class for rule action type "' . e($actionType) . '" (' . e($class) . ').'); } return $class; } /** * Returns a map with actiontypes, mapped to the class representing that type */ protected static function getActionTypes() { if (!self::$actionTypes) { self::$actionTypes = Domain::getRuleActions(); } return self::$actionTypes; } }