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


PHP Craft::log方法代码示例

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


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

示例1: actionIndex

 /**
  * Exports the Craft datamodel.
  *
  * @param string $file    file to write the schema to
  * @param array  $exclude Data to not export
  *
  * @return int
  */
 public function actionIndex($file = 'craft/config/schema.yml', array $exclude = null)
 {
     $dataTypes = Schematic::getExportableDataTypes();
     // If there are data exclusions.
     if ($exclude !== null) {
         // Find any invalid data to exclude.
         $invalidExcludes = array_diff($exclude, $dataTypes);
         // If any invalid exclusions were specified.
         if (count($invalidExcludes) > 0) {
             $errorMessage = 'Invalid exlude';
             if (count($invalidExcludes) > 1) {
                 $errorMessage .= 's';
             }
             $errorMessage .= ': ' . implode(', ', $invalidExcludes) . '.';
             $errorMessage .= ' Valid exclusions are ' . implode(', ', $dataTypes);
             // Output an error message outlining what invalid exclusions were specified.
             echo "\n" . $errorMessage . "\n\n";
             return 1;
         }
         // Remove any explicitly excluded data types from the list of data types to export.
         $dataTypes = array_diff($dataTypes, $exclude);
     }
     Craft::app()->schematic->exportToYaml($file, $dataTypes);
     Craft::log(Craft::t('Exported schema to {file}', ['file' => $file]));
     return 0;
 }
开发者ID:itmundi,项目名称:schematic,代码行数:34,代码来源:ExportCommand.php

示例2: log

 /**
  * Logging any messages to Craft.
  * 
  * @param String $msg
  * @param String $level
  * @param Bool $force
  * @return Void
  */
 public static function log($msg, $level = LogLevel::Info, $force = false)
 {
     if (version_compare('2.0', craft()->getVersion(), '>')) {
         Craft::log($msg, $level, $force);
     } else {
         parent::log($msg, $level, $force);
     }
 }
开发者ID:speder,项目名称:craft.minimee,代码行数:16,代码来源:MinimeePlugin.php

示例3: export

 /**
  * @param array $data
  *
  * @return array
  */
 public function export(array $data = [])
 {
     Craft::log(Craft::t('Exporting Locales'));
     $locales = $this->getLocalizationService()->getSiteLocales();
     $localeDefinitions = [];
     foreach ($locales as $locale) {
         $localeDefinitions[] = $locale->getId();
     }
     return $localeDefinitions;
 }
开发者ID:ostark,项目名称:schematic,代码行数:15,代码来源:Locales.php

示例4: currencyToWords

 /**
  * Converts a currency value to word representation.
  *
  * @param float $value
  * @param string $locale
  * @param string $currency
  * @param string $decPoint
  *
  * @return string The word representation
  */
 function currencyToWords($value, $locale = 'en_US', $currency = '', $decPoint = null)
 {
     $numbersWords = $this->getNumbersWords();
     $return = $numbersWords->toCurrency($value, $locale, $currency, $decPoint);
     if (PEAR::isError($return)) {
         Craft::log('(Helpers) couldn’t convert “' . $value . '” to its word representation: ' . $return->message);
         return false;
     }
     return $return;
 }
开发者ID:carlcs,项目名称:craft-helpers,代码行数:20,代码来源:Helpers_NumberService.php

示例5: authenticate

 public function authenticate()
 {
     \Craft\Craft::log(__METHOD__, \Craft\LogLevel::Info, true);
     $socialUser = \Craft\craft()->social->getSocialUserById($this->socialUserId);
     if ($socialUser) {
         $this->_id = $socialUser->user->id;
         $this->username = $socialUser->user->username;
         $this->errorCode = static::ERROR_NONE;
         return true;
     } else {
         return false;
     }
 }
开发者ID:jamiepittock,项目名称:WhereForArt,代码行数:13,代码来源:TokenIdentity.php

