當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Releases::save方法代碼示例

本文整理匯總了PHP中Releases::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Releases::save方法的具體用法?PHP Releases::save怎麽用?PHP Releases::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Releases的用法示例。


在下文中一共展示了Releases::save方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkFiles

 public function checkFiles(Releases $release)
 {
     if (!$release->id) {
         throw new \LogicException('Unexpected empty release identifier in BleedingEdge::checkFiles()');
     }
     // Make sure we are given a release which exists
     if (empty($release->category_id)) {
         return;
     }
     // Set the category from the release if the model's category doesn't match
     if ($this->category_id != $release->category_id || empty($this->folder)) {
         $this->setCategory($release->category_id);
     }
     // Make sure the category was indeed set
     if (empty($this->category) || empty($this->category_id) || empty($this->folder)) {
         return;
     }
     // Can't proceed if it's not a bleedingedge category
     if ($this->category->type != 'bleedingedge') {
         return;
     }
     $potentialPrefix = substr($this->folder, 0, 5);
     $potentialPrefix = strtolower($potentialPrefix);
     $useS3 = $potentialPrefix == 's3://';
     // Safe fallback
     $folderName = $release->version;
     if ($useS3) {
         // On S3 it's always the version-as-folder, otherwise it'd take FOREVER to scan S3
         $folder = $this->folder . '/' . $release->version;
         $known_folders[] = $release->version;
     } else {
         $folderName = $this->getReleaseFolder($this->folder, $release->version, $release->alias, $release->maturity);
         if ($folderName === false) {
             // Normally this shouldn't happen!
             return;
         } else {
             $known_folders[] = $folderName;
             $folder = $this->folder . '/' . $folderName;
         }
     }
     // Do we have a changelog?
     if (empty($release->notes)) {
         $changelog = $folder . '/CHANGELOG';
         $hasChangelog = false;
         $this_changelog = '';
         if ($useS3) {
             $s3 = AmazonS3::getInstance();
             $response = $s3->getObject(substr($changelog, 5));
             $hasChangelog = $response !== false;
             if ($hasChangelog) {
                 $this_changelog = $response;
             }
         } else {
             if (\JFile::exists($changelog)) {
                 $hasChangelog = true;
                 $this_changelog = @file_get_contents($changelog);
             }
         }
         if ($hasChangelog) {
             $first_changelog = array();
             $notes = $this->coloriseChangelog($this_changelog, $first_changelog);
             $release->notes = $notes;
             $release->save();
         }
     }
     $release->getRelations()->rebase($release);
     $known_items = array();
     if ($useS3) {
         $files = array();
         $everything = $this->_listS3Contents($folder);
         $dirLength = strlen($folder) - 5;
         if (count($everything)) {
             foreach ($everything as $path => $info) {
                 if (array_key_exists('size', $info) && substr($path, -1) != '/') {
                     if (substr($path, 0, $dirLength) == substr($folder, 5)) {
                         $path = substr($path, $dirLength);
                     }
                     $path = trim($path, '/');
                     $files[] = $path;
                 }
             }
         }
     } else {
         $files = \JFolder::files($folder);
     }
     if ($release->items->count()) {
         /** @var Items $item */
         foreach ($release->items as $item) {
             $known_items[] = basename($item->filename);
             if ($item->published && !in_array(basename($item->filename), $files)) {
                 $item->unpublish();
             }
             if (!$item->published && in_array(basename($item->filename), $files)) {
                 $item->publish();
             }
         }
     }
     if (!empty($files)) {
         foreach ($files as $file) {
             if (basename($file) == 'CHANGELOG') {
//.........這裏部分代碼省略.........
開發者ID:,項目名稱:,代碼行數:101,代碼來源:


注:本文中的Releases::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。