src/commands/ExtensionController.php
private function process($packageName, $state = 1, $runMigrations = 1)
    {
        $actionText = 0 === (int) $state
            ? 'deactivated'
            : 'activated';
        if (true === isset($this->extensions[$packageName]['is_active'])) {
            if ($runMigrations === 1) {
                $chain = new ReportingChain();

                ExtensionDataHelper::prepareMigrationTask(
                    $this->extensions[$packageName],
                    $chain,
                    (int) $state ? ExtensionsManager::MIGRATE_TYPE_UP : ExtensionsManager::MIGRATE_TYPE_DOWN,
                    ExtensionsManager::EXTENSION_DEACTIVATE_DEFERRED_GROUP
                );
                if (null !== $firstTaskId = $chain->registerChain()) {
                    DeferredHelper::runImmediateTask($firstTaskId);
                } else {
                    $this->stderr("Unable to run task chain\n");
                }
            }
            $this->extensions[$packageName]['is_active'] = $state;
            if (true === $this->writeConfig()) {
                $this->stdout(
                    str_replace('{actionText}', $actionText, 'Extension successfully {actionText}.') . PHP_EOL
                );
                //this means successfully termination. Because process starts in command line shell
                return 0;
            }
        } else {
            $this->stdout(
                str_replace('{actionText}', $actionText, 'You trying to {actionText} not existing extension!') . PHP_EOL
            );
        }
        return 1;
    }
private function process($packageName, $state = 1, $runMigrations = 1)
    {
        $actionText = 0 === (int) $state
            ? 'deactivated'
            : 'activated';
        if (true === isset($this->extensions[$packageName]['is_active'])) {
            if ($runMigrations === 1) {
                $chain = new ReportingChain();

                ExtensionDataHelper::prepareMigrationTask(
                    $this->extensions[$packageName],
                    $chain,
                    (int) $state ? ExtensionsManager::MIGRATE_TYPE_UP : ExtensionsManager::MIGRATE_TYPE_DOWN,
                    ExtensionsManager::EXTENSION_DEACTIVATE_DEFERRED_GROUP
                );
                if (null !== $firstTaskId = $chain->registerChain()) {
                    DeferredHelper::runImmediateTask($firstTaskId);
                } else {
                    $this->stderr("Unable to run task chain\n");
                }
            }
            $this->extensions[$packageName]['is_active'] = $state;
            if (true === $this->writeConfig()) {
                $this->stdout(
                    str_replace('{actionText}', $actionText, 'Extension successfully {actionText}.') . PHP_EOL
                );
                //this means successfully termination. Because process starts in command line shell
                return 0;
            }
        } else {
            $this->stdout(
                str_replace('{actionText}', $actionText, 'You trying to {actionText} not existing extension!') . PHP_EOL
            );
        }
        return 1;
    }
Activates/Deactivates Extension

@param $packageName
@param integer $state
@param integer $runMigrations
@return bool