示例6: actionIndex

 /**
  * Imports the Craft datamodel.
  *
  * @param string $file          yml file containing the schema definition
  * @param string $override_file yml file containing the override values
  * @param bool   $force         if set to true items not in the import will be deleted
  *
  * @return int
  */
 public function actionIndex($file = 'craft/config/schema.yml', $override_file = 'craft/config/override.yml', $force = false)
 {
     if (!IOHelper::fileExists($file)) {
         $this->usageError(Craft::t('File not found.'));
     }
     $result = Craft::app()->schematic->importFromYaml($file, $override_file, $force);
     if (!$result->hasErrors()) {
         Craft::log(Craft::t('Loaded schema from {file}', ['file' => $file]));
         return 0;
     }
     Craft::log(Craft::t('There was an error loading schema from {file}', ['file' => $file]));
     print_r($result->getErrors());
     return 1;
 }
开发者ID:ostark,项目名称:schematic,代码行数:23,代码来源:ImportCommand.php

示例7: cleanUp

 /**
  * Perform our clean up task. Remove any orphan assets from our crop source.
  */
 public function cleanUp()
 {
     $plugin = craft()->plugins->getPlugin('ImageCropper');
     $settings = $plugin->getSettings();
     $sourceId = $settings->source;
     $assets = craft()->assets->getFilesBySourceId($sourceId);
     $validAssetIds = craft()->db->createCommand()->selectDistinct('targetId')->from('relations')->query();
     $targetIds = array();
     foreach ($validAssetIds as $idArr) {
         $targetIds[] = $idArr['targetId'];
     }
     $task = craft()->tasks->createTask('ImageCropper', 'Cleaning up images', array('assets' => $assets, 'validAssetIds' => $targetIds));
     $taskSuccessful = craft()->tasks->runTask($task);
     if (!$taskSuccessful) {
         Craft::log('Unable to complete ImageCropperTask. Some failure occurred.');
     }
 }
开发者ID:rabble-rouser,项目名称:image-cropper-plugin,代码行数:20,代码来源:ImageCropperService.php

示例8: import

 /**
  * Attempt to import user settings.
  *
  * @param array $user_settings
  * @param bool  $force         If set to true user settings not included in the import will be deleted
  *
  * @return Result
  */
 public function import(array $user_settings, $force = true)
 {
     Craft::log(Craft::t('Importing Users'));
     // always delete existing fieldlayout first
     Craft::app()->fields->deleteLayoutsByType(ElementType::User);
     if (isset($user_settings['fieldLayout'])) {
         $fieldLayoutDefinition = (array) $user_settings['fieldLayout'];
     } else {
         $fieldLayoutDefinition = [];
     }
     $fieldLayout = Craft::app()->schematic_fields->getFieldLayout($fieldLayoutDefinition);
     $fieldLayout->type = ElementType::User;
     if (!Craft::app()->fields->saveLayout($fieldLayout)) {
         // Save fieldlayout via craft
         $this->addErrors($fieldLayout->getAllErrors());
     }
     return $this->getResultModel();
 }
开发者ID:ostark,项目名称:schematic,代码行数:26,代码来源:Users.php

示例9: export

 /**
  * @param array $data
  *
  * @return array
  */
 public function export(array $data = [])
 {
     Craft::log(Craft::t('Exporting Element Index Settings'));
     $settingDefinitions = [];
     // Get all element types
     $elementTypes = $this->getElementsService()->getAllElementTypes();
     // Loop through element types
     foreach ($elementTypes as $elementType) {
         // Get element type name
         $elementTypeName = preg_replace('/^Craft\\\\(.*?)ElementType$/', '$1', get_class($elementType));
         // Get existing settings for element type
         $settings = $this->getElementIndexesService()->getSettings($elementTypeName);
         // If there are settings, export
         if (is_array($settings)) {
             // Group by element type and add to definitions
             $settingDefinitions[$elementTypeName] = $settings;
         }
     }
     return $settingDefinitions;
 }
