本文整理汇总了PHP中Craft::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Craft::log方法的具体用法?PHP Craft::log怎么用?PHP Craft::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Craft
的用法示例。
在下文中一共展示了Craft::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
Craft::log('Changing tasks table settings column to mediumtext.', LogLevel::Info, true);
$this->alterColumn('tasks', 'settings', array('column' => ColumnType::MediumText));
Craft::log('Done changing tasks table settings column to mediumtext.', LogLevel::Info, true);
return true;
}
示例2: transferSystemToken
private function transferSystemToken($namespace)
{
try {
if (file_exists(CRAFT_PLUGINS_PATH . 'oauth/vendor/autoload.php')) {
require_once CRAFT_PLUGINS_PATH . 'oauth/vendor/autoload.php';
}
if (class_exists('OAuth\\OAuth1\\Token\\StdOAuth1Token')) {
// get token record
$row = craft()->db->createCommand()->select('*')->from('oauth_old_tokens')->where('namespace = :namespace', array(':namespace' => $namespace))->queryRow();
if ($row) {
// transform token
$token = @unserialize(base64_decode($row['token']));
if ($token) {
// oauth 1
$newToken = new \OAuth\OAuth1\Token\StdOAuth1Token();
$newToken->setAccessToken($token->access_token);
$newToken->setRequestToken($token->access_token);
$newToken->setRequestTokenSecret($token->secret);
$newToken->setAccessTokenSecret($token->secret);
$this->saveToken($newToken);
} else {
Craft::log('Token error.', LogLevel::Info, true);
}
} else {
Craft::log('Token record error.', LogLevel::Info, true);
}
} else {
Craft::log('Class error.', LogLevel::Info, true);
}
} catch (\Exception $e) {
Craft::log($e->getMessage(), LogLevel::Info, true);
}
}
示例3: init
/**
*
*/
public function init()
{
try {
parent::init();
} catch (\CDbException $e) {
Craft::log($e->getMessage(), LogLevel::Error);
$missingPdo = false;
// TODO: Multi-db driver check.
if (!extension_loaded('pdo')) {
$missingPdo = true;
$messages[] = Craft::t('Craft requires the PDO extension to operate.');
}
if (!extension_loaded('pdo_mysql')) {
$missingPdo = true;
$messages[] = Craft::t('Craft requires the PDO_MYSQL driver to operate.');
}
if (!$missingPdo) {
Craft::log($e->getMessage(), LogLevel::Error);
$messages[] = Craft::t('There is a problem connecting to the database with the credentials supplied in your db config file.');
}
} catch (\Exception $e) {
Craft::log($e->getMessage(), LogLevel::Error);
$messages[] = Craft::t('There is a problem connecting to the database with the credentials supplied in your db config file.');
}
if (!empty($messages)) {
throw new DbConnectException(Craft::t('Database configuration errors: {errors}', array('errors' => implode(PHP_EOL, $messages))));
}
$this->_isDbConnectionValid = true;
// Now that we've validated the config and connection, set extra db logging if devMode is enabled.
if (craft()->config->get('devMode')) {
$this->enableProfiling = true;
$this->enableParamLogging = true;
}
}
示例4: actionSend
/**
* Sends the push notification.
*
* @param $args
*
* @return int
*/
public function actionSend($args)
{
// Log invocation
Craft::log($this->getCommandRunner()->getScriptName());
// Get notification id
$id = $args[0];
// Validate id
if (!is_numeric($id)) {
$this->usageError(Craft::t('The argument must be a numeric id'));
}
// Get notification
$notification = craft()->pushNotifications_notifications->getNotificationById($id);
// Validate notification
if (!$notification) {
$this->usageError(Craft::t('No notification found with id "{id}"', array('id' => $id)));
}
try {
// Send notification
$platforms = craft()->pushNotifications_push->sendNotification($notification);
} catch (\Exception $e) {
$this->usageError($e->getMessage());
}
// Count devices
$devices = 0;
foreach ($platforms as $platform) {
$devices += $platform;
}
// Show result
echo Craft::t('Notification sent to {devices} device(s)', array('devices' => $devices)) . "\n";
exit(0);
}
示例5: actionSaveSet
/**
* Saves a global set.
*/
public function actionSaveSet()
{
$this->requirePostRequest();
$globalSet = new GlobalSetModel();
// Set the simple stuff
$globalSet->id = craft()->request->getPost('setId');
$globalSet->name = craft()->request->getPost('name');
$globalSet->handle = craft()->request->getPost('handle');
// Set the field layout
$fieldLayout = craft()->fields->assembleLayoutFromPost(false);
$fieldLayout->type = ElementType::GlobalSet;
$globalSet->setFieldLayout($fieldLayout);
// Save it
if (craft()->globals->saveSet($globalSet)) {
craft()->userSession->setNotice(Craft::t('Global set saved.'));
// TODO: Remove for 2.0
if (isset($_POST['redirect']) && strpos($_POST['redirect'], '{setId}') !== false) {
Craft::log('The {setId} token within the ‘redirect’ param on globals/saveSet requests has been deprecated. Use {id} instead.', LogLevel::Warning);
$_POST['redirect'] = str_replace('{setId}', '{id}', $_POST['redirect']);
}
$this->redirectToPostedUrl($globalSet);
} else {
craft()->userSession->setError(Craft::t('Couldn’t save global set.'));
}
// Send the global set back to the template
craft()->urlManager->setRouteVariables(array('globalSet' => $globalSet));
}
示例6: actionSaveField
/**
* Saves a field.
*/
public function actionSaveField()
{
$this->requirePostRequest();
$field = new FieldModel();
$field->id = craft()->request->getPost('fieldId');
$field->groupId = craft()->request->getRequiredPost('group');
$field->name = craft()->request->getPost('name');
$field->handle = craft()->request->getPost('handle');
$field->instructions = craft()->request->getPost('instructions');
$field->translatable = (bool) craft()->request->getPost('translatable');
$field->type = craft()->request->getRequiredPost('type');
$typeSettings = craft()->request->getPost('types');
if (isset($typeSettings[$field->type])) {
$field->settings = $typeSettings[$field->type];
}
if (craft()->fields->saveField($field)) {
craft()->userSession->setNotice(Craft::t('Field saved.'));
// TODO: Remove for 2.0
if (isset($_POST['redirect']) && strpos($_POST['redirect'], '{fieldId}') !== false) {
Craft::log('The {fieldId} token within the ‘redirect’ param on fields/saveField requests has been deprecated. Use {id} instead.', LogLevel::Warning);
$_POST['redirect'] = str_replace('{fieldId}', '{id}', $_POST['redirect']);
}
$this->redirectToPostedUrl($field);
} else {
craft()->userSession->setError(Craft::t('Couldn’t save field.'));
}
// Send the field back to the template
craft()->urlManager->setRouteVariables(array('field' => $field));
}
示例7: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
Craft::log('Moving the logo from storage/logo to storage/rebrand/logo', LogLevel::Info, true);
IOHelper::rename(craft()->path->getStoragePath() . 'logo', craft()->path->getRebrandPath() . 'logo', true);
Craft::log('Done moving the logo from storage/logo to storage/rebrand/logo', LogLevel::Info, true);
return true;
}
示例8: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
Craft::log('Adding locked column to users table...', LogLevel::Info, true);
$this->addColumnAfter('users', 'locked', array(AttributeType::Bool, 'required' => true), 'status');
Craft::log('Adding suspended column to users table...', LogLevel::Info, true);
$this->addColumnAfter('users', 'suspended', array(AttributeType::Bool, 'required' => true), 'locked');
Craft::log('Adding pending column to users table...', LogLevel::Info, true);
$this->addColumnAfter('users', 'pending', array(AttributeType::Bool, 'required' => true), 'suspended');
Craft::log('Adding archived column to users table...', LogLevel::Info, true);
$this->addColumnAfter('users', 'archived', array(AttributeType::Bool, 'required' => true), 'pending');
Craft::log('Updating locked users...', LogLevel::Info, true);
$this->update('users', array('locked' => 1), array('status' => 'locked'));
$this->update('users', array('locked' => 0), 'locked IS NULL');
Craft::log('Updating pending users...', LogLevel::Info, true);
$this->update('users', array('pending' => 1), array('status' => 'pending'));
$this->update('users', array('pending' => 0), 'pending IS NULL');
Craft::log('Updating archived users...', LogLevel::Info, true);
$this->update('users', array('archived' => 1), array('status' => 'archived'));
$this->update('users', array('archived' => 0), 'archived IS NULL');
Craft::log('Updating suspended users...', LogLevel::Info, true);
$this->update('users', array('suspended' => 1), array('status' => 'suspended'));
$this->update('users', array('suspended' => 0), 'suspended IS NULL');
Craft::log('Dropping status column from users table...', LogLevel::Info, true);
$this->dropColumn('users', 'status');
Craft::log('Done updating user statuses.', LogLevel::Info, true);
return true;
}
示例9: init
public function init()
{
Craft::log(__METHOD__, LogLevel::Info, true);
// request params
$providerHandle = craft()->request->getParam('provider');
$namespace = craft()->request->getParam('namespace');
$scope = unserialize(base64_decode(craft()->request->getParam('scope')));
// userMode
$userMode = false;
if (!$namespace) {
$userMode = true;
}
// clean session vars
if (!craft()->httpSession->get('oauth.social')) {
craft()->oauth->sessionClean();
}
// set session vars
craft()->oauth->sessionAdd('oauth.providerClass', $providerHandle);
craft()->oauth->sessionAdd('oauth.userMode', $userMode);
craft()->oauth->sessionAdd('oauth.referer', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
craft()->oauth->sessionAdd('oauth.scope', $scope);
// redirect
$url = UrlHelper::getActionUrl('oauth/public/connect/', array('provider' => $providerHandle, 'namespace' => $namespace));
$this->redirect($url);
}
示例10: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
Craft::log('Renaming `social_accounts` table to `social_login_accounts`', LogLevel::Info, true);
MigrationHelper::renameTable('social_accounts', 'social_login_accounts');
Craft::log('Done renaming `social_accounts` table to `social_login_accounts`', LogLevel::Info, true);
return true;
}
开发者ID:ericnormannn,项目名称:m,代码行数:12,代码来源:m151210_000001_social_rename_social_accounts_by_social_login_accounts.php
示例11: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
if (!craft()->db->schema->columnExists('content', 'title')) {
$primaryLocaleId = craft()->i18n->getPrimarySiteLocaleId();
// Add the new 'title' column to the content table
$this->addColumnAfter('content', 'title', array('column' => ColumnType::Varchar), 'locale');
// Migrate the entry titles
$entries = craft()->db->createCommand()->select('entryId, locale, title')->from('entries_i18n')->queryAll();
foreach ($entries as $entry) {
$this->insertOrUpdate('content', array('elementId' => $entry['entryId'], 'locale' => $entry['locale']), array('title' => $entry['title']));
}
unset($entries);
// Delete the old entry titles column
$this->dropIndex('entries_i18n', 'title');
$this->dropColumn('entries_i18n', 'title');
// Create asset titles based on the filenames
$assets = craft()->db->createCommand()->select('id, filename')->from('assetfiles')->queryAll();
foreach ($assets as $asset) {
$filename = pathinfo($asset['filename'], PATHINFO_FILENAME);
$filename = str_replace('_', ' ', $filename);
$this->insertOrUpdate('content', array('elementId' => $asset['id'], 'locale' => $primaryLocaleId), array('title' => $filename));
}
unset($assets);
// Create the index on the new titles column
craft()->db->createCommand()->createIndex('content', 'title');
} else {
Craft::log('Tried to add a `title` column to the `content` table, but there is already one there.', LogLevel::Warning);
}
return true;
}
示例12: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
Craft::log('Changing asset index data table uri column to text.', LogLevel::Info, true);
$this->alterColumn('assetindexdata', 'uri', array('column' => ColumnType::Text));
Craft::log('Done changing asset index data table uri column to text.', LogLevel::Info, true);
return true;
}
示例13: safeUp
public function safeUp()
{
$productIds = craft()->db->createCommand()->select('id')->from("market_products")->queryColumn();
$variantProductIds = craft()->db->createCommand()->select('productId')->from("market_variants")->queryColumn();
$variantProductIds = array_unique($variantProductIds);
foreach ($variantProductIds as $vId) {
if (!in_array($vId, $productIds)) {
Craft::log("Deleting variant with productId: " . $vId);
craft()->db->createCommand()->delete('market_variants', 'productId=:id', array(':id' => $vId));
}
}
$types = ['Market_Product', 'Market_Variant', 'Market_Order'];
foreach ($types as $type) {
$elements = craft()->db->createCommand()->select('id')->from('elements')->where('type = :type', [':type' => $type])->queryColumn();
$tableName = strtolower($type) . "s";
$marketTableElements = craft()->db->createCommand()->select('id')->from($tableName)->queryColumn();
$count = 0;
foreach ($elements as $p) {
if (!in_array($p, $marketTableElements)) {
Craft::log("Deleting " . $type . " element not in market table id: " . $p);
craft()->db->createCommand()->delete('elements', 'id=:id', array(':id' => $p));
$count++;
}
}
Craft::log("Total " . $type . " elements removed as they are not in market tables: " . $count);
}
$table = craft()->db->schema->getTable('craft_market_variants');
if (isset($table->columns['deletedAt'])) {
$this->dropColumn('market_variants', 'deletedAt');
}
return true;
}
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:32,代码来源:m150820_010101_Market_FixProductAndVariants.php
示例14: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
// unique index for 'userMapping' and 'provider'
$tableName = 'oauth_tokens';
$providersTable = $this->dbConnection->schema->getTable('{{' . $tableName . '}}');
if ($providersTable) {
$columns = 'userMapping, provider';
$unique = true;
$this->createIndex($tableName, $columns, $unique);
} else {
Craft::log('Could not find an `' . $tableName . '` table. Wut?', LogLevel::Error);
}
// unique index for 'userId' and 'provider'
$tableName = 'oauth_tokens';
$providersTable = $this->dbConnection->schema->getTable('{{' . $tableName . '}}');
if ($providersTable) {
$columns = 'userId, provider';
$unique = true;
$this->createIndex($tableName, $columns, $unique);
} else {
Craft::log('Could not find an `' . $tableName . '` table. Wut?', LogLevel::Error);
}
// unique index for 'namespace' and 'provider'
$tableName = 'oauth_tokens';
$providersTable = $this->dbConnection->schema->getTable('{{' . $tableName . '}}');
if ($providersTable) {
$columns = 'namespace, provider';
$unique = true;
$this->createIndex($tableName, $columns, $unique);
} else {
Craft::log('Could not find an `' . $tableName . '` table. Wut?', LogLevel::Error);
}
return true;
}
示例15: safeUp
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
// Create the categorygroups table
if (!craft()->db->tableExists('categorygroups')) {
Craft::log('Creating the categorygroups table', LogLevel::Info, true);
$this->createTable('categorygroups', array('structureId' => array('column' => ColumnType::Int, 'null' => false), 'fieldLayoutId' => array('column' => ColumnType::Int), 'name' => array('column' => ColumnType::Varchar, 'required' => true), 'handle' => array('column' => ColumnType::Varchar, 'required' => true), 'hasUrls' => array('column' => ColumnType::Bool, 'required' => true, 'default' => true), 'template' => array('column' => ColumnType::Varchar, 'maxLength' => 500)));
$this->createIndex('categorygroups', 'name', true);
$this->createIndex('categorygroups', 'handle', true);
$this->addForeignKey('categorygroups', 'structureId', 'structures', 'id', 'CASCADE');
$this->addForeignKey('categorygroups', 'fieldLayoutId', 'fieldlayouts', 'id', 'SET NULL');
}
// Create the categorygroups_i18n table
if (!craft()->db->tableExists('categorygroups_i18n')) {
Craft::log('Creating the categorygroups_i18n table', LogLevel::Info, true);
$this->createTable('categorygroups_i18n', array('groupId' => array('column' => ColumnType::Int, 'required' => true), 'locale' => array('column' => ColumnType::Locale, 'required' => true), 'urlFormat' => array('column' => ColumnType::Varchar), 'nestedUrlFormat' => array('column' => ColumnType::Varchar)));
$this->createIndex('categorygroups_i18n', 'groupId,locale', true);
$this->addForeignKey('categorygroups_i18n', 'groupId', 'categorygroups', 'id', 'CASCADE');
$this->addForeignKey('categorygroups_i18n', 'locale', 'locales', 'locale', 'CASCADE', 'CASCADE');
}
// Create the categories table
if (!craft()->db->tableExists('categories')) {
Craft::log('Creating the categories table', LogLevel::Info, true);
$this->createTable('categories', array('id' => array('column' => ColumnType::Int, 'required' => true, 'primaryKey' => true), 'groupId' => array('column' => ColumnType::Int, 'required' => true)), null, false);
$this->addForeignKey('categories', 'id', 'elements', 'id', 'CASCADE');
$this->addForeignKey('categories', 'groupId', 'categorygroups', 'id', 'CASCADE');
}
return true;
}