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


PHP Drupal::logger方法代码示例

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


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

示例1: purlCheckNodeContext

 /**
  * Checks if a node's type requires a redirect.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The event to process.
  */
 public function purlCheckNodeContext(GetResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher_interface)
 {
     $route_options = $this->routeMatch->getRouteObject()->getOptions();
     $isAdminRoute = array_key_exists('_admin_route', $route_options) && $route_options['_admin_route'];
     if (!$isAdminRoute && ($matched = $this->matchedModifiers->getMatched() && ($entity = $this->routeMatch->getParameter('node')))) {
         $node_type = $this->entityStorage->load($entity->bundle());
         $purl_settings = $node_type->getThirdPartySettings('purl');
         if (!isset($purl_settings['keep_context']) || !$purl_settings['keep_context']) {
             $url = \Drupal\Core\Url::fromRoute($this->routeMatch->getRouteName(), $this->routeMatch->getRawParameters()->all(), ['host' => Settings::get('purl_base_domain'), 'absolute' => TRUE]);
             try {
                 $redirect_response = new TrustedRedirectResponse($url->toString());
                 $redirect_response->getCacheableMetadata()->setCacheMaxAge(0);
                 $modifiers = $event->getRequest()->attributes->get('purl.matched_modifiers', []);
                 $new_event = new ExitedContextEvent($event->getRequest(), $redirect_response, $this->routeMatch, $modifiers);
                 $dispatcher_interface->dispatch(PurlEvents::EXITED_CONTEXT, $new_event);
                 $event->setResponse($new_event->getResponse());
                 return;
             } catch (RedirectLoopException $e) {
                 \Drupal::logger('redirect')->warning($e->getMessage());
                 $response = new Response();
                 $response->setStatusCode(503);
                 $response->setContent('Service unavailable');
                 $event->setResponse($response);
                 return;
             }
         }
     }
 }
开发者ID:activelamp,项目名称:purl-d8,代码行数:34,代码来源:PurlNodeContextRoutes.php