开发者ID:itmundi,项目名称:schematic,代码行数:25,代码来源:ElementIndexSettings.php

示例10: import

 /**
  * Attempt to import tagGroups.
  *
  * @param array $tagGroupDefinitions
  * @param bool  $force               If set to true tagGroups not included in the import will be deleted
  *
  * @return Result
  */
 public function import(array $tagGroupDefinitions, $force = false)
 {
     Craft::log(Craft::t('Importing TagGroups'));
     $tagGroups = Craft::app()->tags->getAllTagGroups('handle');
     foreach ($tagGroupDefinitions as $tagGroupHandle => $tagGroupDefinition) {
         $tagGroup = array_key_exists($tagGroupHandle, $tagGroups) ? $tagGroups[$tagGroupHandle] : new TagGroupModel();
         unset($tagGroups[$tagGroupHandle]);
         $this->populateTagGroup($tagGroup, $tagGroupDefinition, $tagGroupHandle);
         if (!Craft::app()->tags->saveTagGroup($tagGroup)) {
             // Save taggroup via craft
             $this->addErrors($tagGroup->getAllErrors());
             continue;
         }
     }
     if ($force) {
         foreach ($tagGroups as $tagGroup) {
             Craft::app()->tags->deleteTagGroupById($tagGroup->id);
         }
     }
     return $this->getResultModel();
 }
开发者ID:itmundi,项目名称:schematic,代码行数:29,代码来源:TagGroups.php

示例11: import

 /**
  * Attempt to import globals.
  *
  * @param array $globalSetDefinitions
  * @param bool  $force                If set to true globals not included in the import will be deleted
  *
  * @return Result
  */
 public function import(array $globalSetDefinitions, $force = false)
 {
     Craft::log(Craft::t('Importing Global Sets'));
     $globalSets = Craft::app()->globals->getAllSets('handle');
     foreach ($globalSetDefinitions as $globalSetHandle => $globalSetDefinition) {
         $global = array_key_exists($globalSetHandle, $globalSets) ? $globalSets[$globalSetHandle] : new GlobalSetModel();
         unset($globalSets[$globalSetHandle]);
         $this->populateGlobalSet($global, $globalSetDefinition, $globalSetHandle);
         if (!Craft::app()->globals->saveSet($global)) {
             // Save globalset via craft
             $this->addErrors($global->getAllErrors());
             continue;
         }
     }
     if ($force) {
         foreach ($globalSets as $globalSet) {
             Craft::app()->globals->deleteSetById($globalSet->id);
         }
     }
     return $this->getResultModel();
 }
开发者ID:itmundi,项目名称:schematic,代码行数:29,代码来源:GlobalSets.php

示例12: login

 public function login($socialUserId)
 {
     $rememberMe = true;
     Craft::log(__METHOD__, LogLevel::Info, true);
     $this->_identity = new TokenIdentity($socialUserId);
     $this->_identity->authenticate();
     // Was the login successful?
     if ($this->_identity->errorCode == TokenIdentity::ERROR_NONE) {
         // Get how long this session is supposed to last.
         $this->authTimeout = craft()->config->getUserSessionDuration($rememberMe);
         $id = $this->_identity->getId();
         $user = craft()->users->getUserById($id);
         $states = $this->_identity->getPersistentStates();
         // Run any before login logic.
         if ($this->beforeLogin($id, $states, false)) {
             $this->changeIdentity($id, $this->_identity->getName(), $states);
             if ($this->authTimeout) {
                 if ($this->allowAutoLogin) {
                     if ($user) {
                         // Save the necessary info to the identity cookie.
                         $sessionToken = StringHelper::UUID();
                         $hashedToken = craft()->security->hashData(base64_encode(serialize($sessionToken)));
                         $uid = craft()->users->handleSuccessfulLogin($user, $hashedToken);
                         $data = array($this->getName(), $sessionToken, $uid, $rememberMe ? 1 : 0, craft()->request->getUserAgent(), $this->saveIdentityStates());
                         $this->saveCookie('', $data, $this->authTimeout);
                     } else {
                         throw new Exception(Craft::t('Could not find a user with Id of {userId}.', array('{userId}' => $this->getId())));
                     }
                 } else {
                     throw new Exception(Craft::t('{class}.allowAutoLogin must be set true in order to use cookie-based authentication.', array('{class}' => get_class($this))));
                 }
             }
             // Run any after login logic.
             $this->afterLogin(false);
         }
         return !$this->getIsGuest();
     }
     Craft::log('Tried to log in unsuccessfully.', LogLevel::Warning);
     return false;
 }
