<?php

namespace LaraBB\Settings\Actions\Prefix;

use LaraBB\Forum\Tasks\Forum\FindTask as FindForumTask;
use LaraBB\Settings\Tasks\Prefix\FindTask as FindPrefixTask;
use LaraBB\Settings\UI\Web\Requests\Prefix\Edit;

/**
 * Class EditAction
 * @package LaraBB\Settings\Actions\Prefix
 */
class EditAction
{
    /**
     * EditAction constructor.
     * @param FindPrefixTask $findPrefixTask
     * @param FindForumTask $findForumTask
     */
    public function __construct(
        private readonly FindPrefixTask $findPrefixTask,
        private readonly FindForumTask $findForumTask
    ) {

    }

    /**
     * @param Edit $request
     * @return array
     */
    public function run(Edit $request): array
    {
        return [
            'active' => 'settings',
            'forums' => $this->findForumTask->all(),
            'prefix' => $this->findPrefixTask->byUuid($request->route('uuid'), ['forums'])
        ];
    }
}
