Passed
Push — feature/code-analysis ( 4fe35d...c99b5b )
by Jonathan
11:08 queued 07:29
created
app/Module/PatronymicLineage/Model/LineageNode.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -24,106 +24,106 @@
 block discarded – undo
24 24
  */
25 25
 class LineageNode
26 26
 {
27
-    /**
28
-     * @var Collection<string, stdClass>  $linked_fams Spouse families linked to the node
29
-     */
30
-    private Collection $linked_fams;
27
+	/**
28
+	 * @var Collection<string, stdClass>  $linked_fams Spouse families linked to the node
29
+	 */
30
+	private Collection $linked_fams;
31 31
 
32
-    private ?Individual $node_indi;
33
-    private LineageRootNode $root_node;
34
-    private ?string $alt_surname;
32
+	private ?Individual $node_indi;
33
+	private LineageRootNode $root_node;
34
+	private ?string $alt_surname;
35 35
 
36
-    /**
37
-     * Constructor for Lineage node
38
-     *
39
-     * @param Individual $node_indi Main individual
40
-     * @param LineageRootNode $root_node Node of the lineage root
41
-     * @param null|string $alt_surname Follow-up surname
42
-     */
43
-    public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
44
-    {
45
-        $this->node_indi = $node_indi;
46
-        $this->root_node = $root_node;
47
-        $this->alt_surname = $alt_surname;
48
-        $this->linked_fams = new Collection();
49
-    }
36
+	/**
37
+	 * Constructor for Lineage node
38
+	 *
39
+	 * @param Individual $node_indi Main individual
40
+	 * @param LineageRootNode $root_node Node of the lineage root
41
+	 * @param null|string $alt_surname Follow-up surname
42
+	 */
43
+	public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
44
+	{
45
+		$this->node_indi = $node_indi;
46
+		$this->root_node = $root_node;
47
+		$this->alt_surname = $alt_surname;
48
+		$this->linked_fams = new Collection();
49
+	}
50 50
 
51
-    /**
52
-     * Add a spouse family to the node
53
-     *
54
-     * @param Family $fams
55
-     * @return stdClass
56
-     */
57
-    public function addFamily(Family $fams): object
58
-    {
59
-        if (!$this->linked_fams->has($fams->xref())) {
60
-            $this->linked_fams->put($fams->xref(), (object) [
61
-                'family'   =>  $fams,
62
-                'children' =>  new Collection()
63
-            ]);
64
-        }
65
-        return $this->linked_fams->get($fams->xref());
66
-    }
51
+	/**
52
+	 * Add a spouse family to the node
53
+	 *
54
+	 * @param Family $fams
55
+	 * @return stdClass
56
+	 */
57
+	public function addFamily(Family $fams): object
58
+	{
59
+		if (!$this->linked_fams->has($fams->xref())) {
60
+			$this->linked_fams->put($fams->xref(), (object) [
61
+				'family'   =>  $fams,
62
+				'children' =>  new Collection()
63
+			]);
64
+		}
65
+		return $this->linked_fams->get($fams->xref());
66
+	}
67 67
 
68
-    /**
69
-     * Add a child LineageNode to the node
70
-     *
71
-     * @param Family $fams
72
-     * @param LineageNode $child
73
-     */
74
-    public function addChild(Family $fams, LineageNode $child = null): void
75
-    {
76
-        $this->addFamily($fams)->children->push($child);
77
-        $this->root_node->incrementChildNodes();
78
-    }
68
+	/**
69
+	 * Add a child LineageNode to the node
70
+	 *
71
+	 * @param Family $fams
72
+	 * @param LineageNode $child
73
+	 */
74
+	public function addChild(Family $fams, LineageNode $child = null): void
75
+	{
76
+		$this->addFamily($fams)->children->push($child);
77
+		$this->root_node->incrementChildNodes();
78
+	}
79 79
 
80
-    /**
81
-     * Returns the node individual
82
-     *
83
-     * @return Individual|NULL
84
-     */
85
-    public function individual(): ?Individual
86
-    {
87
-        return $this->node_indi;
88
-    }
80
+	/**
81
+	 * Returns the node individual
82
+	 *
83
+	 * @return Individual|NULL
84
+	 */
85
+	public function individual(): ?Individual
86
+	{
87
+		return $this->node_indi;
88
+	}
89 89
 
90
-    /**
91
-     * Returns the lineage root node individual
92
-     *
93
-     * @return LineageRootNode
94
-     */
95
-    public function rootNode(): LineageRootNode
96
-    {
97
-        return $this->root_node;
98
-    }
90
+	/**
91
+	 * Returns the lineage root node individual
92
+	 *
93
+	 * @return LineageRootNode
94
+	 */
95
+	public function rootNode(): LineageRootNode
96
+	{
97
+		return $this->root_node;
98
+	}
99 99
 
100
-    /**
101
-     * Returns the spouse families linked to the node
102
-     *
103
-     * @return Collection<string, \stdClass>
104
-     */
105
-    public function families(): Collection
106
-    {
107
-        return $this->linked_fams;
108
-    }
100
+	/**
101
+	 * Returns the spouse families linked to the node
102
+	 *
103
+	 * @return Collection<string, \stdClass>
104
+	 */
105
+	public function families(): Collection
106
+	{
107
+		return $this->linked_fams;
108
+	}
109 109
 
110
-    /**
111
-     * Returns the follow-up surname
112
-     *
113
-     * @return string
114
-     */
115
-    public function followUpSurname(): string
116
-    {
117
-        return $this->alt_surname ?? '';
118
-    }
110
+	/**
111
+	 * Returns the follow-up surname
112
+	 *
113
+	 * @return string
114
+	 */
115
+	public function followUpSurname(): string
116
+	{
117
+		return $this->alt_surname ?? '';
118
+	}
119 119
 
120
-    /**
121
-     * Indicates whether the node has a follow up surname
122
-     *
123
-     * @return boolean
124
-     */
125
-    public function hasFollowUpSurname(): bool
126
-    {
127
-        return mb_strlen($this->followUpSurname()) > 0 ;
128
-    }
120
+	/**
121
+	 * Indicates whether the node has a follow up surname
122
+	 *
123
+	 * @return boolean
124
+	 */
125
+	public function hasFollowUpSurname(): bool
126
+	{
127
+		return mb_strlen($this->followUpSurname()) > 0 ;
128
+	}
129 129
 }