开发者ID:jamiepittock,项目名称:WhereForArt,代码行数:40,代码来源:Social_UserSessionService.php

示例13: import

 /**
  * Attempt to import category groups.
  *
  * @param array $categoryGroupDefinitions
  * @param bool  $force                    If set to true category groups not included in the import will be deleted
  *
  * @return Result
  */
 public function import(array $categoryGroupDefinitions, $force = false)
 {
     Craft::log(Craft::t('Importing Category Groups'));
     $this->resetCraftCategoriesServiceCache();
     $categoryGroups = Craft::app()->categories->getAllGroups('handle');
     foreach ($categoryGroupDefinitions as $categoryGroupHandle => $categoryGroupDefinition) {
         $categoryGroup = array_key_exists($categoryGroupHandle, $categoryGroups) ? $categoryGroups[$categoryGroupHandle] : new CategoryGroupModel();
         unset($categoryGroups[$categoryGroupHandle]);
         $this->populateCategoryGroup($categoryGroup, $categoryGroupDefinition, $categoryGroupHandle);
         if (!Craft::app()->categories->saveGroup($categoryGroup)) {
             // Save categorygroup via craft
             $this->addErrors($categoryGroup->getAllErrors());
             continue;
         }
     }
     if ($force) {
         foreach ($categoryGroups as $categoryGroup) {
             Craft::app()->categories->deleteGroupById($categoryGroup->id);
         }
     }
     return $this->getResultModel();
 }
开发者ID:itmundi,项目名称:schematic,代码行数:30,代码来源:CategoryGroups.php

示例14: callLever

 public function callLever($url)
 {
     $cachedResponse = craft()->fileCache->get($url);
     if ($cachedResponse) {
         return $cachedResponse;
     }
     try {
         $client = new Client();
         $request = $client->get($url);
         $response = $request->send();
         if (!$response->isSuccessful()) {
             return;
         }
         $items = $response->json();
         craft()->fileCache->set($url, $items);
         return $items;
     } catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
         Craft::log(__METHOD__ . " Couldn't get lever response", LogLevel::Info, true);
     } catch (\Guzzle\Http\Exception\CurlException $e) {
         Craft::log(__METHOD__ . " " . $e->getMessage(), LogLevel::Info, true);
     }
 }
开发者ID:efollender,项目名称:craft-lever-postings,代码行数:22,代码来源:LeverPostings_ItemsService.php

示例15: init

 /**
  * Initialize Sentry.
  */
 public function init()
 {
     try {
         // Get plugin settings
         $settings = $this->getSettings();
         // See if we have to report in devMode
         if (craft()->config->get('devMode')) {
             if (!$settings->reportInDevMode) {
                 return;
             }
         }
         $this->configureBackendSentry();
         $this->configureFrontendSentry();
     } catch (Exception $e) {
         Craft::log("ERROR: The craft sentry plugin encountered an error wheil trying to initialize: {$e}", LogLevel::Error);
     }
 }
开发者ID:jayelkaake,项目名称:craft-sentry,代码行数:20,代码来源:SentryPlugin.php


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