Skip to content

[HttpKernel] Introduce KernelInterface::getProjectDir() #28901

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

Merged
merged 1 commit into from
Oct 17, 2018
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
5 changes: 2 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

/** @var KernelInterface $kernel */
$kernel = $this->getApplication()->getKernel();
$projectDir = $kernel->getContainer()->getParameter('kernel.project_dir');

$rows = array(
array('<info>Symfony</>'),
Expand All @@ -75,8 +74,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
array('Environment', $kernel->getEnvironment()),
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
array('Charset', $kernel->getCharset()),
array('Cache directory', self::formatPath($kernel->getCacheDir(), $projectDir).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
array('Log directory', self::formatPath($kernel->getLogDir(), $projectDir).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
new TableSeparator(),
array('<info>PHP</>'),
new TableSeparator(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* Command that places bundle web assets into a given directory.
Expand Down Expand Up @@ -89,11 +90,12 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var KernelInterface $kernel */
$kernel = $this->getApplication()->getKernel();
$targetArg = rtrim($input->getArgument('target'), '/');

if (!is_dir($targetArg)) {
$targetArg = $kernel->getContainer()->getParameter('kernel.project_dir').'/'.$targetArg;
$targetArg = $kernel->getProjectDir().'/'.$targetArg;

if (!is_dir($targetArg)) {
throw new InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/HttpKernel/KernelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* It manages an environment made of application kernel and bundles.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @method string getProjectDir() Gets the project dir (path of the project's composer file) - not defining it is deprecated since Symfony 4.2
*/
interface KernelInterface extends HttpKernelInterface, \Serializable
{
Expand Down