Skip to content

Commit

Permalink
Fix PHP Fatal error: Call to a member function getContainer() on null #…
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Jul 18, 2016
1 parent e3bb90b commit ac60c43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Core/Console/ConsoleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Windwalker\Core\Application\WebApplication;
use Windwalker\Core\Event\EventDispatcher;
use Windwalker\Core\Ioc;
use Windwalker\Core\Package\PackageResolver;
use Windwalker\Http\Output\NoHeaderOutput;
Expand Down Expand Up @@ -54,7 +55,10 @@ public static function getAllPackagesResolver($env = 'dev', CoreConsole $console
{
$console = $console ? : Ioc::getApplication();

$resolver = new PackageResolver($console->container);
$container = clone $console->container;
$container->share(EventDispatcher::class, $container->newInstance(EventDispatcher::class));

$resolver = new PackageResolver($container);

foreach (static::loadPackages($env, $console) as $name => $package)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Console/CoreConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ public function execute()

$this->prepareExecute();

$this->triggerEvent('onBeforeExecute');
$this->triggerEvent('onBeforeExecute', ['app' => $this]);

// Perform application routines.
$exitCode = $this->doExecute();

$this->triggerEvent('onAfterExecute');
$this->triggerEvent('onAfterExecute', ['app' => $this]);

return $this->postExecute($exitCode);
}
Expand Down Expand Up @@ -226,9 +226,9 @@ public function triggerEvent($event, $args = array())
/** @var \Windwalker\Event\Dispatcher $dispatcher */
$dispatcher = $this->container->get('dispatcher');

$dispatcher->triggerEvent($event);
$dispatcher->triggerEvent($event, $args);

return $this;
return $event;
}

/**
Expand Down

0 comments on commit ac60c43

Please sign in to comment.