Please login to merge, or discard this patch.
app/Module/PatronymicLineage/Model/LineageRootNode.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -23,68 +23,68 @@
 block discarded – undo
23 23
  */
24 24
 class LineageRootNode extends LineageNode
25 25
 {
26
-    /**
27
-     * @var Collection<string, int> $places Places for the lineage node
28
-     */
29
-    private $places;
26
+	/**
27
+	 * @var Collection<string, int> $places Places for the lineage node
28
+	 */
29
+	private $places;
30 30
 
31
-    /**
32
-     * @var int $nb_children Number of node childs
33
-     */
34
-    private $nb_children;
31
+	/**
32
+	 * @var int $nb_children Number of node childs
33
+	 */
34
+	private $nb_children;
35 35
 
36
-    /**
37
-     * Constructor for LineageRootNode
38
-     *
39
-     * @param Individual|null $node_indi
40
-     */
41
-    public function __construct(?Individual $node_indi = null)
42
-    {
43
-        parent::__construct($node_indi, $this);
44
-        $this->places = new Collection();
45
-        $this->nb_children = 0;
46
-    }
36
+	/**
37
+	 * Constructor for LineageRootNode
38
+	 *
39
+	 * @param Individual|null $node_indi
40
+	 */
41
+	public function __construct(?Individual $node_indi = null)
42
+	{
43
+		parent::__construct($node_indi, $this);
44
+		$this->places = new Collection();
45
+		$this->nb_children = 0;
46
+	}
47 47
 
48
-    /**
49
-     * Adds a place to the list of lineage's place
50
-     *
51
-     * @param Place $place
52
-     */
53
-    public function addPlace(Place $place): void
54
-    {
55
-        $place_name = $place->gedcomName();
56
-        if (mb_strlen($place_name) > 0) {
57
-            $this->places->put($place_name, $this->places->get($place_name, 0) + 1);
58
-        }
59
-    }
48
+	/**
49
+	 * Adds a place to the list of lineage's place
50
+	 *
51
+	 * @param Place $place
52
+	 */
53
+	public function addPlace(Place $place): void
54
+	{
55
+		$place_name = $place->gedcomName();
56
+		if (mb_strlen($place_name) > 0) {
57
+			$this->places->put($place_name, $this->places->get($place_name, 0) + 1);
58
+		}
59
+	}
60 60
 
61
-    /**
62
-     * Returns the number of child nodes.
63
-     * This number is more to be used as indication rather than an accurate one.
64
-     *
65
-     * @return int
66
-     */
67
-    public function numberChildNodes(): int
68
-    {
69
-        return $this->nb_children;
70
-    }
61
+	/**
62
+	 * Returns the number of child nodes.
63
+	 * This number is more to be used as indication rather than an accurate one.
64
+	 *
65
+	 * @return int
66
+	 */
67
+	public function numberChildNodes(): int
68
+	{
69
+		return $this->nb_children;
70
+	}
71 71
 
72
-    /**
73
-     * Increments the number of child nodes by one
74
-     *
75
-     */
76
-    public function incrementChildNodes(): void
77
-    {
78
-        $this->nb_children++;
79
-    }
72
+	/**
73
+	 * Increments the number of child nodes by one
74
+	 *
75
+	 */
76
+	public function incrementChildNodes(): void
77
+	{
78
+		$this->nb_children++;
79
+	}
80 80
 
81
-    /**
82
-     * Returns the list of place for the lineage
83
-     *
84
-     * @return Collection<string, int>
85
-     */
86
-    public function places(): Collection
87
-    {
88
-        return $this->places;
89
-    }
81
+	/**
82
+	 * Returns the list of place for the lineage
83
+	 *
84
+	 * @return Collection<string, int>
85
+	 */
86
+	public function places(): Collection
87
+	{
88
+		return $this->places;
89
+	}
90 90
 }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Schema/Migration0.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
  */
22 22
 class Migration0 implements MigrationInterface
23 23
 {
24
-    /**
25
-     * {@inheritDoc}
26
-     * @see MigrationInterface::upgrade()
27
-     */
28
-    public function upgrade(): void
29
-    {
30
-        // These migrations have been merged into migration 1.
31
-    }
24
+	/**
25
+	 * {@inheritDoc}
26
+	 * @see MigrationInterface::upgrade()
27
+	 */
28
+	public function upgrade(): void
29
+	{
30
+		// These migrations have been merged into migration 1.
31
+	}
32 32
 }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Schema/Migration1.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -25,31 +25,31 @@
 block discarded – undo
25 25
  */
26 26
 class Migration1 implements MigrationInterface
27 27
 {
28
-    /**
29
-     * {@inheritDoc}
30
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
-     */
32
-    public function upgrade(): void
33
-    {
34
-        $in_transaction = DB::connection()->getPdo()->inTransaction();
35
-
36
-        // Clean up previous admin tasks table if it exists
37
-        DB::schema()->dropIfExists('maj_admintasks');
38
-
39
-        DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
40
-
41
-            $table->increments('majat_id');
42
-            $table->string('majat_task_id', 32)->unique();
43
-            $table->enum('majat_status', ['enabled', 'disabled'])->default('disabled');
44
-            $table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0));
45
-            $table->boolean('majat_last_result')->default(true);
46
-            $table->integer('majat_frequency')->default(10080);
47
-            $table->smallInteger('majat_nb_occur')->default(0);
48
-            $table->boolean('majat_running')->default(false);
49
-        });
50
-
51
-        if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) {
52
-            DB::connection()->beginTransaction();
53
-        }
54
-    }
28
+	/**
29
+	 * {@inheritDoc}
30
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
+	 */
32
+	public function upgrade(): void
33
+	{
34
+		$in_transaction = DB::connection()->getPdo()->inTransaction();
35
+
36
+		// Clean up previous admin tasks table if it exists
37
+		DB::schema()->dropIfExists('maj_admintasks');
38
+
39
+		DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
40
+
41
+			$table->increments('majat_id');
42
+			$table->string('majat_task_id', 32)->unique();
43
+			$table->enum('majat_status', ['enabled', 'disabled'])->default('disabled');
44
+			$table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0));
45
+			$table->boolean('majat_last_result')->default(true);
46
+			$table->integer('majat_frequency')->default(10080);
47
+			$table->smallInteger('majat_nb_occur')->default(0);
48
+			$table->boolean('majat_running')->default(false);
49
+		});
50
+
51
+		if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) {
52
+			DB::connection()->beginTransaction();
53
+		}
54
+	}
55 55
 }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TasksList.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -31,91 +31,91 @@
 block discarded – undo
31 31
  */
32 32
 class TasksList implements RequestHandlerInterface
