Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .tools/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@

// use original error handlers of the tools
ErrorHandler::unregister();

return $project;
6 changes: 2 additions & 4 deletions .tools/phpstan/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
use Redaxo\Core\Console\Application;
use Redaxo\Core\Console\CommandLoader;

if (!defined('REX_MIN_PHP_VERSION')) {
require dirname(__DIR__) . '/bootstrap.php';
}
$project = require dirname(__DIR__) . '/bootstrap.php';

$application = new Application();
$application = new Application($project);
$application->setCommandLoader(new CommandLoader());

return $application;
10 changes: 10 additions & 0 deletions boot/addons.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php

use Redaxo\Core\AbstractProject;
use Redaxo\Core\Addon\Addon;
use Redaxo\Core\Core;
use Redaxo\Core\ExtensionPoint\Extension;
use Redaxo\Core\ExtensionPoint\ExtensionPoint;
use Redaxo\Core\Util\Timer;

/**
* @psalm-scope-this AbstractProject
* @var AbstractProject $this
*/

Addon::initialize(!Core::isSetup());

if (Core::isSetup() || Core::isSafeMode()) {
Expand All @@ -20,6 +26,8 @@
Addon::require($packageId)->enlist();
}

$this->enlist();

// now we actually include the addons logic
Timer::measure('packages_boot', static function () use ($packageOrder) {
foreach ($packageOrder as $packageId) {
Expand All @@ -31,3 +39,5 @@

// ----- all addons configs included
Extension::registerPoint(new ExtensionPoint('PACKAGES_INCLUDED'));

$this->boot();
10 changes: 9 additions & 1 deletion boot/console.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<?php

use Redaxo\Core\AbstractProject;
use Redaxo\Core\Addon\Addon;
use Redaxo\Core\Console\Application;
use Redaxo\Core\Console\Command\ListCommand;
use Redaxo\Core\Console\CommandLoader;
use Redaxo\Core\Core;
use Redaxo\Core\Translation\I18n;

/**
* @psalm-scope-this AbstractProject
* @var AbstractProject $this
*/

// force debug mode to enable output of notices/warnings and dump() function
Core::setProperty('debug', true);

Core::setProperty('lang', 'en_gb');
I18n::setLocale('en_gb');

$application = new Application();
$application = new Application($this);
Core::setProperty('console', $application);

Addon::initialize(!Core::isSetup());
Expand All @@ -22,6 +28,8 @@
foreach (Core::getPackageOrder() as $packageId) {
Addon::require($packageId)->enlist();
}

$this->enlist();
}

$application->setCommandLoader(new CommandLoader());
Expand Down
18 changes: 18 additions & 0 deletions src/AbstractProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
use Override;
use Redaxo\Core\Exception\LogicException;
use Redaxo\Core\Filesystem\DefaultPathProvider;
use Redaxo\Core\Filesystem\Path;
use Redaxo\Core\Translation\I18n;
use Redaxo\Core\View\Fragment;
use ReflectionObject;
use Symfony\Component\Runtime\RunnerInterface;
use Throwable;

use function dirname;
use function sprintf;

use const DIRECTORY_SEPARATOR;
use const STDERR;

abstract class AbstractProject implements RunnerInterface
Expand Down Expand Up @@ -54,6 +58,8 @@ public function __construct(
public readonly string $environment,
) {}

public function boot(): void {}

final public function bootCore(): void
{
if ('console' === $this->environment) {
Expand Down Expand Up @@ -81,6 +87,18 @@ final public function bootAddons(): void
require dirname(__DIR__) . '/boot/addons.php';
}

final public function enlist(): void
{
$folder = Path::base('/');

if (is_readable($folder . 'lang')) {
I18n::addDirectory($folder . 'lang');
}
if (is_readable($folder . 'fragments')) {
Fragment::addDirectory($folder . 'fragments' . DIRECTORY_SEPARATOR);
}
}

#[Override]
final public function run(): int
{
Expand Down
8 changes: 6 additions & 2 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Exception;
use Override;
use ParseError;
use Redaxo\Core\AbstractProject;
use Redaxo\Core\Addon\Addon;
use Redaxo\Core\Console\Command\AbstractCommand;
use Redaxo\Core\Console\Command\OnlySetupAddonsInterface;
Expand All @@ -31,8 +32,9 @@

class Application extends SymfonyApplication
{
public function __construct()
{
public function __construct(
private readonly AbstractProject $project,
) {
parent::__construct('REDAXO', Core::getVersion());
}

Expand Down Expand Up @@ -117,6 +119,8 @@ private function loadPackages(AbstractCommand $command): void
}

Extension::registerPoint(new ExtensionPoint('PACKAGES_INCLUDED'));

$this->project->boot();
}

private function checkConsoleUser(InputInterface $input, OutputInterface $output): void
Expand Down
Loading