示例2: assignPackages

 /**
  * {@inheritdoc}
  */
 public function assignPackages($force = FALSE)
 {
     $current_bundle = $this->assigner->getBundle();
     $settings = $current_bundle->getAssignmentSettings($this->getPluginId());
     $config_base_types = $settings['types']['config'];
     $config_types = $this->featuresManager->listConfigTypes();
     $config_collection = $this->featuresManager->getConfigCollection();
     foreach ($config_collection as $item_name => $item) {
         if (in_array($item->getType(), $config_base_types)) {
             if (is_null($this->featuresManager->findPackage($item->getShortName())) && !$item->getPackage()) {
                 $description = $this->t('Provides @label @type and related configuration.', array('@label' => $item->getLabel(), '@type' => Unicode::strtolower($config_types[$item->getType()])));
                 if (isset($item->getData()['description'])) {
                     $description .= ' ' . $item->getData()['description'];
                 }
                 $this->featuresManager->initPackage($item->getShortName(), $item->getLabel(), $description, 'module', $current_bundle);
                 // Update list with the package we just added.
                 try {
                     $this->featuresManager->assignConfigPackage($item->getShortName(), [$item_name]);
                 } catch (\Exception $exception) {
                     \Drupal::logger('features')->error($exception->getMessage());
                 }
                 $this->featuresManager->assignConfigDependents([$item_name]);
             }
         }
     }
     $entity_types = $this->entityManager->getDefinitions();
     $content_base_types = $settings['types']['content'];
     foreach ($content_base_types as $entity_type_id) {
         if (!isset($packages[$entity_type_id]) && isset($entity_types[$entity_type_id])) {
             $label = $entity_types[$entity_type_id]->getLabel();
             $description = $this->t('Provide @label related configuration.', array('@label' => $label));
             $this->featuresManager->initPackage($entity_type_id, $label, $description, 'module', $current_bundle);
         }
     }
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:38,代码来源:FeaturesAssignmentBaseType.php

示例3: chargeCard

 /**
  * {@inheritdoc}
  */
 protected function chargeCard($order, $amount, $txn_type, $reference = NULL)
 {
     $user = \Drupal::currentUser();
     // cc_exp_month and cc_exp_year are also validated by
     // _uc_credit_valid_card_expiration() on the checkout form.
     $month = $order->payment_details['cc_exp_month'];
     $year = $order->payment_details['cc_exp_year'];
     if ($year < 100) {
         $year = $year + 2000;
     }
     // Card is expired at 0:00 on the first day of the next month.
     $expiration_date = mktime(0, 0, 0, $month + 1, 1, $year);
     // Conditions for failure are described in file documentation block above.
     // All other transactions will succeed.
     if ($order->payment_details['cc_number'] == '0000000000000000' || isset($order->payment_details['cc_cvv']) && $order->payment_details['cc_cvv'] == '000' || $expiration_date - REQUEST_TIME <= 0 || $amount == 12.34 || $order->billing_first_name == 'Fictitious' || $order->billing_phone == '8675309') {
         $success = FALSE;
     } else {
         $success = TRUE;
     }
     // The information for the payment is in the $order->payment_details array.
     if ($this->configuration['debug']) {
         \Drupal::logger('uc_credit')->notice('Test gateway payment details @details.', ['@details' => print_r($order->payment_details, TRUE)]);
     }
     if ($success) {
         $message = $this->t('Credit card charged: @amount', ['@amount' => uc_currency_format($amount)]);
         uc_order_comment_save($order->id(), $user->id(), $message, 'admin');
     } else {
         $message = $this->t('Credit card charge failed.');
         uc_order_comment_save($order->id(), $user->id(), $message, 'admin');
     }
     $result = array('success' => $success, 'comment' => $this->t('Card charged, resolution code: 0022548315'), 'message' => $success ? $this->t('Credit card payment processed successfully.') : $this->t('Credit card charge failed.'), 'uid' => $user->id());
     return $result;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:36,代码来源:TestGateway.php

示例4: at_core_submit_color

/**
 * @file
 * Saves a parsable inc file with the full color info array for the active theme.
 *
 * If a custom color scheme has been created in the UI it is injected into the
 * schemes array and saved. You must rename the Custom scheme and give it a
 * unique array key before using the generated file in your theme.
 *
 * Note that color module validates the input of the color form and this is not
 * run if there is a problem, e.g. the user inputting non hexadecimal CSS color
 * strings, which color module validates to avoid XSS.
 */
function at_core_submit_color(&$form, &$form_state) {

  $build_info = $form_state->getBuildInfo();
  $values = $form_state->getValues();
  $theme = $build_info['args'][0];

  $palette = $values['palette'];

  $indent = str_pad(' ', 6);
  $lines = explode("\n", var_export($palette, TRUE));

  array_shift($lines);

  $message  = "    'PaletteName' => array(\n";
  $message .= $indent . "'title' => t('PaletteName'),\n";
  $message .= $indent . "'colors' => array(\n";
  $last_line = $indent . array_pop($lines) . ',';

  foreach ($lines as $line) {
    if (strpos($line, ' => ') !== FALSE) {
      $parts = explode(' => ', $line);
      $message .= $indent . $parts[0] . str_pad(' ', (46 - strlen($line))) . '=> ' . $parts[1];
    } else {
      $message .=  "$indent  $line";
    }
    $message .=  "\n";
  }

  $message .= "$last_line\n";
  $message .= "    ),\n";
  $message = '<pre>' . $message . '</pre>';

  //watchdog('Custom color palette', $message);
  \Drupal::logger($theme)->notice($message);
}
开发者ID:jno84,项目名称:drupal8,代码行数:47,代码来源:color_submit.php

示例5: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Pass the file to the parser.
     $fid = $form_state->getValue('mtg_import_json_file');
     $fid = reset($fid);
     if ($fid == 0) {
         return FALSE;
     }
     $file = File::load($fid);
     if (!$file) {
         drupal_set_message('Unable to load file.');
         \Drupal::logger('mtg_import')->error(t('Unable to load the file.'));
         return FALSE;
     }
     $uri = $file->uri->value;
     $file_contents_raw = file_get_contents($uri);
     $file_contents = json_decode($file_contents_raw);
     if (!empty($file_contents->cards)) {
         $operations = [['mtg_import_parse_set_data', [$file_contents]]];
         $chunks = array_chunk($file_contents->cards, 20);
         foreach ($chunks as $chunk) {
             $operations[] = ['mtg_import_parse_card_data', [$chunk]];
         }
         $batch = ['title' => t('Importing'), 'operations' => $operations, 'finished' => 'mtg_import_completed', 'progress_message' => t('Completed part @current of @total.')];
         batch_set($batch);
     } else {
         drupal_set_message(t('There are no cards in the file, so no import will take place.'), 'warning');
     }
 }
开发者ID:mangyfox,项目名称:magic-v2,代码行数:32,代码来源:UploadForm.php

示例6: reportWork

 /**
  * Simple reporter log and display information about the queue.
  *
  * @param int $worker
  *   Worker number.
  * @param object $item
  *   The $item which was stored in the cron queue.
  */
 protected function reportWork($worker, $item)
 {
     if (\Drupal::state()->get('cron_example_show_status_message')) {
         drupal_set_message($this->t('Queue @worker worker processed item with sequence @sequence created at @time', ['@worker' => $worker, '@sequence' => $item->sequence, '@time' => date_iso8601($item->created)]));
     }
     \Drupal::logger('cron_example')->info('Queue @worker worker processed item with sequence @sequence created at @time', ['@worker' => $worker, '@sequence' => $item->sequence, '@time' => date_iso8601($item->created)]);
 }
开发者ID:seongbae,项目名称:drumo-distribution,代码行数:15,代码来源:ReportWorkerBase.php

示例7: testStatus

 /**
  * Determines the status of all user-contributed tests and logs any failures to
  * a tracking table.
  *
  * @param boolean $log
  *  (Optional) If TRUE, log all failures.
  *
  * @return array $custom_data
  *  An associative array containing any tests which failed validation.
  */
 public function testStatus($log = FALSE)
 {
     $custom_data = array();
     // Iterate through modules which contain hook_acquia_spi_test().
     foreach (\Drupal::moduleHandler()->getImplementations('acquia_connector_spi_test') as $module) {
         $function = $module . '_acquia_connector_spi_test';
         if (function_exists($function)) {
             $result = $this->testValidate($function());
             if (!$result['result']) {
                 $custom_data[$module] = $result;
                 foreach ($result['failure'] as $test_name => $test_failures) {
                     foreach ($test_failures as $test_param => $test_value) {
                         $variables = array('@module' => $module, '@message' => $test_value['message'], '@param_name' => $test_param, '@test' => $test_name, '@value' => $test_value['value']);
                         // Only log if we're performing a full validation check.
                         if ($log) {
                             drupal_set_message($this->t("Custom test validation failed for @test in @module and has been logged: @message for parameter '@param_name'; current value '@value'.", $variables), 'error');
                             \Drupal::logger('acquia spi test')->notice("<em>Custom test validation failed</em>: @message for parameter '@param_name'; current value '@value'. (<em>Test '@test_name' in module '@module_name'</em>)", $variables);
                         }
                     }
                 }
             }
         }
     }
     // If a full validation check is being performed, go to the status page to
     // show the results.
     if ($log) {
         $this->redirect('system.status');
     }
     return $custom_data;
 }
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:40,代码来源:TestStatusController.php

示例8: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $entity = $this->getEntity();
     $entity->delete();
     \Drupal::logger('eck')->notice('@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label()));
     $form_state->setRedirectUrl(new Url('eck.entity.' . $this->entity->getEntityTypeId() . '.list'));
 }
开发者ID:jokas,项目名称:d8.dev,代码行数:10,代码来源:EckEntityDeleteForm.php

示例9: __construct

 public function __construct($publication)
 {
     $this->publication = $this->convert_smart_quotes($publication);
     $this->remainingData = $this->publication;
     $this->logger = \Drupal::logger('import_publication');
     //$this->logger->notice(t("New Publication String:" . $this->publication));
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:7,代码来源:PublicationParser.php

示例10: query

 /**
  * {@inheritdoc}
  */
 public function query($group_by = FALSE) {
   try {
     $server = $this->query->getIndex()->getServer();
     if (!$server->supportsFeature('search_api_mlt')) {
       $backend_id = $server->getBackendId();
       \Drupal::logger('search_api')->error('The search backend "@backend_id" does not offer "More like this" functionality.',
         array('@backend_id' => $backend_id));
       $this->query->abort();
       return;
     }
     $fields = isset($this->options['fields']) ? $this->options['fields'] : array();
     if (!$fields) {
       foreach ($this->query->getIndex()->getOption('fields', array()) as $key => $field) {
         $fields[] = $key;
       }
     }
     $mlt = array(
       'id' => $this->argument,
       'fields' => $fields,
     );
     $this->query->getSearchApiQuery()->setOption('search_api_mlt', $mlt);
   }
   catch (SearchApiException $e) {
     $this->query->abort($e->getMessage());
   }
 }
开发者ID:jkyto,项目名称:agolf,代码行数:29,代码来源:SearchApiMoreLikeThis.php

示例11: submitForm

 /**
  * {@inheritdoc}
  *
  * Delete the entity and log the event. log() replaces the watchdog.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $entity = $this->getEntity();
     $entity->delete();
     \Drupal::logger('reservations')->notice('@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label()));
     $form_state->setRedirect('entity.reservation.list');
 }
开发者ID:wallecan,项目名称:drupalpp,代码行数:12,代码来源:ReservationDeleteForm.php

示例12: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->entity->delete();
     drupal_set_message($this->t('Domain %label has been deleted.', array('%label' => $this->entity->label())));
     \Drupal::logger('domain')->notice('Domain %label has been deleted.', array('%label' => $this->entity->label()));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
开发者ID:dropdog,项目名称:play,代码行数:10,代码来源:DomainDeleteForm.php

示例13: purgeTags

 /**
  * Purges cache tags on CloudFlare.
  *
  * @todo Once https://github.com/d8-contrib-modules/cloudflare/issues/16 is
  *   done, this should disappear.
  *
  * @param string[] $tags
  *   The list of tags for which to invalidate cache items.
  */
 public function purgeTags(array $tags)
 {
     $config = \Drupal::config('cloudflare.settings');
     $api_key = $config->get('apikey');
     $email = $config->get('email');
     $zone = $config->get('zone');
     // If the module is not yet configured, don't attempt to purge.
     // @todo Improve the rest of the architecture of this module so this check
     //   is not necessary anymore.
     if (!isset($api_key)) {
         return;
     }
     try {
         $this->zoneApi = new ZoneApi($api_key, $email);
         // @todo rethink how to handle cloudflare zones in Drupal.
         if (is_null($zone)) {
             $zones = $this->zoneApi->listZones();
             $zone = $zones[0]->getZoneId();
         }
         $this->zoneApi->purgeTags($zone, $tags);
     } catch (CloudFlareHttpException $e) {
         drupal_set_message("Unable to clear zone cache. " . $e->getMessage(), 'error');
         \Drupal::logger('cloudflare')->error($e->getMessage());
         return;
     } catch (CloudFlareApiException $e) {
         drupal_set_message("Unable to clear zone cache. " . $e->getMessage(), 'error');
         \Drupal::logger('cloudflare')->error($e->getMessage());
         return;
     }
     // If no exceptions have been thrown then the request has been successful.
 }
开发者ID:victorcpereira,项目名称:cloudflare,代码行数:40,代码来源:CacheTagsInvalidator.php

示例14: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->entity->delete();
     drupal_set_message(t('Newsletter %label has been deleted.', array('%label' => $this->entity->label())));
     \Drupal::logger('simplenews')->notice('Newsletter %label has been deleted.', array('%label' => $this->entity->label()));
     $form_state->setRedirect('simplenews.newsletter_list');
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:10,代码来源:NewsletterDeleteForm.php

示例15: access

 /**
  * Access callback for json() callback.
  */
 public function access()
 {
     $request = \Drupal::request();
     $nonce = $request->get('nonce', FALSE);
     $connector_config = $this->config('acquia_connector.settings');
     // If we don't have all the query params, leave now.
     if (!$nonce) {
         return AccessResultForbidden::forbidden();
     }
     $sub_data = $connector_config->get('subscription_data');
     $sub_uuid = $this->getIdFromSub($sub_data);
     if (!empty($sub_uuid)) {
         $expected_hash = hash('sha1', "{$sub_uuid}:{$nonce}");
         // If the generated hash matches the hash from $_GET['key'], we're good.
         if ($request->get('key', FALSE) === $expected_hash) {
             return AccessResultAllowed::allowed();
         }
     }
     // Log the request if validation failed and debug is enabled.
     if ($connector_config->get('debug')) {
         $info = array('sub_data' => $sub_data, 'sub_uuid_from_data' => $sub_uuid, 'expected_hash' => $expected_hash, 'get' => $request->query->all(), 'server' => $request->server->all(), 'request' => $request->request->all());
         \Drupal::logger('acquia_agent')->notice('Site status request: @data', array('@data' => var_export($info, TRUE)));
     }
     return AccessResultForbidden::forbidden();
 }
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:28,代码来源:StatusController.php


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