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

Add Tasks "on-the-fly" #60

Closed
wandersonwhcr opened this issue Sep 23, 2014 · 2 comments
Closed

Add Tasks "on-the-fly" #60

wandersonwhcr opened this issue Sep 23, 2014 · 2 comments

Comments

@wandersonwhcr
Copy link

Wow! I found Robo and it's awesome!

I'm searching for a tasker where I can add tasks "on-the-fly", like this:

// manager.php
$manager = new Manager();
foreach (glob('modules/*/scripts/*.installer.php') as $filename) {
    call_user_func(function ($manager, $filename) {
        include $filename;
    }, $manager, $filename);
}
$manager->run();
// modules/admin/scripts/structure.installer.php
use Admin\Installer\Structure as StructureInstaller;

$manager->add(new StructureInstaller());

It's something like add tasks in Robo at the beggining, like:

class RoboFile extends \Robo\Tasks
{
    public function install()
    {
        foreach (glob('modules/*/scripts/*.installer.php') as $filename) {
            call_user_func(function ($robo, $filename) {
                include $filename;
            }, $this, $filename);
        }
        $this->taskInstall();
    }
}

Can I do this?

@DavertMik
Copy link
Member

Tasks are included as protected methods into RoboFile. PHP does not allow to add methods dynamically.

All you can to include your own traits into Robofile

class Robofile
{
     use Installer;

}

@wandersonwhcr
Copy link
Author

Yeah, I know I "can't" add methods dynamically. :)

So, I'll explain my situation.

I'm building a software where modules can be added through composer. If a module is installed, sometime a module needs to install something or execute a task, like create directories or alter database tables.

Because of this, I need a manager where I can add installers dynamically :)

But, as I said before, Robo is awesome! :D

Thank you for the response!

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

No branches or pull requests

2 participants