Skip to content

Commit 91dde9e

Browse files
committed
Cleaning core file structure
1 parent 15e26f8 commit 91dde9e

File tree

302 files changed

+869
-1024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+869
-1024
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ We are using the [PSR-12 coding style](https://www.php-fig.org/psr/psr-12/) for
5757
As mentioned above we are following PSR-12 naming conventions. Some areas are not covered in the standard and will be covered in this section. For sake of completion we include all naming conventions in this section.
5858

5959
**Classes**
60-
Pascal Case (Example: `Leantime.Core.FrontController`
60+
Pascal Case (Example: `leantime.core.controller.frontcontroller`
6161

6262
**Class Methods**
6363
Camel Case (Example: `$object->getItem()`

app/Command/BackupDbCommand.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
namespace Leantime\Command;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
6+
use Leantime\Core\Configuration\Environment;
7+
use Symfony\Component\Console\Attribute\AsCommand;
68
use Symfony\Component\Console\Command\Command;
79
use Symfony\Component\Console\Input\InputInterface;
810
use Symfony\Component\Console\Output\OutputInterface;
911
use Symfony\Component\Console\Style\SymfonyStyle;
10-
use Leantime\Domain\Install\Repositories\Install;
11-
use Symfony\Component\Console\Attribute\AsCommand;
12-
use Leantime\Core\Environment;
1312

1413
use function PHPUnit\Framework\directoryExists;
1514

app/Command/TestEmailCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
namespace Leantime\Command;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
6-
use Leantime\Core\Environment;
6+
use Leantime\Core\Configuration\Environment;
7+
use Leantime\Core\Mailer;
8+
use Symfony\Component\Console\Attribute\AsCommand;
79
use Symfony\Component\Console\Command\Command;
810
use Symfony\Component\Console\Input\InputInterface;
911
use Symfony\Component\Console\Input\InputOption;
1012
use Symfony\Component\Console\Output\OutputInterface;
1113
use Symfony\Component\Console\Style\SymfonyStyle;
12-
use Leantime\Core\Mailer;
13-
use Symfony\Component\Console\Attribute\AsCommand;
1414

1515
/**
1616
* Class TestEmailCommand

app/Command/UpdateLeantime.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
namespace Leantime\Command;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
6+
use Leantime\Core\Configuration\AppSettings;
7+
use Symfony\Component\Console\Attribute\AsCommand;
68
use Symfony\Component\Console\Command\Command;
9+
use Symfony\Component\Console\Input\ArrayInput;
710
use Symfony\Component\Console\Input\InputInterface;
811
use Symfony\Component\Console\Input\InputOption;
912
use Symfony\Component\Console\Output\OutputInterface;
1013
use Symfony\Component\Console\Style\SymfonyStyle;
11-
use Leantime\Domain\Install\Repositories\Install;
12-
use Symfony\Component\Console\Attribute\AsCommand;
13-
use Leantime\Core\AppSettings;
14-
use Leantime\Core\Environment;
15-
use Symfony\Component\Console\Input\ArrayInput;
1614

1715
/**
1816
* Class UpdateLeantime

app/Core/Application.php app/Core/Bootstrap/Application.php

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Bootstrap;
44

5-
use Illuminate\Cache\MemcachedConnector;
65
use Illuminate\Container\Container;
76
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
87
use Illuminate\Contracts\Container\Container as IlluminateContainerContract;
9-
use Illuminate\Support\Arr;
10-
use Illuminate\Support\ServiceProvider;
118
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
12-
use Illuminate\Support\Facades\Cache;
9+
use Illuminate\Support\Arr;
1310
use Illuminate\Support\Facades\Facade;
14-
use Leantime\Domain\Auth\Services\Auth as AuthService;
11+
use Illuminate\Support\ServiceProvider;
12+
use Leantime\Core\Configuration\Environment;
13+
use Leantime\Core\Console\CliRequest;
14+
use Leantime\Core\Console\ConsoleKernel;
15+
use Leantime\Core\Controller\Frontcontroller;
16+
use Leantime\Core\Events\EventDispatcher;
17+
use Leantime\Core\Exceptions\ExceptionHandler;
18+
use Leantime\Core\Http\ApiRequest;
19+
use Leantime\Core\Http\HtmxRequest;
20+
use Leantime\Core\Http\HttpKernel;
21+
use Leantime\Core\Http\IncomingRequest;
1522
use Leantime\Domain\Modulemanager\Services\Modulemanager as ModulemanagerService;
16-
use Leantime\Domain\Oidc\Services\Oidc as OidcService;
17-
use Leantime\Domain\Setting\Services\Setting as SettingsService;
1823
use Psr\Container\ContainerInterface as PsrContainerContract;
19-
use Symfony\Component\ErrorHandler\Debug;
2024

2125
/**
2226
* Application Class - IoC Container for the application
@@ -94,7 +98,7 @@ public function __construct()
9498

9599
Facade::setFacadeApplication($this);
96100

97-
Events::discover_listeners();
101+
EventDispatcher::discover_listeners();
98102

99103
$this->boot();
100104
}
@@ -212,7 +216,7 @@ private function registerCoreAliases(): void
212216

213217
$this->alias(\Illuminate\Encryption\Encrypter::class, "encrypter");
214218

215-
$this->alias(\Leantime\Core\Events::class, 'events');
219+
$this->alias(\Leantime\Core\Events\EventDispatcher::class, 'events');
216220
}
217221

218222
/**

app/Core/Bootloader.php app/Core/Bootstrap/Bootloader.php

+6-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Bootstrap;
44

55
use GuzzleHttp\Promise\PromiseInterface;
6-
use Illuminate\Cache\MemcachedConnector;
7-
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
86
use Illuminate\Contracts\Container\BindingResolutionException;
9-
use Illuminate\Contracts\Container\Container as IlluminateContainerContract;
10-
use Illuminate\Contracts\Encryption\Encrypter;
11-
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
12-
use Illuminate\Redis\RedisManager;
13-
use Illuminate\Session\SessionManager;
14-
use Illuminate\Support\Facades\Cache;
15-
use Illuminate\Support\Facades\Crypt;
16-
use Illuminate\Support\Facades\Facade;
17-
use Illuminate\Support\Facades\Log;
18-
use Leantime\Domain\Auth\Services\Auth as AuthService;
19-
use Leantime\Domain\Modulemanager\Services\Modulemanager as ModulemanagerService;
20-
use Leantime\Domain\Oidc\Services\Oidc as OidcService;
21-
use Leantime\Domain\Setting\Services\Setting as SettingsService;
7+
use Leantime\Core\Console\CliRequest;
8+
use Leantime\Core\Console\ConsoleKernel;
9+
use Leantime\Core\Events\Eventhelpers;
10+
use Leantime\Core\Http\HttpKernel;
11+
use Leantime\Core\Http\IncomingRequest;
2212
use Psr\Container\ContainerInterface as PsrContainerContract;
23-
use Symfony\Component\ErrorHandler\Debug;
2413

2514
/**
2615
* Bootloader

app/Core/CliRequest.php

-8
This file was deleted.

app/Core/AppSettings.php app/Core/Configuration/AppSettings.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Configuration;
44

55
/**
66
* appSettings class - System appSettings

app/Core/DefaultConfig.php app/Core/Configuration/DefaultConfig.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Configuration;
44

55
/**
66
* Default Configuration Class

app/Core/Environment.php app/Core/Configuration/Environment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Configuration;
44

55
use ArrayAccess;
66
use Dotenv\Dotenv;

app/Core/Console/CliRequest.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Leantime\Core\Console;
4+
5+
use Leantime\Core\Http\IncomingRequest;
6+
7+
class CliRequest extends IncomingRequest
8+
{
9+
//
10+
}

app/Core/ConsoleKernel.php app/Core/Console/ConsoleKernel.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Console;
44

5+
use;
56
use Illuminate\Console\Command as LaravelCommand;
67
use Illuminate\Console\Scheduling\Schedule;
78
use Illuminate\Contracts\Console\Application as ConsoleApplicationContract;
@@ -10,6 +11,7 @@
1011
use Illuminate\Support\Arr;
1112
use Illuminate\Support\ProcessUtils;
1213
use Illuminate\Support\Str;
14+
use Leantime\Core\Events\Eventhelpers;
1315
use Leantime\Domain\Plugins\Services\Plugins as PluginsService;
1416
use Symfony\Component\Console\Application as ConsoleApplication;
1517
use Symfony\Component\Console\Command\Command as SymfonyCommand;

app/Core/Service.php app/Core/Contracts/Service.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Contracts;
44

55
/**
66
* Service Interface - Base interface for all services
@@ -65,5 +65,5 @@ public function get(int $id);
6565
* @param array|null $searchparams Search parameters
6666
* @return array|false Returns array on success, false on failure. No results should return empty array
6767
*/
68-
public function getAll(array $searchparams = null);
68+
public function query(array $searchparams = null);
6969
}

app/Core/Composer.php app/Core/Controller/Composer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Controller;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
66
use Illuminate\Support\Fluent;

app/Core/Controller.php app/Core/Controller/Controller.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Controller;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
66
use Illuminate\Http\Exceptions\HttpResponseException;
7+
use Leantime\Core\Events\Eventhelpers;
8+
use Leantime\Core\Http\IncomingRequest;
9+
use Leantime\Core\Language;
10+
use Leantime\Core\Template;
711
use Symfony\Component\HttpFoundation\Response;
812

913
/**

app/Core/Frontcontroller.php app/Core/Controller/Frontcontroller.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Controller;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
66
use Illuminate\Support\Str;
7+
use Leantime\Core\Events\Eventhelpers;
8+
use Leantime\Core\Http\HtmxRequest;
9+
use Leantime\Core\Http\IncomingRequest;
710
use Symfony\Component\HttpFoundation\RedirectResponse;
811
use Symfony\Component\HttpFoundation\Response;
912

app/Core/HtmxController.php app/Core/Controller/HtmxController.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Controller;
44

55
use Error;
66
use Illuminate\Contracts\Container\BindingResolutionException;
77
use Illuminate\Support\Str;
8+
use Leantime\Core\Events\Eventhelpers;
9+
use Leantime\Core\Http\IncomingRequest;
10+
use Leantime\Core\Template;
811
use LogicException;
912
use Symfony\Component\HttpFoundation\Response;
1013

app/Core/Db.php app/Core/Db/Db.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Db;
44

5+
use Leantime\Core\Configuration\Environment;
6+
use Leantime\Core\Console\CliRequest;
7+
use Leantime\Core\Events\Eventhelpers;
8+
use Leantime\Core\Http\IncomingRequest;
59
use PDO;
610
use PDOException;
711

app/Core/Repository.php app/Core/Db/Repository.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Db;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
6+
use Leantime\Core\Events\Eventhelpers;
67
use PDO;
78
use PDOStatement;
89
use ReflectionClass;

app/Core/Events.php app/Core/Events/EventDispatcher.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?php
22

3-
namespace Leantime\Core;
3+
namespace Leantime\Core\Events;
44

55
use Illuminate\Contracts\Container\BindingResolutionException;
66
use Illuminate\Contracts\Events\Dispatcher;
77
use Illuminate\Log\Events\MessageLogged;
88
use Illuminate\Support\Facades\Cache;
9+
use Leantime\Core\Configuration\Environment;
10+
use Leantime\Core\Controller\Frontcontroller;
911

1012
/**
11-
* Events class - Handles all events and filters
13+
* EventDispatcher class - Handles all events and filters
1214
*
1315
* @package leantime
1416
* @subpackage core
1517
*/
16-
class Events implements Dispatcher
18+
class EventDispatcher implements Dispatcher
1719
{
1820
/**
1921
* Registry of all events added to a hook
@@ -184,7 +186,7 @@ public static function discover_listeners(): void
184186

185187
if(!config('debug')) {
186188
$modules = Cache::store('installation')->rememberForever('domainEvents', function () {
187-
return Events::getDomainPaths();
189+
return EventDispatcher::getDomainPaths();
188190
});
189191

190192
}else{
@@ -209,7 +211,7 @@ public static function discover_listeners(): void
209211
}
210212
}
211213

212-
Events::add_event_listener('leantime.core.middleware.installed.handle.after_install', function () {
214+
EventDispatcher::add_event_listener('leantime.core.middleware.installed.handle.after_install', function () {
213215
if (! session("isInstalled")) {
214216
return;
215217
}

app/Core/Eventhelpers.php app/Core/Events/Eventhelpers.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Leantime\Core {
3+
namespace Leantime\Core\Events {
44

55
use Exception;
66
use Illuminate\Contracts\Container\BindingResolutionException;
@@ -25,7 +25,7 @@ trait Eventhelpers
2525
*/
2626
public static function dispatch_event(string $hook, mixed $available_params = [], string|int $function = null): void
2727
{
28-
Events::dispatch_event($hook, $available_params, static::get_event_context($function));
28+
EventDispatcher::dispatch_event($hook, $available_params, static::get_event_context($function));
2929
}
3030

3131
/**
@@ -42,7 +42,7 @@ public static function dispatch_event(string $hook, mixed $available_params = []
4242
*/
4343
public static function dispatch_filter(string $hook, mixed $payload, mixed $available_params = [], string|int $function = null): mixed
4444
{
45-
return Events::dispatch_filter($hook, $payload, $available_params, static::get_event_context($function));
45+
return EventDispatcher::dispatch_filter($hook, $payload, $available_params, static::get_event_context($function));
4646
}
4747

4848
/**

0 commit comments

Comments
 (0)