Skip to content

Commit

Permalink
Cleaning core file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Aug 24, 2024
1 parent 15e26f8 commit 91dde9e
Show file tree
Hide file tree
Showing 302 changed files with 869 additions and 1,024 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ We are using the [PSR-12 coding style](https://www.php-fig.org/psr/psr-12/) for
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.

**Classes**
Pascal Case (Example: `Leantime.Core.FrontController`
Pascal Case (Example: `leantime.core.controller.frontcontroller`

**Class Methods**
Camel Case (Example: `$object->getItem()`
Expand Down
5 changes: 2 additions & 3 deletions app/Command/BackupDbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Leantime\Command;

use Illuminate\Contracts\Container\BindingResolutionException;
use Leantime\Core\Configuration\Environment;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Leantime\Domain\Install\Repositories\Install;
use Symfony\Component\Console\Attribute\AsCommand;
use Leantime\Core\Environment;

use function PHPUnit\Framework\directoryExists;

Expand Down
6 changes: 3 additions & 3 deletions app/Command/TestEmailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Leantime\Command;

use Illuminate\Contracts\Container\BindingResolutionException;
use Leantime\Core\Environment;
use Leantime\Core\Configuration\Environment;
use Leantime\Core\Mailer;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Leantime\Core\Mailer;
use Symfony\Component\Console\Attribute\AsCommand;

/**
* Class TestEmailCommand
Expand Down
8 changes: 3 additions & 5 deletions app/Command/UpdateLeantime.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
namespace Leantime\Command;

use Illuminate\Contracts\Container\BindingResolutionException;
use Leantime\Core\Configuration\AppSettings;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Leantime\Domain\Install\Repositories\Install;
use Symfony\Component\Console\Attribute\AsCommand;
use Leantime\Core\AppSettings;
use Leantime\Core\Environment;
use Symfony\Component\Console\Input\ArrayInput;

/**
* Class UpdateLeantime
Expand Down
26 changes: 15 additions & 11 deletions app/Core/Application.php → app/Core/Bootstrap/Application.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Bootstrap;

use Illuminate\Cache\MemcachedConnector;
use Illuminate\Container\Container;
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
use Illuminate\Contracts\Container\Container as IlluminateContainerContract;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Facade;
use Leantime\Domain\Auth\Services\Auth as AuthService;
use Illuminate\Support\ServiceProvider;
use Leantime\Core\Configuration\Environment;
use Leantime\Core\Console\CliRequest;
use Leantime\Core\Console\ConsoleKernel;
use Leantime\Core\Controller\Frontcontroller;
use Leantime\Core\Events\EventDispatcher;
use Leantime\Core\Exceptions\ExceptionHandler;
use Leantime\Core\Http\ApiRequest;
use Leantime\Core\Http\HtmxRequest;
use Leantime\Core\Http\HttpKernel;
use Leantime\Core\Http\IncomingRequest;
use Leantime\Domain\Modulemanager\Services\Modulemanager as ModulemanagerService;
use Leantime\Domain\Oidc\Services\Oidc as OidcService;
use Leantime\Domain\Setting\Services\Setting as SettingsService;
use Psr\Container\ContainerInterface as PsrContainerContract;
use Symfony\Component\ErrorHandler\Debug;

/**
* Application Class - IoC Container for the application
Expand Down Expand Up @@ -94,7 +98,7 @@ public function __construct()

Facade::setFacadeApplication($this);

Events::discover_listeners();
EventDispatcher::discover_listeners();

$this->boot();
}
Expand Down Expand Up @@ -212,7 +216,7 @@ private function registerCoreAliases(): void

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

$this->alias(\Leantime\Core\Events::class, 'events');
$this->alias(\Leantime\Core\Events\EventDispatcher::class, 'events');
}

/**
Expand Down
23 changes: 6 additions & 17 deletions app/Core/Bootloader.php → app/Core/Bootstrap/Bootloader.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Bootstrap;

use GuzzleHttp\Promise\PromiseInterface;
use Illuminate\Cache\MemcachedConnector;
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\Container\Container as IlluminateContainerContract;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
use Illuminate\Redis\RedisManager;
use Illuminate\Session\SessionManager;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Log;
use Leantime\Domain\Auth\Services\Auth as AuthService;
use Leantime\Domain\Modulemanager\Services\Modulemanager as ModulemanagerService;
use Leantime\Domain\Oidc\Services\Oidc as OidcService;
use Leantime\Domain\Setting\Services\Setting as SettingsService;
use Leantime\Core\Console\CliRequest;
use Leantime\Core\Console\ConsoleKernel;
use Leantime\Core\Events\Eventhelpers;
use Leantime\Core\Http\HttpKernel;
use Leantime\Core\Http\IncomingRequest;
use Psr\Container\ContainerInterface as PsrContainerContract;
use Symfony\Component\ErrorHandler\Debug;

/**
* Bootloader
Expand Down
8 changes: 0 additions & 8 deletions app/Core/CliRequest.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Configuration;

/**
* appSettings class - System appSettings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Configuration;

/**
* Default Configuration Class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Configuration;

use ArrayAccess;
use Dotenv\Dotenv;
Expand Down
10 changes: 10 additions & 0 deletions app/Core/Console/CliRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Leantime\Core\Console;

use Leantime\Core\Http\IncomingRequest;

class CliRequest extends IncomingRequest
{
//
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Console;

use;
use Illuminate\Console\Command as LaravelCommand;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Contracts\Console\Application as ConsoleApplicationContract;
Expand All @@ -10,6 +11,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\ProcessUtils;
use Illuminate\Support\Str;
use Leantime\Core\Events\Eventhelpers;
use Leantime\Domain\Plugins\Services\Plugins as PluginsService;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
Expand Down
4 changes: 2 additions & 2 deletions app/Core/Service.php → app/Core/Contracts/Service.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Contracts;

/**
* Service Interface - Base interface for all services
Expand Down Expand Up @@ -65,5 +65,5 @@ public function get(int $id);
* @param array|null $searchparams Search parameters
* @return array|false Returns array on success, false on failure. No results should return empty array
*/
public function getAll(array $searchparams = null);
public function query(array $searchparams = null);
}
2 changes: 1 addition & 1 deletion app/Core/Composer.php → app/Core/Controller/Composer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Controller;

use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Fluent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Controller;

use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Http\Exceptions\HttpResponseException;
use Leantime\Core\Events\Eventhelpers;
use Leantime\Core\Http\IncomingRequest;
use Leantime\Core\Language;
use Leantime\Core\Template;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Controller;

use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Str;
use Leantime\Core\Events\Eventhelpers;
use Leantime\Core\Http\HtmxRequest;
use Leantime\Core\Http\IncomingRequest;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Controller;

use Error;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Str;
use Leantime\Core\Events\Eventhelpers;
use Leantime\Core\Http\IncomingRequest;
use Leantime\Core\Template;
use LogicException;
use Symfony\Component\HttpFoundation\Response;

Expand Down
6 changes: 5 additions & 1 deletion app/Core/Db.php → app/Core/Db/Db.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Db;

use Leantime\Core\Configuration\Environment;
use Leantime\Core\Console\CliRequest;
use Leantime\Core\Events\Eventhelpers;
use Leantime\Core\Http\IncomingRequest;
use PDO;
use PDOException;

Expand Down
3 changes: 2 additions & 1 deletion app/Core/Repository.php → app/Core/Db/Repository.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Db;

use Illuminate\Contracts\Container\BindingResolutionException;
use Leantime\Core\Events\Eventhelpers;
use PDO;
use PDOStatement;
use ReflectionClass;
Expand Down
12 changes: 7 additions & 5 deletions app/Core/Events.php → app/Core/Events/EventDispatcher.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?php

namespace Leantime\Core;
namespace Leantime\Core\Events;

use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Log\Events\MessageLogged;
use Illuminate\Support\Facades\Cache;
use Leantime\Core\Configuration\Environment;
use Leantime\Core\Controller\Frontcontroller;

/**
* Events class - Handles all events and filters
* EventDispatcher class - Handles all events and filters
*
* @package leantime
* @subpackage core
*/
class Events implements Dispatcher
class EventDispatcher implements Dispatcher
{
/**
* Registry of all events added to a hook
Expand Down Expand Up @@ -184,7 +186,7 @@ public static function discover_listeners(): void

if(!config('debug')) {
$modules = Cache::store('installation')->rememberForever('domainEvents', function () {
return Events::getDomainPaths();
return EventDispatcher::getDomainPaths();
});

}else{
Expand All @@ -209,7 +211,7 @@ public static function discover_listeners(): void
}
}

Events::add_event_listener('leantime.core.middleware.installed.handle.after_install', function () {
EventDispatcher::add_event_listener('leantime.core.middleware.installed.handle.after_install', function () {
if (! session("isInstalled")) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Leantime\Core {
namespace Leantime\Core\Events {

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

/**
Expand All @@ -42,7 +42,7 @@ public static function dispatch_event(string $hook, mixed $available_params = []
*/
public static function dispatch_filter(string $hook, mixed $payload, mixed $available_params = [], string|int $function = null): mixed
{
return Events::dispatch_filter($hook, $payload, $available_params, static::get_event_context($function));
return EventDispatcher::dispatch_filter($hook, $payload, $available_params, static::get_event_context($function));
}

/**
Expand Down
Loading

0 comments on commit 91dde9e

Please sign in to comment.