当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTimeHelper::currentUTCDateTime方法代码示例

本文整理汇总了PHP中DateTimeHelper::currentUTCDateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeHelper::currentUTCDateTime方法的具体用法?PHP DateTimeHelper::currentUTCDateTime怎么用?PHP DateTimeHelper::currentUTCDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeHelper的用法示例。


在下文中一共展示了DateTimeHelper::currentUTCDateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionFetchPackageInfo

 /**
  * Fetches the installed package info from Elliott.
  */
 public function actionFetchPackageInfo()
 {
     $this->requireAjaxRequest();
     $etResponse = craft()->et->fetchPackageInfo();
     if ($etResponse) {
         // Make sure we've got a valid license key (mismatched domain is OK for these purposes)
         if ($etResponse->licenseKeyStatus != LicenseKeyStatus::Invalid) {
             $packages = $etResponse->data;
             // Include which packages are actually licensed
             foreach ($etResponse->licensedPackages as $packageName) {
                 $packages[$packageName]['licensed'] = true;
             }
             // Include which packages are in trial
             foreach ($etResponse->packageTrials as $packageName => $expiryDate) {
                 $currentTime = DateTimeHelper::currentUTCDateTime();
                 $diff = $expiryDate - $currentTime->getTimestamp();
                 $daysLeft = round($diff / 86400);
                 // 60 * 60 * 24
                 $packages[$packageName]['trial'] = true;
                 $packages[$packageName]['daysLeftInTrial'] = $daysLeft;
             }
             $this->returnJson(array('success' => true, 'packages' => $packages));
         } else {
             $this->returnErrorJson(Craft::t('Your license key is invalid.'));
         }
     } else {
         $this->returnErrorJson(Craft::t('Craft is unable to fetch package info at this time.'));
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:32,代码来源:AppController.php

示例2: currentTimeForDb

 /**
  * @static
  * @return string
  */
 public static function currentTimeForDb()
 {
     // Eventually this will return the time in the appropriate database format for MySQL, Postgre, etc.
     // For now, it's MySQL only.
     $date = DateTimeHelper::currentUTCDateTime();
     return $date->format(DateTime::MYSQL_DATETIME, DateTime::UTC);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:11,代码来源:DateTimeHelper.php

示例3: getNextAnnouncement

 /**
  * Returns the next active announcement.
  *
  * @param string $timeInAdvance
  *
  * @return AnnouncementModel
  */
 public function getNextAnnouncement($timeInAdvance = '0')
 {
     $time = DateTimeHelper::currentUTCDateTime();
     $time->modify('+' . $timeInAdvance);
     $announcementRecord = craft()->db->createCommand()->select('*')->from('maintenance_announcements')->where(array('and', array('or', 'blockSite = 1', 'blockCp = 1'), 'startDate <= :time', array('or', 'endDate >= :now', 'endDate IS NULL')), array(':now' => DateTimeHelper::formatTimeForDb(), ':time' => DateTimeHelper::formatTimeForDb($time)))->order('startDate desc')->queryRow();
     if ($announcementRecord) {
         return Maintenance_AnnouncementModel::populateModel($announcementRecord);
     }
 }
开发者ID:carlcs,项目名称:craft-maintenance,代码行数:16,代码来源:MaintenanceService.php

示例4: actionShunCpAlert

 /**
  * Shuns a CP alert for 24 hours.
  *
  * @return null
  */
 public function actionShunCpAlert()
 {
     $this->requireAjaxRequest();
     craft()->userSession->requirePermission('accessCp');
     $message = craft()->request->getRequiredPost('message');
     $user = craft()->userSession->getUser();
     $currentTime = DateTimeHelper::currentUTCDateTime();
     $tomorrow = $currentTime->add(new DateInterval('P1D'));
     if (craft()->users->shunMessageForUser($user->id, $message, $tomorrow)) {
         $this->returnJson(array('success' => true));
     } else {
         $this->returnErrorJson(Craft::t('An unknown error occurred.'));
     }
 }
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:19,代码来源:AppController.php

示例5: createToken

 /**
  * Creates a new token and returns it.
  *
  * @param mixed $route              Where matching requests should be routed to. If you want them to be routed to a
  *                                  controller action, pass:
  *                                  `array('action' => "controller/action", 'params' => array('foo' => 'bar'))`.
  * @param int|null      $usageLimit The maximum number of times this token can be used. Defaults to no limit.
  * @param DateTime|null $expiryDate The date that the token expires. Defaults to the 'defaultTokenDuration' config
  *                                  setting.
  *
  * @return string|false             The generated token, or `false` if there was an error.
  */
 public function createToken($route, $usageLimit = null, $expiryDate = null)
 {
     if (!$expiryDate) {
         $expiryDate = DateTimeHelper::currentUTCDateTime();
         $expiryDate->add(new DateInterval(craft()->config->get('defaultTokenDuration')));
     }
     $tokenRecord = new TokenRecord();
     $tokenRecord->token = craft()->security->generateRandomString(32);
     $tokenRecord->route = $route;
     if ($usageLimit) {
         $tokenRecord->usageCount = 0;
         $usageLimit->usageLimit = $usageLimit;
     }
     $tokenRecord->expiryDate = $expiryDate;
     $success = $tokenRecord->save();
     if ($success) {
         return $tokenRecord->token;
     } else {
         return false;
     }
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:33,代码来源:TokensService.php

示例6: getGlobals

 /**
  * Returns a list of global variables to add to the existing list.
  *
  * @return array An array of global variables
  */
 public function getGlobals()
 {
     // Keep the 'blx' variable around for now
     $craftVariable = new CraftVariable();
     $globals['craft'] = $craftVariable;
     $globals['blx'] = $craftVariable;
     $globals['now'] = DateTimeHelper::currentUTCDateTime();
     $globals['loginUrl'] = UrlHelper::getUrl(craft()->config->getLoginPath());
     $globals['logoutUrl'] = UrlHelper::getUrl(craft()->config->getLogoutPath());
     if (craft()->isInstalled() && !craft()->updates->isCraftDbMigrationNeeded()) {
         $globals['siteName'] = craft()->getSiteName();
         $globals['siteUrl'] = craft()->getSiteUrl();
         $globals['currentUser'] = craft()->userSession->getUser();
         // Keep 'user' around so long as it's not hurting anyone.
         // Technically deprecated, though.
         $globals['user'] = $globals['currentUser'];
         if (craft()->request->isSiteRequest()) {
             foreach (craft()->globals->getAllSets() as $globalSet) {
                 $globals[$globalSet->handle] = $globalSet;
             }
         }
     } else {
         $globals['siteName'] = null;
         $globals['siteUrl'] = null;
         $globals['user'] = null;
     }
     if (craft()->request->isCpRequest()) {
         $globals['CraftEdition'] = craft()->getEdition();
         $globals['CraftPersonal'] = Craft::Personal;
         $globals['CraftClient'] = Craft::Client;
         $globals['CraftPro'] = Craft::Pro;
     }
     return $globals;
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:39,代码来源:CraftTwigExtension.php

示例7: _getSessionDuration

 /**
  * @param $rememberMe
  * @return int
  */
 private function _getSessionDuration($rememberMe)
 {
     if ($rememberMe) {
         $duration = craft()->config->get('rememberedUserSessionDuration');
     } else {
         $duration = craft()->config->get('userSessionDuration');
     }
     // Calculate how long the session should last.
     if ($duration) {
         $interval = new DateInterval($duration);
         $expire = DateTimeHelper::currentUTCDateTime();
         $currentTimeStamp = $expire->getTimestamp();
         $futureTimeStamp = $expire->add($interval)->getTimestamp();
         $seconds = $futureTimeStamp - $currentTimeStamp;
     } else {
         $seconds = 0;
     }
     return $seconds;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:23,代码来源:UserSessionService.php

示例8: defineAttributes

 /**
  * @return array
  */
 protected function defineAttributes()
 {
     return array('title' => array(AttributeType::Name, 'required' => true), 'body' => array(AttributeType::String, 'required' => true), 'command' => AttributeType::String, 'schedule' => array(AttributeType::DateTime, 'default' => DateTimeHelper::currentUTCDateTime()));
 }
开发者ID:webremote,项目名称:pushnotifications,代码行数:7,代码来源:PushNotifications_NotificationRecord.php

示例9: insertFileByPath

 /**
  * Insert a file into a folder by it's local path.
  *
  * @param string           $localFilePath    The local file path of the file to insert.
  * @param AssetFolderModel $folder           The assetFolderModel where the file should be uploaded to.
  * @param string           $filename         The name of the file to insert.
  * @param bool             $preventConflicts If set to true, will ensure that a conflict is not encountered by
  *                                           checking the file name prior insertion.
  *
  * @return AssetOperationResponseModel
  */
 public function insertFileByPath($localFilePath, AssetFolderModel $folder, $filename, $preventConflicts = false)
 {
     // Fire an 'onBeforeUploadAsset' event
     $event = new Event($this, array('path' => $localFilePath, 'folder' => $folder, 'filename' => $filename));
     craft()->assets->onBeforeUploadAsset($event);
     if ($event->performAction) {
         // We hate Javascript and PHP in our image files.
         if (IOHelper::getFileKind(IOHelper::getExtension($localFilePath)) == 'image' && ImageHelper::isImageManipulatable(IOHelper::getExtension($localFilePath)) && IOHelper::getExtension($localFilePath) != 'svg') {
             craft()->images->cleanImage($localFilePath);
         }
         $mobileUpload = false;
         if (IOHelper::getFileName($filename, false) == "image" && craft()->request->isMobileBrowser(true)) {
             $mobileUpload = true;
             $date = DateTimeHelper::currentUTCDateTime();
             $filename = "image_" . $date->format('Ymd_His') . "." . IOHelper::getExtension($filename);
         }
         if ($preventConflicts) {
             $newFileName = $this->getNameReplacementInFolder($folder, $filename);
             $response = $this->insertFileInFolder($folder, $localFilePath, $newFileName);
         } else {
             $response = $this->insertFileInFolder($folder, $localFilePath, $filename);
             // Naming conflict. create a new file and ask the user what to do with it
             if ($response->isConflict()) {
                 $newFileName = $this->getNameReplacementInFolder($folder, $filename);
                 $conflictResponse = $response;
                 $response = $this->insertFileInFolder($folder, $localFilePath, $newFileName);
             }
         }
         if ($response->isSuccess()) {
             $fileModel = new AssetFileModel();
             $title = $fileModel->generateAttributeLabel(IOHelper::getFileName($filename, false));
             // If there were double spaces, it's because the filename had a space followed by a
             // capital letter. We convert the space to a dash, but Yii thinks it's a new "word"
             // and adds another space.
             $fileModel->getContent()->title = str_replace('  ', ' ', $title);
             $filename = IOHelper::getFileName($response->getDataItem('filePath'));
             $fileModel->filename = IOHelper::getFileName($filename);
             $fileModel->sourceId = $this->model->id;
             $fileModel->folderId = $folder->id;
             $fileModel->kind = IOHelper::getFileKind(IOHelper::getExtension($filename));
             $fileModel->size = filesize($localFilePath);
             $fileModel->dateModified = IOHelper::getLastTimeModified($localFilePath);
             if ($fileModel->kind == 'image') {
                 list($width, $height) = ImageHelper::getImageSize($localFilePath);
                 $fileModel->width = $width;
                 $fileModel->height = $height;
             }
             if ($mobileUpload) {
                 $fileModel->getContent()->title = Craft::t('Mobile Upload');
             }
             craft()->assets->storeFile($fileModel);
             if (!$this->isSourceLocal() && $fileModel->kind == 'image') {
                 craft()->assetTransforms->storeLocalSource($localFilePath, craft()->path->getAssetsImageSourcePath() . $fileModel->id . '.' . IOHelper::getExtension($fileModel->filename));
             }
             // Check if we stored a conflict response originally - send that back then.
             if (isset($conflictResponse)) {
                 $response = $conflictResponse;
             }
             $response->setDataItem('fileId', $fileModel->id);
         }
     } else {
         $response = new AssetOperationResponseModel();
         $response->setError(Craft::t('The file upload was cancelled.'));
     }
     return $response;
 }
开发者ID:JamesGibsonUK,项目名称:gibsonlearn,代码行数:77,代码来源:BaseAssetSourceType.php

示例10: defineAttributes

 /**
  * @return array
  */
 protected function defineAttributes()
 {
     return array_merge(parent::defineAttributes(), array('appId' => AttributeType::Number, 'title' => AttributeType::Name, 'body' => AttributeType::String, 'command' => AttributeType::String, 'schedule' => array(AttributeType::DateTime, 'default' => DateTimeHelper::currentUTCDateTime())));
 }
开发者ID:webremote,项目名称:pushnotifications,代码行数:7,代码来源:PushNotifications_NotificationModel.php

示例11: getGlobals

 /**
  * Returns a list of global variables to add to the existing list.
  *
  * @return array An array of global variables
  */
 public function getGlobals()
 {
     // Keep the 'blx' variable around for now
     $craftVariable = new CraftVariable();
     $globals['craft'] = $craftVariable;
     $globals['blx'] = $craftVariable;
     $globals['now'] = DateTimeHelper::currentUTCDateTime();
     $globals['loginUrl'] = UrlHelper::getUrl(craft()->config->getLoginPath());
     $globals['logoutUrl'] = UrlHelper::getUrl(craft()->config->getLogoutPath());
     if (Craft::isInstalled()) {
         $globals['siteName'] = Craft::getSiteName();
         $globals['siteUrl'] = Craft::getSiteUrl();
         $globals['user'] = craft()->userSession->getUser();
         if (craft()->request->isSiteRequest()) {
             foreach (craft()->globals->getAllSets() as $globalSet) {
                 $globalSet->locale = craft()->language;
                 $globals[$globalSet->handle] = $globalSet;
             }
         }
     } else {
         $globals['siteName'] = null;
         $globals['siteUrl'] = null;
         $globals['user'] = null;
     }
     return $globals;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:31,代码来源:CraftTwigExtension.php

示例12: getRemainingCooldownTime

 /**
  * Returns the remaining cooldown time for this user, if they've entered their password incorrectly too many times.
  *
  * @return DateInterval|null
  */
 public function getRemainingCooldownTime()
 {
     if ($this->status == UserStatus::Locked) {
         $currentTime = DateTimeHelper::currentUTCDateTime();
         $cooldownEnd = $this->getCooldownEndTime();
         if ($currentTime < $cooldownEnd) {
             return $currentTime->diff($cooldownEnd);
         }
     }
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:15,代码来源:UserModel.php

示例13: saveEntry

 /**
  * Saves an entry.
  *
  * @param EntryModel $entry
  * @throws Exception
  * @return bool
  */
 public function saveEntry(EntryModel $entry)
 {
     $isNewEntry = !$entry->id;
     // Entry data
     if (!$isNewEntry) {
         $entryRecord = EntryRecord::model()->with('element')->findById($entry->id);
         if (!$entryRecord) {
             throw new Exception(Craft::t('No entry exists with the ID “{id}”', array('id' => $entry->id)));
         }
         $elementRecord = $entryRecord->element;
         // if entry->sectionId is null and there is an entryRecord sectionId, we assume this is a front-end edit.
         if ($entry->sectionId === null && $entryRecord->sectionId) {
             $entry->sectionId = $entryRecord->sectionId;
         }
     } else {
         $entryRecord = new EntryRecord();
         $elementRecord = new ElementRecord();
         $elementRecord->type = ElementType::Entry;
     }
     $section = craft()->sections->getSectionById($entry->sectionId);
     if (!$section) {
         throw new Exception(Craft::t('No section exists with the ID “{id}”', array('id' => $entry->sectionId)));
     }
     $sectionLocales = $section->getLocales();
     if (!isset($sectionLocales[$entry->locale])) {
         throw new Exception(Craft::t('The section “{section}” is not enabled for the locale {locale}', array('section' => $section->name, 'locale' => $entry->locale)));
     }
     $entryRecord->sectionId = $entry->sectionId;
     $entryRecord->authorId = $entry->authorId;
     $entryRecord->postDate = $entry->postDate;
     $entryRecord->expiryDate = $entry->expiryDate;
     if ($entry->enabled && !$entryRecord->postDate) {
         // Default the post date to the current date/time
         $entryRecord->postDate = $entry->postDate = DateTimeHelper::currentUTCDateTime();
     }
     $entryRecord->validate();
     $entry->addErrors($entryRecord->getErrors());
     $elementRecord->enabled = $entry->enabled;
     $elementRecord->validate();
     $entry->addErrors($elementRecord->getErrors());
     // Entry locale data
     if ($entry->id) {
         $entryLocaleRecord = EntryLocaleRecord::model()->findByAttributes(array('entryId' => $entry->id, 'locale' => $entry->locale));
         // If entry->slug is null and there is an entryLocaleRecord slug, we assume this is a front-end edit.
         if ($entry->slug === null && $entryLocaleRecord->slug) {
             $entry->slug = $entryLocaleRecord->slug;
         }
     }
     if (empty($entryLocaleRecord)) {
         $entryLocaleRecord = new EntryLocaleRecord();
         $entryLocaleRecord->sectionId = $entry->sectionId;
         $entryLocaleRecord->locale = $entry->locale;
     }
     if ($entryLocaleRecord->isNewRecord() || $entry->slug != $entryLocaleRecord->slug) {
         $this->_generateEntrySlug($entry);
         $entryLocaleRecord->slug = $entry->slug;
     }
     $entryLocaleRecord->validate();
     $entry->addErrors($entryLocaleRecord->getErrors());
     // Element locale data
     if ($entry->id) {
         $elementLocaleRecord = ElementLocaleRecord::model()->findByAttributes(array('elementId' => $entry->id, 'locale' => $entry->locale));
     }
     if (empty($elementLocaleRecord)) {
         $elementLocaleRecord = new ElementLocaleRecord();
         $elementLocaleRecord->locale = $entry->locale;
     }
     if ($section->hasUrls && $entry->enabled) {
         // Make sure the section's URL format is valid. This shouldn't be possible due to section validation,
         // but it's not enforced by the DB, so anything is possible.
         $urlFormat = $sectionLocales[$entry->locale]->urlFormat;
         if (!$urlFormat || strpos($urlFormat, '{slug}') === false) {
             throw new Exception(Craft::t('The section “{section}” doesn’t have a valid URL Format.', array('section' => Craft::t($section->name))));
         }
         $elementLocaleRecord->uri = craft()->templates->renderObjectTemplate($urlFormat, $entry);
     } else {
         $elementLocaleRecord->uri = null;
     }
     $elementLocaleRecord->validate();
     $entry->addErrors($elementLocaleRecord->getErrors());
     // Entry content
     $fieldLayout = $section->getFieldLayout();
     $content = craft()->content->prepElementContentForSave($entry, $fieldLayout);
     $content->validate();
     $entry->addErrors($content->getErrors());
     if (!$entry->hasErrors()) {
         // Save the element record first
         $elementRecord->save(false);
         // Now that we have an element ID, save it on the other stuff
         if (!$entry->id) {
             $entry->id = $elementRecord->id;
             $entryRecord->id = $entry->id;
         }
//.........这里部分代码省略.........
开发者ID:kentonquatman,项目名称:portfolio,代码行数:101,代码来源:EntriesService.php

示例14: saveEntry

 /**
  * Saves a new or existing entry.
  *
  * ```php
  * $entry = new EntryModel();
  * $entry->sectionId = 10;
  * $entry->typeId    = 1;
  * $entry->authorId  = 5;
  * $entry->enabled   = true;
  *
  * $entry->getContent()->title = "Hello World!";
  *
  * $entry->setContentFromPost(array(
  *     'body' => "<p>I can’t believe I literally just called this “Hello World!”.</p>",
  * ));
  *
  * $success = craft()->entries->saveEntry($entry);
  *
  * if (!$success)
  * {
  *     Craft::log('Couldn’t save the entry "'.$entry->title.'"', LogLevel::Error);
  * }
  * ```
  *
  * @param EntryModel $entry The entry to be saved.
  *
  * @throws \Exception
  * @return bool Whether the entry was saved successfully.
  */
 public function saveEntry(EntryModel $entry)
 {
     $isNewEntry = !$entry->id;
     $hasNewParent = $this->_checkForNewParent($entry);
     if ($hasNewParent) {
         if ($entry->parentId) {
             $parentEntry = $this->getEntryById($entry->parentId, $entry->locale);
             if (!$parentEntry) {
                 throw new Exception(Craft::t('No entry exists with the ID “{id}”.', array('id' => $entry->parentId)));
             }
         } else {
             $parentEntry = null;
         }
         $entry->setParent($parentEntry);
     }
     // Get the entry record
     if (!$isNewEntry) {
         $entryRecord = EntryRecord::model()->findById($entry->id);
         if (!$entryRecord) {
             throw new Exception(Craft::t('No entry exists with the ID “{id}”.', array('id' => $entry->id)));
         }
     } else {
         $entryRecord = new EntryRecord();
     }
     // Get the section
     $section = craft()->sections->getSectionById($entry->sectionId);
     if (!$section) {
         throw new Exception(Craft::t('No section exists with the ID “{id}”.', array('id' => $entry->sectionId)));
     }
     // Verify that the section is available in this locale
     $sectionLocales = $section->getLocales();
     if (!isset($sectionLocales[$entry->locale])) {
         throw new Exception(Craft::t('The section “{section}” is not enabled for the locale {locale}', array('section' => $section->name, 'locale' => $entry->locale)));
     }
     // Set the entry data
     $entryType = $entry->getType();
     $entryRecord->sectionId = $entry->sectionId;
     if ($section->type == SectionType::Single) {
         $entryRecord->authorId = $entry->authorId = null;
         $entryRecord->expiryDate = $entry->expiryDate = null;
     } else {
         $entryRecord->authorId = $entry->authorId;
         $entryRecord->postDate = $entry->postDate;
         $entryRecord->expiryDate = $entry->expiryDate;
         $entryRecord->typeId = $entryType->id;
     }
     if ($entry->enabled && !$entryRecord->postDate) {
         // Default the post date to the current date/time
         $entryRecord->postDate = $entry->postDate = DateTimeHelper::currentUTCDateTime();
     }
     $entryRecord->validate();
     $entry->addErrors($entryRecord->getErrors());
     if ($entry->hasErrors()) {
         return false;
     }
     if (!$entryType->hasTitleField) {
         $entry->getContent()->title = craft()->templates->renderObjectTemplate($entryType->titleFormat, $entry);
     }
     $transaction = craft()->db->getCurrentTransaction() === null ? craft()->db->beginTransaction() : null;
     try {
         // Fire an 'onBeforeSaveEntry' event
         $event = new Event($this, array('entry' => $entry, 'isNewEntry' => $isNewEntry));
         $this->onBeforeSaveEntry($event);
         // Is the event giving us the go-ahead?
         if ($event->performAction) {
             // Save the element
             $success = craft()->elements->saveElement($entry);
             // If it didn't work, rollback the transaction in case something changed in onBeforeSaveEntry
             if (!$success) {
                 if ($transaction !== null) {
                     $transaction->rollback();
//.........这里部分代码省略.........
开发者ID:scisahaha,项目名称:generator-craft,代码行数:101,代码来源:EntriesService.php

示例15: _populateMigrationTable

 /**
  * Populates the migrations table with the base migration plus any existing ones from app/migrations.
  *
  * @throws Exception
  * @return null
  */
 private function _populateMigrationTable()
 {
     $migrations = array();
     // Add the base one.
     $migration = new MigrationRecord();
     $migration->version = craft()->migrations->getBaseMigration();
     $migration->applyTime = DateTimeHelper::currentUTCDateTime();
     $migrations[] = $migration;
     $migrationsFolder = craft()->path->getAppPath() . 'migrations/';
     $migrationFiles = IOHelper::getFolderContents($migrationsFolder, false, "(m(\\d{6}_\\d{6})_.*?)\\.php");
     if ($migrationFiles) {
         foreach ($migrationFiles as $file) {
             if (IOHelper::fileExists($file)) {
                 $migration = new MigrationRecord();
                 $migration->version = IOHelper::getFileName($file, false);
                 $migration->applyTime = DateTimeHelper::currentUTCDateTime();
                 $migrations[] = $migration;
             }
         }
         foreach ($migrations as $migration) {
             if (!$migration->save()) {
                 Craft::log('Could not populate the migration table.', LogLevel::Error);
                 throw new Exception(Craft::t('There was a problem saving to the migrations table: ') . $this->_getFlattenedErrors($migration->getErrors()));
             }
         }
     }
     Craft::log('Migration table populated successfully.');
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:34,代码来源:InstallService.php


注:本文中的DateTimeHelper::currentUTCDateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。