コード例 #1
0
 private function updateDocumentFromPackage(Solarium_Document_ReadWrite $document, Package $package, array $tags, $redis, DownloadManager $downloadManager, FavoriteManager $favoriteManager)
 {
     $document->setField('id', $package->getId());
     $document->setField('name', $package->getName());
     $document->setField('package_name', $package->getPackageName());
     $document->setField('description', preg_replace('{[\\x00-\\x1f]+}u', '', $package->getDescription()));
     $document->setField('type', $package->getType());
     $document->setField('trendiness', $redis->zscore('downloads:trending', $package->getId()));
     $document->setField('downloads', $downloadManager->getTotalDownloads($package));
     $document->setField('favers', $favoriteManager->getFaverCount($package));
     $document->setField('repository', $package->getRepository());
     $document->setField('language', $package->getLanguage());
     if ($package->isAbandoned()) {
         $document->setField('abandoned', 1);
         $document->setField('replacementPackage', $package->getReplacementPackage() ?: '');
     } else {
         $document->setField('abandoned', 0);
         $document->setField('replacementPackage', '');
     }
     $tags = array_map(function ($tag) {
         return mb_strtolower(preg_replace('{[\\x00-\\x1f]+}u', '', $tag), 'UTF-8');
     }, $tags);
     $document->setField('tags', $tags);
 }
コード例 #2
0
 private function updateDocumentFromPackage(Solarium_Document_ReadWrite $document, Package $package, $redis, DownloadManager $downloadManager, FavoriteManager $favoriteManager)
 {
     $document->setField('id', $package->getId());
     $document->setField('name', $package->getName());
     $document->setField('description', $package->getDescription());
     $document->setField('type', $package->getType());
     $document->setField('trendiness', $redis->zscore('downloads:trending', $package->getId()));
     $document->setField('downloads', $downloadManager->getTotalDownloads($package));
     $document->setField('favers', $favoriteManager->getFaverCount($package));
     $document->setField('repository', $package->getRepository());
     $document->setField('language', $package->getLanguage());
     if ($package->isAbandoned()) {
         $document->setField('abandoned', 1);
         $document->setField('replacementPackage', $package->getReplacementPackage() ?: '');
     } else {
         $document->setField('abandoned', 0);
         $document->setField('replacementPackage', '');
     }
     $tags = array();
     foreach ($package->getVersions() as $version) {
         foreach ($version->getTags() as $tag) {
             $tags[mb_strtolower($tag->getName(), 'UTF-8')] = true;
         }
     }
     $document->setField('tags', array_keys($tags));
 }