File manager - Edit - /var/www/payraty/helpdesk/app/Services/Triggers/Actions/Actions.php
Back
<?php namespace App\Services\Triggers\Actions; use App; use App\Models\Ticket; use App\Models\Trigger; use Illuminate\Support\Str; class Actions { public function execute(Ticket $ticket, Trigger $trigger): Ticket { foreach($trigger->actions as $actionModel) { $action = $this->getAction($actionModel->name); $ticket = $action->execute($ticket, $actionModel, $trigger); //if action aborts triggers cycle (for example deletes ticket) //we need to bail instantly and not run any actions after it if ($this->abortsCycle([$actionModel])) break; } return $ticket; } public function updatesTicket(iterable $actions): bool { foreach($actions as $action) { if ($action['updates_ticket'] === 1) { return true; } } return false; } public function abortsCycle(iterable $actions): bool { foreach($actions as $action) { if ($action['aborts_cycle'] === 1) { return true; } } return false; } /** * Get an instance of specified action class. * * @param string $actionName * @return TriggerActionInterface */ protected function getAction($actionName) { $className = $this->getActionClassName($actionName); return App::make('App\Services\Triggers\Actions\\'.$className); } /** * Get class name of specified action. * * @param string $actionName * @return string */ protected function getActionClassName($actionName) { return ucfirst(Str::camel($actionName)).'Action'; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.68 |
proxy
|
phpinfo
|
Settings