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 getThemes()
 {
     if (isset($_GET['repo'])) {
         try {
             $theme = $this->themes->pusherThemeFromRepository($_GET['repo']);
             return $this->render('themes/edit', compact('theme'));
         } catch (ThemeNotFound $e) {
             // Theme not found, show index instead
         }
     }
     $data['themes'] = $this->themes->allPusherThemes();
     return $this->render('themes/index', $data);
 }
 public function handle(UpdateThemeCommand $command)
 {
     $theme = $this->themes->pusherThemeFromRepository($command->repository);
     $this->upgrader->upgradeTheme($theme);
     do_action('wppusher_theme_was_updated', new ThemeWasUpdated($theme));
 }