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

Re: Make console command extendable from packages #2720

Merged
merged 1 commit into from Jul 10, 2015

Conversation

hissy
Copy link
Contributor

@hissy hissy commented Jul 9, 2015

This PR makes console command extendable from a Package, without adding the method directly to the Package class. This is an alternative plan of #2651

An example of package controller:

<?php 
namespace Concrete\Package\CommandPackageExample;

use Concrete\Package\CommandPackageExample\Console\Command\ExampleCommand;
use Core;

class Controller extends \Concrete\Core\Package\Package
{
    protected $pkgHandle = 'command_package_example';
    protected $appVersionRequired = '5.7.4.3';
    protected $pkgVersion = '0.1';
    protected $pkgAutoloaderMapCoreExtensions = true;

    public function getPackageName()
    {
        return t('Command Package Example');
    }

    public function getPackageDescription()
    {
        return t('An example package to add console commands.');
    }

    public function on_start()
    {
        if (Core::make('app')->isRunThroughCommandLineInterface()) {
            try {
                $app = Core::make('console');
                $app->add(new ExampleCommand());
            } catch (Exception $e) {}
        }
    }
}

@KorvinSzanto
Copy link
Member

This looks like the right way to do it.

@aembler
Copy link
Member

aembler commented Jul 10, 2015

I like that.

@aembler aembler merged commit 74a0427 into concretecms:develop Jul 10, 2015
@hissy hissy deleted the enhancement/package-commands-2 branch July 10, 2015 23:51
@hissy
Copy link
Contributor Author

hissy commented Jul 10, 2015

Thanks! 😋

@Remo Remo mentioned this pull request Jul 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants