public function update(CompletePackage $package, $installPath = null) { $plugin = $this->findOneByName($package->getName()); if ($plugin == null) { error_log('Tried to update a plugin that wasn\'t in the database: ' . $package->getName()); } $plugin->setVersion($package->getVersion()); $plugin->setDescription($package->getDescription()); $plugin->setHomepage($package->getHomepage()); $plugin->setAuthors($package->getAuthors()); // getSupport() is always going to return empty an array. Maybe this will change in the future $plugin->setSupport($package->getSupport()); $plugin->setDateUpdated(new \DateTime()); // Get full package json file. The package json from composer update/install does not include support properties // https://github.com/CourseBit/Inkstand/issues/4 if ($installPath != null) { $packageJson = json_decode(file_get_contents(sprintf('%s/composer.json', $installPath))); if (!empty($packageJson) && isset($packageJson->support)) { $plugin->setSupport($packageJson->support); } } $plugin->setBundleClass($package->getExtra()['bundle_class']); $plugin->setBundleTitle($package->getExtra()['bundle_title']); $this->entityManager->persist($plugin); $this->entityManager->flush(); }
/** * {@inheritdoc} */ public function getAuthors() { $this->initialize(); return parent::getAuthors(); }
private function updateAuthors(AddonVersion $version, CompletePackage $package) { if ($package->getAuthors()) { foreach ($package->getAuthors() as $details) { $author = null; if (!$details->getName() && !$details->getEmail()) { continue; } if ($details->getEmail()) { $author = AddonAuthor::get()->filter('Email', $details->getEmail())->first(); } if (!$author && $details->getHomepage()) { $author = AddonAuthor::get()->filter('Name', $details->getName())->filter('Homepage', $details->getHomepage())->first(); } if (!$author && $details->getName()) { $author = AddonAuthor::get()->filter('Name', $details->getName())->filter('Versions.Addon.Name', $package->getName())->first(); } if (!$author) { $author = new AddonAuthor(); } if ($details->getName()) { $author->Name = $details->getName(); } if ($details->getEmail()) { $author->Email = $details->getEmail(); } if ($details->getHomepage()) { $author->Homepage = $details->getHomepage(); } //to-do not supported by API //if(isset($details['role'])) $author->Role = $details['role']; $version->Authors()->add($author->write()); } } }