33 33
 {
34
-    private ?AdminTasksModule $module;
35
-    private TaskScheduleService $taskschedules_service;
34
+	private ?AdminTasksModule $module;
35
+	private TaskScheduleService $taskschedules_service;
36 36
 
37
-    /**
38
-     * Constructor for TasksList Request Handler
39
-     *
40
-     * @param ModuleService $module_service
41
-     * @param TaskScheduleService $taskschedules_service
42
-     */
43
-    public function __construct(
44
-        ModuleService $module_service,
45
-        TaskScheduleService $taskschedules_service
46
-    ) {
47
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
48
-        $this->taskschedules_service = $taskschedules_service;
49
-    }
37
+	/**
38
+	 * Constructor for TasksList Request Handler
39
+	 *
40
+	 * @param ModuleService $module_service
41
+	 * @param TaskScheduleService $taskschedules_service
42
+	 */
43
+	public function __construct(
44
+		ModuleService $module_service,
45
+		TaskScheduleService $taskschedules_service
46
+	) {
47
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
48
+		$this->taskschedules_service = $taskschedules_service;
49
+	}
50 50
 
51
-    /**
52
-     * {@inheritDoc}
53
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
54
-     */
55
-    public function handle(ServerRequestInterface $request): ResponseInterface
56
-    {
57
-        if ($this->module === null) {
58
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
59
-        }
51
+	/**
52
+	 * {@inheritDoc}
53
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
54
+	 */
55
+	public function handle(ServerRequestInterface $request): ResponseInterface
56
+	{
57
+		if ($this->module === null) {
58
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
59
+		}
60 60
 
61
-        $module = $this->module;
62
-        $module_name = $this->module->name();
63
-        return response(['data' => $this->taskschedules_service->all(true, true)
64
-            ->map(function (TaskSchedule $schedule) use ($module, $module_name): array {
65
-                $task = $this->taskschedules_service->findTask($schedule->taskId());
66
-                $task_name = $task !== null ? $task->name() : I18N::translate('Task not found');
61
+		$module = $this->module;
62
+		$module_name = $this->module->name();
63
+		return response(['data' => $this->taskschedules_service->all(true, true)
64
+			->map(function (TaskSchedule $schedule) use ($module, $module_name): array {
65
+				$task = $this->taskschedules_service->findTask($schedule->taskId());
66
+				$task_name = $task !== null ? $task->name() : I18N::translate('Task not found');
67 67
 
68
-                return [
69
-                    'edit' =>   view($module_name . '::admin/tasks-table-options', [
70
-                        'task_sched_id' => $schedule->id(),
71
-                        'task_sched_enabled' => $schedule->isEnabled(),
72
-                        'task_edit_route' => route(TaskEditPage::class, ['task' => $schedule->id()]),
73
-                        'task_status_route' => route(TaskStatusAction::class, [
74
-                            'task' => $schedule->id(),
75
-                            'enable' => $schedule->isEnabled() ? 0 : 1
76
-                        ])
77
-                    ]),
78
-                    'status'    =>  [
79
-                        'display'   =>  view($module_name . '::components/yes-no-icons', [
80
-                            'yes' => $schedule->isEnabled()
81
-                        ]),
82
-                        'raw'       =>  $schedule->isEnabled() ? 1 : 0
83
-                    ],
84
-                    'task_name' =>  [
85
-                        'display'   =>  '<bdi>' . e($task_name) . '</bdi>',
86
-                        'raw'       =>  $task_name
87
-                    ],
88
-                    'last_run'  =>  [
89
-                        'display'   =>  $schedule->lastRunTime()->timestamp() === 0 ?
90
-                            view('components/datetime', ['timestamp' => $schedule->lastRunTime()]) :
91
-                            view('components/datetime-diff', ['timestamp' => $schedule->lastRunTime()]),
92
-                        'raw'       =>  $schedule->lastRunTime()->timestamp()
93
-                    ],
94
-                    'last_result'   =>  [
95
-                        'display'   => view($module_name . '::components/yes-no-icons', [
96
-                            'yes' => $schedule->wasLastRunSuccess()
97
-                        ]),
98
-                        'raw'       =>  $schedule->wasLastRunSuccess() ? 1 : 0
99
-                    ],
100
-                    'frequency' =>
101
-                        '<bdi>' . e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()) . '</bdi>',
102
-                    'nb_occurrences'    =>  $schedule->remainingOccurrences() > 0 ?
103
-                        I18N::number($schedule->remainingOccurrences()) :
104
-                        I18N::translate('Unlimited'),
105
-                    'running'   =>  view($module_name . '::components/yes-no-icons', [
106
-                        'yes' => $schedule->isRunning(),
107
-                        'text_yes' => I18N::translate('Running'),
108
-                        'text_no' => I18N::translate('Not running')
109
-                    ]),
110
-                    'run'       =>  view($module_name . '::admin/tasks-table-run', [
111
-                        'task_sched_id' => $schedule->id(),
112
-                        'run_route' => route(TaskTrigger::class, [
113
-                            'task'  =>  $schedule->taskId(),
114
-                            'force' =>  $module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN')
115
-                        ])
116
-                    ])
117
-                ];
118
-            })
119
-        ]);
120
-    }
68
+				return [
69
+					'edit' =>   view($module_name . '::admin/tasks-table-options', [
70
+						'task_sched_id' => $schedule->id(),
71
+						'task_sched_enabled' => $schedule->isEnabled(),
72
+						'task_edit_route' => route(TaskEditPage::class, ['task' => $schedule->id()]),
73
+						'task_status_route' => route(TaskStatusAction::class, [
74
+							'task' => $schedule->id(),
75
+							'enable' => $schedule->isEnabled() ? 0 : 1
76
+						])
77
+					]),
78
+					'status'    =>  [
79
+						'display'   =>  view($module_name . '::components/yes-no-icons', [
80
+							'yes' => $schedule->isEnabled()
81
+						]),
82
+						'raw'       =>  $schedule->isEnabled() ? 1 : 0
83
+					],
84
+					'task_name' =>  [
85
+						'display'   =>  '<bdi>' . e($task_name) . '</bdi>',
86
+						'raw'       =>  $task_name
87
+					],
88
+					'last_run'  =>  [
89
+						'display'   =>  $schedule->lastRunTime()->timestamp() === 0 ?
90
+							view('components/datetime', ['timestamp' => $schedule->lastRunTime()]) :
91
+							view('components/datetime-diff', ['timestamp' => $schedule->lastRunTime()]),
92
+						'raw'       =>  $schedule->lastRunTime()->timestamp()
93
+					],
94
+					'last_result'   =>  [
95
+						'display'   => view($module_name . '::components/yes-no-icons', [
96
+							'yes' => $schedule->wasLastRunSuccess()
97
+						]),
98
+						'raw'       =>  $schedule->wasLastRunSuccess() ? 1 : 0
99
+					],
100
+					'frequency' =>
101
+						'<bdi>' . e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()) . '</bdi>',
102
+					'nb_occurrences'    =>  $schedule->remainingOccurrences() > 0 ?
103
+						I18N::number($schedule->remainingOccurrences()) :
104
+						I18N::translate('Unlimited'),
105
+					'running'   =>  view($module_name . '::components/yes-no-icons', [
106
+						'yes' => $schedule->isRunning(),
107
+						'text_yes' => I18N::translate('Running'),
108
+						'text_no' => I18N::translate('Not running')
109
+					]),
110
+					'run'       =>  view($module_name . '::admin/tasks-table-run', [
111
+						'task_sched_id' => $schedule->id(),
112
+						'run_route' => route(TaskTrigger::class, [
113
+							'task'  =>  $schedule->taskId(),
114
+							'force' =>  $module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN')
115
+						])
116
+					])
117
+				];
118
+			})
119
+		]);
120
+	}
121 121
 }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TaskStatusAction.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,70 +30,70 @@
 block discarded – undo
30 30
  */
31 31
 class TaskStatusAction implements RequestHandlerInterface
