当前位置: 首页>>代码示例>>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;未经允许,请勿转载。