本文整理汇总了PHP中watchdog_exception函数的典型用法代码示例。如果您正苦于以下问题:PHP watchdog_exception函数的具体用法?PHP watchdog_exception怎么用?PHP watchdog_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了watchdog_exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$module = $input->getArgument('module');
$module_handler = $this->getModuleHandler();
if ($module != 'all') {
$modules = [$module];
} else {
$modules = $module_handler->getImplementations('cron');
}
foreach ($modules as $module) {
if ($module_handler->implementsHook($module, 'cron')) {
$io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
try {
$module_handler->invoke($module, 'cron');
} catch (\Exception $e) {
watchdog_exception('cron', $e);
$io->error($e->getMessage());
}
} else {
$io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
}
}
$this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$modules = $input->getArgument('module');
$module_handler = $this->getDrupalService('module_handler');
$lock = $this->getDrupalService('lock');
// Try to acquire cron lock.
if (!$lock->acquire('cron', 900.0)) {
$io->warning($this->trans('commands.cron.execute.messages.lock'));
return;
}
if (in_array('all', $modules)) {
$modules = $module_handler->getImplementations('cron');
}
foreach ($modules as $module) {
if ($module_handler->implementsHook($module, 'cron')) {
$io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
try {
$module_handler->invoke($module, 'cron');
} catch (\Exception $e) {
watchdog_exception('cron', $e);
$io->error($e->getMessage());
}
} else {
$io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
}
}
// Set last time cron was executed
\Drupal::state()->set('system.cron_last', REQUEST_TIME);
// Release cron lock.
$lock->release('cron');
$this->get('chain_queue')->addCommand('cache:rebuild', ['cache' => 'all']);
$io->success($this->trans('commands.cron.execute.messages.success'));
}
示例3: alterItems
public function alterItems(array &$items)
{
// Prevent session information from being saved while indexing.
drupal_save_session(FALSE);
// Force the current user to anonymous to prevent access bypass in search
// indexes.
$original_user = $GLOBALS['user'];
$GLOBALS['user'] = drupal_anonymous_user();
$entity_type = $this->index->getEntityType();
$entity_handler = panelizer_entity_plugin_get_handler($entity_type);
foreach ($items as &$item) {
$entity_id = entity_id($entity_type, $item);
$item->search_api_panelizer_content = NULL;
$item->search_api_panelizer_title = NULL;
try {
if ($render_info = $entity_handler->render_entity($item, 'page_manager')) {
$item->search_api_panelizer_content = $render_info['content'];
$item->search_api_panelizer_title = !empty($render_info['title']) ? $render_info['title'] : NULL;
}
} catch (Exception $e) {
watchdog_exception('panelizer', $e, 'Error indexing Panelizer content for %entity_type with ID %entity_id', array('%entity_type' => $entity_type, '%entity_id' => $entity_id));
}
}
// Restore the user.
$GLOBALS['user'] = $original_user;
drupal_save_session(TRUE);
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$modules = $input->getArgument('module');
if (!$this->lock->acquire('cron', 900.0)) {
$io->warning($this->trans('commands.cron.execute.messages.lock'));
return 1;
}
if (in_array('all', $modules)) {
$modules = $this->moduleHandler->getImplementations('cron');
}
foreach ($modules as $module) {
if (!$this->moduleHandler->implementsHook($module, 'cron')) {
$io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
continue;
}
try {
$io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
$this->moduleHandler->invoke($module, 'cron');
} catch (\Exception $e) {
watchdog_exception('cron', $e);
$io->error($e->getMessage());
}
}
$this->state->set('system.cron_last', REQUEST_TIME);
$this->lock->release('cron');
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
$io->success($this->trans('commands.cron.execute.messages.success'));
return 0;
}
示例5: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
/** @var \Drupal\search_api\ServerInterface $server */
$server = $this->getEntity();
try {
$server->deleteAllItems();
drupal_set_message($this->t('All indexed data was successfully deleted from the server.'));
} catch (SearchApiException $e) {
drupal_set_message($this->t('Indexed data could not be cleared for some indexes. Check the logs for details.'), 'error');
}
$failed_reindexing = array();
$properties = array('status' => TRUE, 'read_only' => FALSE);
foreach ($server->getIndexes($properties) as $index) {
try {
$index->reindex();
} catch (SearchApiException $e) {
$args = array('%index' => $index->label());
watchdog_exception('search_api', $e, '%type while clearing index %index: @message in %function (line %line of %file).', $args);
$failed_reindexing[] = $index->label();
}
}
if ($failed_reindexing) {
$args = array('@indexes' => implode(', ', $failed_reindexing));
drupal_set_message($this->t('Failed to mark the following indexes for reindexing: @indexes. Check the logs for details.', $args), 'warning');
}
$form_state->setRedirect('entity.search_api_server.canonical', array('search_api_server' => $server->id()));
}
示例6: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, ServerInterface $search_api_server = NULL)
{
$form['#title'] = $this->t('List of configuration files found');
try {
// Retrieve the list of available files.
$files_list = SearchApiSolrUtility::getServerFiles($search_api_server);
if (empty($files_list)) {
$form['info']['#markup'] = $this->t('No files found.');
return $form;
}
$form['files_tabs'] = array('#type' => 'vertical_tabs');
// Generate a fieldset for each file.
foreach ($files_list as $file_name => $file_info) {
$file_date = format_date(strtotime($file_info['modified']));
$escaped_file_name = SafeMarkup::checkPlain($file_name);
$form['files'][$file_name] = array('#type' => 'details', '#title' => $escaped_file_name, '#group' => 'files_tabs');
$data = '<h3>' . $escaped_file_name . '</h3>';
$data .= '<p><em>' . $this->t('Last modified: @time.', array('@time' => $file_date)) . '</em></p>';
if ($file_info['size'] > 0) {
$file_data = $search_api_server->getBackend()->getFile($file_name);
$data .= '<pre><code>' . SafeMarkup::checkPlain($file_data->getBody()) . '</code></pre>';
} else {
$data .= '<p><em>' . $this->t('The file is empty.') . '</em></p>';
}
$form['files'][$file_name]['data']['#markup'] = $data;
}
} catch (SearchApiException $e) {
watchdog_exception('search_api_solr', $e, '%type while retrieving config files of Solr server @server: !message in %function (line %line of %file).', array('@server' => $search_api_server->label()));
$form['info']['#markup'] = $this->t('An error occured while trying to load the list of files.');
}
return $form;
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$styles = $input->getArgument('styles');
$result = 0;
$imageStyle = $this->entityTypeManager->getStorage('image_style');
$stylesNames = [];
if (in_array('all', $styles)) {
$styles = $imageStyle->loadMultiple();
foreach ($styles as $style) {
$stylesNames[] = $style->get('name');
}
$styles = $stylesNames;
}
foreach ($styles as $style) {
try {
$io->info(sprintf($this->trans('commands.image.styles.flush.messages.executing-flush'), $style));
$imageStyle->load($style)->flush();
} catch (\Exception $e) {
watchdog_exception('image', $e);
$io->error($e->getMessage());
$result = 1;
}
}
$io->success($this->trans('commands.image.styles.flush.messages.success'));
return $result;
}
示例8: form
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state)
{
$form = parent::form($form, $form_state);
/** @var \Drupal\embed\EmbedButtonInterface $button */
$button = $this->entity;
$form_state->setTemporaryValue('embed_button', $button);
$form['label'] = ['#title' => $this->t('Label'), '#type' => 'textfield', '#default_value' => $button->label(), '#description' => t('The human-readable name of this embed button. This text will be displayed when the user hovers over the CKEditor button. This name must be unique.'), '#required' => TRUE, '#size' => 30];
$form['id'] = ['#type' => 'machine_name', '#default_value' => $button->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$button->isNew(), '#machine_name' => ['exists' => ['Drupal\\embed\\Entity\\EmbedButton', 'load']], '#description' => $this->t('A unique machine-readable name for this embed button. It must only contain lowercase letters, numbers, and underscores.')];
$form['type_id'] = ['#type' => 'select', '#title' => $this->t('Embed type'), '#options' => $this->embedTypeManager->getDefinitionOptions(), '#default_value' => $button->getTypeId(), '#required' => TRUE, '#ajax' => ['callback' => '::updateTypeSettings', 'effect' => 'fade'], '#disabled' => !$button->isNew()];
if (count($form['type_id']['#options']) == 0) {
drupal_set_message($this->t('No embed types found.'), 'warning');
}
// Add the embed type plugin settings.
$form['type_settings'] = ['#type' => 'container', '#tree' => TRUE, '#prefix' => '<div id="embed-type-settings-wrapper">', '#suffix' => '</div>'];
try {
if ($plugin = $button->getTypePlugin()) {
$form['type_settings'] = $plugin->buildConfigurationForm($form['type_settings'], $form_state);
}
} catch (PluginNotFoundException $exception) {
drupal_set_message($exception->getMessage(), 'error');
watchdog_exception('embed', $exception);
$form['type_id']['#disabled'] = FALSE;
}
$config = $this->config('embed.settings');
$upload_location = $config->get('file_scheme') . '://' . $config->get('upload_directory') . '/';
$form['icon_file'] = ['#title' => $this->t('Button icon'), '#type' => 'managed_file', '#description' => $this->t('Icon for the button to be shown in CKEditor toolbar. Leave empty to use the default Entity icon.'), '#upload_location' => $upload_location, '#upload_validators' => ['file_validate_extensions' => ['gif png jpg jpeg'], 'file_validate_image_resolution' => ['32x32', '16x16']]];
if ($file = $button->getIconFile()) {
$form['icon_file']['#default_value'] = ['target_id' => $file->id()];
}
return $form;
}
示例9: import
/**
* Import the culturefeed domains.
*/
public function import()
{
$this->client = new Client($this::END_POINT);
try {
$body = $this->client->get('heading_categorisation.xml')->send()->getBody(TRUE);
$this->importHeadings(new SimpleXMLElement($body));
} catch (ClientErrorResponseException $e) {
watchdog_exception('culturefeed_cnapi_import', $e);
}
}
示例10: onRequest
/**
* Registers the autoloader.
*/
public function onRequest(GetResponseEvent $event)
{
try {
$this->registerAutoloader();
} catch (\RuntimeException $e) {
if (PHP_SAPI !== 'cli') {
watchdog_exception('search_api_solr', $e, NULL, array(), RfcLogLevel::WARNING);
}
}
}
示例11: sendRequest
/**
* Send the request to service.
*
* @param $identifiers
* Pass requested identifiers.
* @return mixed
* Response object or error message.
*/
protected function sendRequest($identifiers)
{
$authInfo = array('authenticationUser' => $this->username, 'authenticationGroup' => $this->group, 'authenticationPassword' => $this->password);
$client = new SoapClient($this->wsdlUrl);
try {
$response = $client->moreInfo(array('authentication' => $authInfo, 'identifier' => $identifiers));
} catch (Exception $e) {
watchdog_exception('artesis_netarchive', $e);
}
return $response;
}
示例12: fetchProjectData
/**
* {@inheritdoc}
*/
public function fetchProjectData(array $project, $site_key = '')
{
$url = $this->buildFetchUrl($project, $site_key);
$data = '';
try {
$data = $this->httpClient->get($url, array('headers' => array('Accept' => 'text/xml')))->getBody(TRUE);
} catch (RequestException $exception) {
watchdog_exception('update', $exception);
}
return $data;
}
示例13: getEmbedObject
/**
* {@inheritdoc}
*/
public function getEmbedObject($url)
{
$embed = NULL;
try {
$response = $this->httpClient->get($this->getEmbedProviderURL($url), array('headers' => array('content-type' => 'application/json')));
$embed = json_decode($response->getBody());
} catch (GuzzleClientException $e) {
watchdog_exception('ckeditor_media_embed', $e);
}
return $embed;
}
示例14: import
/**
* Import the culturefeed domains.
*/
public function import()
{
$this->client = new Client($this::END_POINT);
try {
// Cities.
$body = $this->client->get('city')->send()->getBody(TRUE);
$this->importCities(new SimpleXMLElement($body));
} catch (ClientErrorResponseException $e) {
watchdog_exception('culturefeed_city_import', $e);
}
}
示例15: isTitleInUse
/**
* @param string $title
*
* @return bool
*/
public static function isTitleInUse($title)
{
try {
return (bool) static::loadByTitle($title);
} catch (InvalidArgumentException $e) {
return FALSE;
} catch (NonUniqueResultException $e) {
watchdog_exception('b2b_import', $e);
return TRUE;
}
}