32 32
 {
33
-    private ?AdminTasksModule $module;
34
-    private TaskScheduleService $taskschedules_service;
33
+	private ?AdminTasksModule $module;
34
+	private TaskScheduleService $taskschedules_service;
35 35
 
36
-    /**
37
-     * Constructor for TaskStatusAction Request Handler
38
-     *
39
-     * @param ModuleService $module_service
40
-     * @param TaskScheduleService $taskschedules_service
41
-     */
42
-    public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
43
-    {
44
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
45
-        $this->taskschedules_service = $taskschedules_service;
46
-    }
36
+	/**
37
+	 * Constructor for TaskStatusAction Request Handler
38
+	 *
39
+	 * @param ModuleService $module_service
40
+	 * @param TaskScheduleService $taskschedules_service
41
+	 */
42
+	public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
43
+	{
44
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
45
+		$this->taskschedules_service = $taskschedules_service;
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
51
-     */
52
-    public function handle(ServerRequestInterface $request): ResponseInterface
53
-    {
54
-        $admin_config_route = route(AdminConfigPage::class);
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
51
+	 */
52
+	public function handle(ServerRequestInterface $request): ResponseInterface
53
+	{
54
+		$admin_config_route = route(AdminConfigPage::class);
55 55
 
56
-        if ($this->module === null) {
57
-            FlashMessages::addMessage(
58
-                I18N::translate('The attached module could not be found.'),
59
-                'danger'
60
-            );
61
-            return redirect($admin_config_route);
62
-        }
56
+		if ($this->module === null) {
57
+			FlashMessages::addMessage(
58
+				I18N::translate('The attached module could not be found.'),
59
+				'danger'
60
+			);
61
+			return redirect($admin_config_route);
62
+		}
63 63
 
64
-        $task_sched_id = Validator::attributes($request)->integer('task', -1);
65
-        $task_schedule = $this->taskschedules_service->find($task_sched_id);
64
+		$task_sched_id = Validator::attributes($request)->integer('task', -1);
65
+		$task_schedule = $this->taskschedules_service->find($task_sched_id);
66 66
 
67
-        $admin_config_route = route(AdminConfigPage::class);
67
+		$admin_config_route = route(AdminConfigPage::class);
68 68
 
69
-        if ($task_schedule === null) {
70
-            FlashMessages::addMessage(
71
-                I18N::translate('The task shedule with ID “%s” does not exist.', I18N::number($task_sched_id)),
72
-                'danger'
73
-            );
74
-            return redirect($admin_config_route);
75
-        }
69
+		if ($task_schedule === null) {
70
+			FlashMessages::addMessage(
71
+				I18N::translate('The task shedule with ID “%s” does not exist.', I18N::number($task_sched_id)),
72
+				'danger'
73
+			);
74
+			return redirect($admin_config_route);
75
+		}
76 76
 
77
-        Validator::attributes($request)->boolean('enable', false) ?
78
-            $task_schedule->enable() :
79
-            $task_schedule->disable();
77
+		Validator::attributes($request)->boolean('enable', false) ?
78
+			$task_schedule->enable() :
79
+			$task_schedule->disable();
80 80
 
81
-        if ($this->taskschedules_service->update($task_schedule) > 0) {
82
-            FlashMessages::addMessage(
83
-                I18N::translate('The scheduled task has been successfully updated.'),
84
-                'success'
85
-            );
86
-            //phpcs:ignore Generic.Files.LineLength.TooLong
87
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
88
-        } else {
89
-            FlashMessages::addMessage(
90
-                I18N::translate('An error occured while updating the scheduled task.'),
91
-                'danger'
92
-            );
93
-            //phpcs:ignore Generic.Files.LineLength.TooLong
94
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
95
-        }
81
+		if ($this->taskschedules_service->update($task_schedule) > 0) {
82
+			FlashMessages::addMessage(
83
+				I18N::translate('The scheduled task has been successfully updated.'),
84
+				'success'
85
+			);
86
+			//phpcs:ignore Generic.Files.LineLength.TooLong
87
+			Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
88
+		} else {
89
+			FlashMessages::addMessage(
90
+				I18N::translate('An error occured while updating the scheduled task.'),
91
+				'danger'
92
+			);
93
+			//phpcs:ignore Generic.Files.LineLength.TooLong
94
+			Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
95
+		}
96 96
 
97
-        return redirect($admin_config_route);
98
-    }
97
+		return redirect($admin_config_route);
98
+	}
99 99
 }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TaskEditAction.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -34,148 +34,148 @@
 block discarded – undo
34 34
  */
35 35
 class TaskEditAction implements RequestHandlerInterface
36 36
 {
37
-    private ?AdminTasksModule $module;
38
-    private TaskScheduleService $taskschedules_service;
39
-
40
-    /**
41
-     * Constructor for TaskEditAction Request Handler
42
-     *
43
-     * @param ModuleService $module_service
44
-     * @param TaskScheduleService $taskschedules_service
45
-     */
46
-    public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
47
-    {
48
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
49
-        $this->taskschedules_service = $taskschedules_service;
50
-    }
51
-
52
-    /**
53
-     * {@inheritDoc}
54
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
55
-     */
56
-    public function handle(ServerRequestInterface $request): ResponseInterface
57
-    {
58
-        $admin_config_route = route(AdminConfigPage::class);
59
-
60
-        if ($this->module === null) {
61
-            FlashMessages::addMessage(
62
-                I18N::translate('The attached module could not be found.'),
63
-                'danger'
64
-            );
65
-            return redirect($admin_config_route);
66
-        }
67
-
68
-        $task_sched_id = Validator::attributes($request)->integer('task', -1);
69
-        $task_schedule = $this->taskschedules_service->find($task_sched_id);
70
-
71
-        if ($task_schedule === null) {
72
-            FlashMessages::addMessage(
73
-                I18N::translate('The task shedule with ID “%s” does not exist.', I18N::number($task_sched_id)),
74
-                'danger'
75
-            );
76
-            return redirect($admin_config_route);
77
-        }
78
-
79
-        $success = $this->updateGeneralSettings($task_schedule, $request);
80
-        $success = $success && $this->updateSpecificSettings($task_schedule, $request);
81
-
82
-        if ($success) {
83
-            FlashMessages::addMessage(
84
-                I18N::translate('The scheduled task has been successfully updated.'),
85
-                'success'
86
-            );
87
-            //phpcs:ignore Generic.Files.LineLength.TooLong
88
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
89
-        }
90
-
91
-        return redirect($admin_config_route);
92
-    }
93
-
94
-    /**
95
-     * Update general settings for the task, based on the request parameters
96
-     *
97
-     * @param TaskSchedule $task_schedule
98
-     * @param ServerRequestInterface $request
99
-     * @return bool
100
-     */
101
-    private function updateGeneralSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool
102
-    {
103
-        if ($this->module === null) {
104
-            return false;
105
-        }
106
-
107
-        $frequency = Validator::parsedBody($request)->integer('frequency', 0);
108
-        if ($frequency > 0) {
109
-            $task_schedule->setFrequency($frequency);
110
-        } else {
111
-            FlashMessages::addMessage(I18N::translate('The frequency is not in a valid format.'), 'danger');
112
-        }
113
-
114
-        $is_limited = Validator::parsedBody($request)->boolean('is_limited', false);
115
-        $nb_occur = Validator::parsedBody($request)->integer('nb_occur', 1);
116
-        if ($is_limited) {
117
-            if ($nb_occur > 0) {
118
-                $task_schedule->setRemainingOccurrences($nb_occur);
119
-            } else {
120
-                FlashMessages::addMessage(
121
-                    I18N::translate('The number of remaining occurrences is not in a valid format.'),
122
-                    'danger'
123
-                );
124
-            }
125
-        } else {
126
-            $task_schedule->setRemainingOccurrences(0);
127
-        }
128
-
129
-        try {
130
-            $this->taskschedules_service->update($task_schedule);
131
-            return true;
132
-        } catch (Throwable $ex) {
133
-            Log::addErrorLog(
134
-                sprintf(
135
-                    'Error while updating the Task Schedule "%s". Exception: %s',
136
-                    $task_schedule->id(),
137
-                    $ex->getMessage()
138
-                )
139
-            );
140
-        }
141
-
142
-        FlashMessages::addMessage(I18N::translate('An error occured while updating the scheduled task.'), 'danger');
143
-        //@phpcs:ignore Generic.Files.LineLength.TooLong
144
-        Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
145
-        return false;
146
-    }
147
-
148
-    /**
149
-     * Update general settings for the task, based on the request parameters
150
-     *
151
-     * @param TaskSchedule $task_schedule
152
-     * @param ServerRequestInterface $request
153
-     * @return bool
154
-     */
155
-    private function updateSpecificSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool
156
-    {
157
-        if ($this->module === null) {
158
-            return false;
159
-        }
160
-
161
-        $task = $this->taskschedules_service->findTask($task_schedule->taskId());
162
-        if ($task === null || !($task instanceof ConfigurableTaskInterface)) {
163
-            return true;
164
-        }
165
-
166
-        /** @var \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface&\MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface $task */
167
-        if (!$task->updateConfig($request, $task_schedule)) {
168
-            FlashMessages::addMessage(
169
-                I18N::translate(
170
-                    'An error occured while updating the specific settings of administrative task “%s”.',
171
-                    $task->name()
172
-                ),
173
-                'danger'
174
-            );
175
-            //phpcs:ignore Generic.Files.LineLength.TooLong
176
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : AdminTask “' . $task->name() . '” specific settings could not be updated. See error log.');
177
-        }
178
-
179
-        return true;
180
-    }
37
+	private ?AdminTasksModule $module;
38
+	private TaskScheduleService $taskschedules_service;
39
+
40
+	/**
41
+	 * Constructor for TaskEditAction Request Handler
42
+	 *
43
+	 * @param ModuleService $module_service
44
+	 * @param TaskScheduleService $taskschedules_service
45
+	 */
46
+	public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
47
+	{
48
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
49
+		$this->taskschedules_service = $taskschedules_service;
50
+	}
51
+
52
+	/**
53
+	 * {@inheritDoc}
54
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
55
+	 */
56
+	public function handle(ServerRequestInterface $request): ResponseInterface
57
+	{
58
+		$admin_config_route = route(AdminConfigPage::class);
59
+
60
+		if ($this->module === null) {
61
+			FlashMessages::addMessage(
62
+				I18N::translate('The attached module could not be found.'),
63
+				'danger'
64
+			);
65
+			return redirect($admin_config_route);
66
+		}
67
+
68
+		$task_sched_id = Validator::attributes($request)->integer('task', -1);
69
+		$task_schedule = $this->taskschedules_service->find($task_sched_id);
70
+
71
+		if ($task_schedule === null) {
72
+			FlashMessages::addMessage(
73
+				I18N::translate('The task shedule with ID “%s” does not exist.', I18N::number($task_sched_id)),
74
+				'danger'
75
+			);
76
+			return redirect($admin_config_route);
77
+		}
78
+
79
+		$success = $this->updateGeneralSettings($task_schedule, $request);
80
+		$success = $success && $this->updateSpecificSettings($task_schedule, $request);
81
+
82
+		if ($success) {
83
+			FlashMessages::addMessage(
84
+				I18N::translate('The scheduled task has been successfully updated.'),
85
+				'success'
86
+			);
87
+			//phpcs:ignore Generic.Files.LineLength.TooLong
88
+			Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
89
+		}
90
+
91
+		return redirect($admin_config_route);
92
+	}
93
+
94
+	/**
95
+	 * Update general settings for the task, based on the request parameters
96
+	 *
97
+	 * @param TaskSchedule $task_schedule
98
+	 * @param ServerRequestInterface $request
99
+	 * @return bool
100
+	 */
101
+	private function updateGeneralSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool
102
+	{
103
+		if ($this->module === null) {
104
+			return false;
105
+		}
106
+
107
+		$frequency = Validator::parsedBody($request)->integer('frequency', 0);
108
+		if ($frequency > 0) {
109
+			$task_schedule->setFrequency($frequency);
110
+		} else {
111
+			FlashMessages::addMessage(I18N::translate('The frequency is not in a valid format.'), 'danger');
112
+		}
113
+
114
+		$is_limited = Validator::parsedBody($request)->boolean('is_limited', false);
115
+		$nb_occur = Validator::parsedBody($request)->integer('nb_occur', 1);
116
+		if ($is_limited) {
117
+			if ($nb_occur > 0) {
118
+				$task_schedule->setRemainingOccurrences($nb_occur);
119
+			} else {
120
+				FlashMessages::addMessage(
121
+					I18N::translate('The number of remaining occurrences is not in a valid format.'),
122
+					'danger'
123
+				);
124
+			}
125
+		} else {
126
+			$task_schedule->setRemainingOccurrences(0);
127
+		}
128
+
129
+		try {
130
+			$this->taskschedules_service->update($task_schedule);
131
+			return true;
132
+		} catch (Throwable $ex) {
133
+			Log::addErrorLog(
134
+				sprintf(
135
+					'Error while updating the Task Schedule "%s". Exception: %s',
136
+					$task_schedule->id(),
137
+					$ex->getMessage()
138
+				)
139
+			);
140
+		}
141
+
142
+		FlashMessages::addMessage(I18N::translate('An error occured while updating the scheduled task.'), 'danger');
143
+		//@phpcs:ignore Generic.Files.LineLength.TooLong
144
+		Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
145
+		return false;
146
+	}
147
+
148
+	/**
149
+	 * Update general settings for the task, based on the request parameters
150
+	 *
151
+	 * @param TaskSchedule $task_schedule
152
+	 * @param ServerRequestInterface $request
153
+	 * @return bool
154
+	 */
155
+	private function updateSpecificSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool
156
+	{
157
+		if ($this->module === null) {
158
+			return false;
159
+		}
160
+
161
+		$task = $this->taskschedules_service->findTask($task_schedule->taskId());
162
+		if ($task === null || !($task instanceof ConfigurableTaskInterface)) {
163
+			return true;
164
+		}
165
+
166
+		/** @var \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface&\MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface $task */
167
+		if (!$task->updateConfig($request, $task_schedule)) {
168
+			FlashMessages::addMessage(
169
+				I18N::translate(
170
+					'An error occured while updating the specific settings of administrative task “%s”.',
171
+					$task->name()
172
+				),
173
+				'danger'
174
+			);
175
+			//phpcs:ignore Generic.Files.LineLength.TooLong
176
+			Log::addConfigurationLog('Module ' . $this->module->title() . ' : AdminTask “' . $task->name() . '” specific settings could not be updated. See error log.');
177
+		}
178
+
179
+		return true;
180
+	}
181 181
 }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TaskEditPage.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -31,58 +31,58 @@
 block discarded – undo
31 31
  */
32 32
 class TaskEditPage implements RequestHandlerInterface
33 33
 {
34
-    use ViewResponseTrait;
34
+	use ViewResponseTrait;
35 35
 
36
-    private ?AdminTasksModule $module;
37
-    private TaskScheduleService $taskschedules_service;
36
+	private ?AdminTasksModule $module;
37
+	private TaskScheduleService $taskschedules_service;
38 38
 
39
-    /**
40
-     * Constructor for TaskEditPage Request Handler
41
-     *
42
-     * @param ModuleService $module_service
43
-     * @param TaskScheduleService $taskschedules_service
44
-     */
45
-    public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
46
-    {
47
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
48
-        $this->taskschedules_service = $taskschedules_service;
49
-    }
39
+	/**
40
+	 * Constructor for TaskEditPage Request Handler
41
+	 *
42
+	 * @param ModuleService $module_service
43
+	 * @param TaskScheduleService $taskschedules_service
44
+	 */
45
+	public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
46
+	{
47
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
48
+		$this->taskschedules_service = $taskschedules_service;
49
+	}
50 50
 
51
-    /**
52
-     * {@inheritDoc}
53
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
54
-     */
55
-    public function handle(ServerRequestInterface $request): ResponseInterface
56
-    {
57
-        $this->layout = 'layouts/administration';
51
+	/**
52
+	 * {@inheritDoc}
53
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
54
+	 */
55
+	public function handle(ServerRequestInterface $request): ResponseInterface
56
+	{
57
+		$this->layout = 'layouts/administration';
58 58
 
59
-        if ($this->module === null) {
60
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
61
-        }
59
+		if ($this->module === null) {
60
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
61
+		}
62 62
 
63
-        $task_sched_id = Validator::attributes($request)->integer('task', -1);
64
-        $task_schedule = $this->taskschedules_service->find($task_sched_id);
63
+		$task_sched_id = Validator::attributes($request)->integer('task', -1);
64
+		$task_schedule = $this->taskschedules_service->find($task_sched_id);
65 65
 
66
-        if ($task_schedule === null) {
67
-            throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.'));
68
-        }
66
+		if ($task_schedule === null) {
67
+			throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.'));
68
+		}
69 69
 
70
-        $task = $this->taskschedules_service->findTask($task_schedule->taskId());
70
+		$task = $this->taskschedules_service->findTask($task_schedule->taskId());
71 71
 
72
-        if ($task === null) {
73
-            throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.'));
74
-        }
72
+		if ($task === null) {
73
+			throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.'));
74
+		}
75 75
 
76
-        $has_task_config = $task instanceof ConfigurableTaskInterface;
77
-        /** @var \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface&\MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface $task */
76
+		$has_task_config = $task instanceof ConfigurableTaskInterface;
77
+		/** @var \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface&\MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface $task */
78 78
 
79
-        return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [
80
-            'module'            =>  $this->module,
81
-            'title'             =>  I18N::translate('Edit the administrative task') . ' - ' . $task->name(),
82
-            'task_schedule'     =>  $task_schedule,
83
-            'task'              =>  $task,
84
-            'has_task_config'   =>  $has_task_config,
85
-            'task_config_view'  =>  $has_task_config ? $task->configView($request) : ''
86
-        ]);
87
-    }
79
+		return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [
80
+			'module'            =>  $this->module,
81
+			'title'             =>  I18N::translate('Edit the administrative task') . ' - ' . $task->name(),
82
+			'task_schedule'     =>  $task_schedule,
83
+			'task'              =>  $task,
84
+			'has_task_config'   =>  $has_task_config,
85
+			'task_config_view'  =>  $has_task_config ? $task->configView($request) : ''
86
+		]);
87
+	}
88 88
 }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TaskTrigger.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -29,41 +29,41 @@
 block discarded – undo
