public function handle(UpdatePackageFromWebhookCommand $command)
 {
     $package = false;
     // Plugin?
     try {
         $package = $this->plugins->pusherPluginFromRepository($command->repository);
         $updateCommand = new UpdatePlugin(array('file' => $package->file, 'repository' => $package->repository));
     } catch (PluginNotFound $e) {
         // No plugins...
     }
     // Or theme?
     try {
         $package = $this->themes->pusherThemeFromRepository($command->repository);
         $updateCommand = new UpdateTheme(array('stylesheet' => $package->stylesheet, 'repository' => $package->repository));
     } catch (ThemeNotFound $e) {
         // ... and no themes.
     }
     if (!$package) {
         throw new PushToDeployFailed("Push-to-Deploy failed. Couldn't find matching package.");
     }
     // Check if push to deploy is enabled before executing
     if (!$package->pushToDeploy) {
         throw new PushToDeployFailed("Push-to-Deploy failed. Push-to-Deploy was not enabled for package '{$package->name}'");
     }
     $this->dashboard->execute($updateCommand);
 }
 public function handle(ThemeWasInstalled $action)
 {
     if (is_multisite()) {
         $activationLink = network_admin_url() . "themes.php?action=enable&theme=" . urlencode($action->theme->stylesheet) . "&_wpnonce=" . wp_create_nonce('enable-theme_' . $action->theme->stylesheet);
     } else {
         $activationLink = get_admin_url() . "themes.php?action=activate&stylesheet=" . urlencode($action->theme->stylesheet) . "&_wpnonce=" . wp_create_nonce('switch-theme_' . $action->theme->stylesheet);
     }
     $this->dashboard->addMessage("Theme was successfully installed. Go ahead and <a href=\"{$activationLink}\">activate</a> it.");
 }
 public function handle()
 {
     $this->dashboard->addMessage('Plugin was successfully updated.');
 }
 public function handle(PluginWasEdited $action)
 {
     $this->dashboard->addMessage('Plugin changes was successfully saved.');
 }
 /**
  * @param ThemeWasUpdated $action
  */
 public function handle(ThemeWasUpdated $action)
 {
     $this->dashboard->addMessage('Theme was successfully updated.');
 }
 public function handle(ThemeWasUnlinked $action)
 {
     $this->dashboard->addMessage("Theme was unlinked from WP Pusher. You can re-connect it with 'Dry run'.");
 }
 /**
  * @param PluginWasInstalled $action
  */
 public function handle(PluginWasInstalled $action)
 {
     $baseAdminUrl = is_multisite() ? network_admin_url() : get_admin_url();
     $activationLink = $baseAdminUrl . "plugins.php?action=activate&plugin=" . urlencode($action->plugin->file) . "&_wpnonce=" . wp_create_nonce('activate-plugin_' . $action->plugin->file);
     $this->dashboard->addMessage("Plugin was successfully installed. Go ahead and <a href=\"{$activationLink}\">activate</a> it.");
 }
 public function handle(ThemeWasEdited $action)
 {
     $this->dashboard->addMessage('Theme changes was successfully saved.');
 }