Ejemplo n.º 1
0
 public function handle(InstallThemeCommand $command)
 {
     $theme = new Theme();
     $repository = $this->repositoryFactory->build($command->type, $command->repository);
     if ($command->private and $this->pusher->hasValidLicenseKey()) {
         $repository->makePrivate();
     }
     $repository->setBranch($command->branch);
     $theme->setRepository($repository);
     $theme->setSubdirectory($command->subdirectory);
     $command->dryRun ?: $this->upgrader->installTheme($theme);
     if ($command->subdirectory) {
         $slug = end(explode('/', $command->subdirectory));
     } else {
         $slug = $repository->getSlug();
     }
     $theme = $this->themes->fromSlug($slug);
     $theme->setRepository($repository);
     $theme->setPushToDeploy($command->ptd);
     $theme->setSubdirectory($command->subdirectory);
     $this->themes->store($theme);
     do_action('wppusher_theme_was_installed', new ThemeWasInstalled($theme));
 }
Ejemplo n.º 2
0
 public function store(Theme $theme)
 {
     global $wpdb;
     $model = new PackageModel(array('package' => $theme->stylesheet, 'repository' => $theme->repository, 'branch' => $theme->repository->getBranch(), 'status' => 1, 'host' => $theme->repository->code, 'private' => $theme->repository->isPrivate(), 'ptd' => $theme->pushToDeploy, 'subdirectory' => $theme->getSubdirectory()));
     $table_name = pusherTableName();
     $count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_name} WHERE package = '{$model->package}'");
     if ($count !== '0') {
         return $wpdb->update($table_name, array('status' => $model->status, 'branch' => $model->branch, 'subdirectory' => $model->subdirectory), array('package' => $model->package));
     }
     return $wpdb->insert($table_name, array('package' => $model->package, 'repository' => $model->repository, 'branch' => $model->branch, 'type' => 2, 'status' => $model->status, 'host' => $model->host, 'private' => $model->private, 'ptd' => $model->ptd, 'subdirectory' => $model->subdirectory));
 }