8.4.2: How to show warnings during package installation without elements?

Permalink
Hello.

In my package installation I check whether another non-compatible package is already installed. I do that in an elements/dashboard/install.php. And it's where I show a warning in that case. But if all is ok, that results in an empty page during the package install, it's like an additional empty step the user has to make. Is there any other way where I can show warnings prior to package installation to avoid using the element?

linuxoid
 
JohntheFish replied on at Permalink Reply
JohntheFish
Test at the start of the install method and throw an exception if you don't want to continue.

Alternatively @mlocati added a precondition array to package controllers a few versions ago. I don't know if that can do negative conditions.

Both the above require an install to be attempted before they can object to it.
linuxoid replied on at Permalink Reply
linuxoid
As was suggested here:
https://documentation.concrete5.org/developers/packages/installation...

I've tried
protected $packageDependencies = [
    'my_package' => false,
];
public function getPackageDependencies()
{
    return [
        'my_package' => false,
    ];
}

but none of these work, the package successfully installs without a warning.

Looking at the Package and DependencyChecker, they should use the getPackageDependencies() but they don't catch the one which should prevent installation.
linuxoid replied on at Permalink Reply
linuxoid
If package A is installed, package B cannot be installed. So. I have installed package A and then try to install package B. My package B controller has the following:
protected $packageDependencies = [
    'package_A' => false,
];
public function testForInstall($testForAlreadyInstalled = false)
{
    $dependencyChecker = $this->app->build(DependencyChecker::class);
    $errors = $this->app->make('error');
    $errors->add($dependencyChecker->testForInstall($this));
    return $errors->has() ? $errors : true;
}

but it gives me an error:
"The package "A" can't be installed if the package "B" is installed." It must be the other way round! It must be: "The package "B" can't be installed if the package "A" is installed."

Why doesn't the DependencyChecker work by itself without me reimplementing the method?