29 29
  */
30 30
 class TaskTrigger implements RequestHandlerInterface
31 31
 {
32
-    private ?AdminTasksModule $module;
33
-    private TaskScheduleService $taskschedules_service;
32
+	private ?AdminTasksModule $module;
33
+	private TaskScheduleService $taskschedules_service;
34 34
 
35
-    /**
36
-     * Constructor for TaskTrigger request handler
37
-     * @param ModuleService $module_service
38
-     * @param TaskScheduleService $taskschedules_service
39
-     */
40
-    public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
41
-    {
42
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
43
-        $this->taskschedules_service = $taskschedules_service;
44
-    }
35
+	/**
36
+	 * Constructor for TaskTrigger request handler
37
+	 * @param ModuleService $module_service
38
+	 * @param TaskScheduleService $taskschedules_service
39
+	 */
40
+	public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
41
+	{
42
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
43
+		$this->taskschedules_service = $taskschedules_service;
44
+	}
45 45
 
46
-    /**
47
-     * {@inheritDoc}
48
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
-     */
50
-    public function handle(ServerRequestInterface $request): ResponseInterface
51
-    {
52
-        if ($this->module === null) {
53
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
54
-        }
46
+	/**
47
+	 * {@inheritDoc}
48
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
+	 */
50
+	public function handle(ServerRequestInterface $request): ResponseInterface
51
+	{
52
+		if ($this->module === null) {
53
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
54
+		}
55 55
 
56
-        $task_id = Validator::attributes($request)->string('task', '');
57
-        $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
58
-        $force_token = Validator::queryParams($request)->string('force', '');
59
-        $force = $token == $force_token;
56
+		$task_id = Validator::attributes($request)->string('task', '');
57
+		$token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
58
+		$force_token = Validator::queryParams($request)->string('force', '');
59
+		$force = $token == $force_token;
60 60
 
61
-        $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id);
61
+		$task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id);
62 62
 
63
-        foreach ($task_schedules as $task_schedule) {
64
-            $this->taskschedules_service->run($task_schedule, $force);
65
-        }
63
+		foreach ($task_schedules as $task_schedule) {
64
+			$this->taskschedules_service->run($task_schedule, $force);
65
+		}
66 66
 
67
-        return response();
68
-    }
67
+		return response();
68
+	}
69 69
 }
Please login to merge, or discard this patch.