Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Use composers autoloader for path retrieval #2750

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 9 additions & 21 deletions bin/drupal.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<?php

use Drupal\Console\Application;
use Drupal\Console\Bootstrap\Drupal;
use Drupal\Console\Bootstrap\Drupal as DrupalConsole;
use Drupal\Console\ConsoleApplication;
use Drupal\Console\ConsolePaths;

set_time_limit(0);
$consoleRoot = realpath(__DIR__.'/../') . '/';
$appRoot = getcwd() . '/';
$siteRoot = realpath(__DIR__.'/../../../../') . '/';
$root = $appRoot;

$autoLoadFile = $appRoot.'/autoload.php';
$autoLoadFile = __DIR__ . '/../../../autoload.php';

if (file_exists($autoLoadFile)) {
$autoload = include_once $autoLoadFile;
$autoload = require_once $autoLoadFile;
} else {
echo PHP_EOL .
' Something goes wrong with your package.'.PHP_EOL.
Expand All @@ -23,20 +20,11 @@
exit(1);
}

if (!file_exists($appRoot.'composer.json')) {
$root = realpath($appRoot . '../') . '/';
}

if (!file_exists($root.'composer.json')) {
echo 'No composer.json file found at:' . PHP_EOL .
$root . PHP_EOL .
'you should try run this command,' . PHP_EOL .
'from project root directory.' . PHP_EOL;

exit(1);
}
$reflector = new ReflectionClass(Drupal::class);
$drupalRoot = dirname(dirname(dirname($reflector->getFileName())));
chdir($drupalRoot);

$drupal = new Drupal($autoload, $root, $appRoot);
$drupal = new DrupalConsole($autoload, $drupalRoot, ConsolePaths::consoleCore());
$container = $drupal->boot();

if (!$container) {
Expand Down
8 changes: 4 additions & 4 deletions src/Bootstrap/AddServicesCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public function process(ContainerBuilder $container)
new FileLocator($this->root)
);

$loader->load($this->root. DRUPAL_CONSOLE_CORE . 'services.yml');
$loader->load($this->root. DRUPAL_CONSOLE . 'services.yml');
$loader->load(DRUPAL_CONSOLE_CORE . '/services.yml');
$loader->load(DRUPAL_CONSOLE . '/services.yml');

$finder = new Finder();
$finder->files()
->name('*.yml')
->in(
sprintf(
'%s/config/services/drupal-console',
$this->root.DRUPAL_CONSOLE
DRUPAL_CONSOLE
)
);

Expand All @@ -71,7 +71,7 @@ public function process(ContainerBuilder $container)
->in(
sprintf(
'%s/config/services/drupal-core',
$this->root.DRUPAL_CONSOLE
DRUPAL_CONSOLE
)
);

Expand Down
4 changes: 2 additions & 2 deletions src/Bootstrap/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function boot()
$container->get('console.renderer')
->setSkeletonDirs(
[
$this->root.DRUPAL_CONSOLE.'/templates/',
$this->root.DRUPAL_CONSOLE_CORE.'/templates/'
DRUPAL_CONSOLE.'/templates/',
DRUPAL_CONSOLE_CORE.'/templates/'
]
);

Expand Down