Commit 6a0932d0 authored by RenatoG's avatar RenatoG Committed by RenatoG

Issue #2908245 by RenatoG: Fix Drupal Coding Standards and Best Practices for root default

parent 97a669c9
......@@ -62,10 +62,13 @@ function hook_xmlsitemap_link_info() {
/**
* Alter the data of a sitemap link before the link is saved.
*
* @param $link
* @param array $link
* An array with the data of the sitemap link.
*
* @codingStandardsIgnoreStart
*/
function hook_xmlsitemap_link_alter(&$link) {
// @codingStandardsIgnoreEnd
if ($link['type'] == 'mymodule') {
$link['priority'] += 0.5;
}
......@@ -74,7 +77,7 @@ function hook_xmlsitemap_link_alter(&$link) {
/**
* Inform modules that an XML sitemap link has been created.
*
* @param $link
* @param array $link
* Associative array defining an XML sitemap link as passed into
* \Drupal\xmlsitemap\XmlSitemapLinkStorageInterface::save().
*
......@@ -93,7 +96,7 @@ function hook_xmlsitemap_link_insert(array $link) {
/**
* Inform modules that an XML sitemap link has been updated.
*
* @param $link
* @param array $link
* Associative array defining an XML sitemap link as passed into
* \Drupal\xmlsitemap\XmlSitemapLinkStorageInterface::save().
*
......@@ -181,7 +184,7 @@ function hook_xmlsitemap_context_url_options_alter(array &$options, array $conte
/**
* Alter the query selecting data from {xmlsitemap} during sitemap generation.
*
* @param $query
* @param QueryAlterableInterface $query
* A Query object describing the composite parts of a SQL query.
*
* @see hook_query_TAG_alter()
......@@ -214,7 +217,7 @@ function hook_xmlsitemap_sitemap_operations() {
* This hook is invoked from xmlsitemap_sitemap_delete_multiple() after the XML
* sitemap has been removed from the table in the database.
*
* @param $sitemap
* @param Drupal\xmlsitemap\XmlSitemapInterface $sitemap
* The XML sitemap object that was deleted.
*/
function hook_xmlsitemap_sitemap_delete(XmlSitemapInterface $sitemap) {
......
......@@ -123,7 +123,10 @@ function xmlsitemap_requirements($phase) {
$generated_ago = REQUEST_TIME - $generated_last;
$requirements['xmlsitemap_generated'] = [
'title' => $t('XML sitemap'),
'value' => $generated_last ? $t('Last attempted generation on @date (@interval ago).', ['@date' => format_date($generated_last, 'small'), '@interval' => \Drupal::service('date.formatter')->formatInterval($generated_ago)]) : $t('Cached files have not been generated yet.'),
'value' => $generated_last ? $t('Last attempted generation on @date (@interval ago).', [
'@date' => format_date($generated_last, 'small'),
'@interval' => \Drupal::service('date.formatter')->formatInterval($generated_ago),
]) : $t('Cached files have not been generated yet.'),
'severity' => REQUIREMENT_OK,
];
if (\Drupal::state()->get('xmlsitemap_rebuild_needed')) {
......@@ -142,7 +145,9 @@ function xmlsitemap_requirements($phase) {
$requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_WARNING;
}
if ($requirements['xmlsitemap_generated']['severity']) {
$requirements['xmlsitemap_generated']['description'] = $t('The XML cached files are out of date and need to be regenerated. You can <a href="@link-cron">run cron manually</a> to regenerate the sitemap files.', ['@link-cron' => Url::fromRoute('system.run_cron', [], ['query' => drupal_get_destination()])->toString()]);
$requirements['xmlsitemap_generated']['description'] = $t('The XML cached files are out of date and need to be regenerated. You can <a href="@link-cron">run cron manually</a> to regenerate the sitemap files.', [
'@link-cron' => Url::fromRoute('system.run_cron', [], ['query' => drupal_get_destination()])->toString(),
]);
}
}
$anonymous_accout = new AnonymousUserSession();
......@@ -151,7 +156,9 @@ function xmlsitemap_requirements($phase) {
$requirements['xmlsitemap_user_anonymous_permission'] = [
'title' => $t('XML sitemap user'),
'value' => $t('Anonymous access to user profiles'),
'description' => $t('In order to list user profile links in the sitemap, the anonymous user must have the <a href="@perm-link"><em>View user profiles</em> permission</a>.', ['@perm-link' => Url::fromRoute('entity.user_role.edit_permissions_form', ['user_role' => DRUPAL_ANONYMOUS_RID], ['fragment' => 'module-user'])->toString()]),
'description' => $t('In order to list user profile links in the sitemap, the anonymous user must have the <a href="@perm-link"><em>View user profiles</em> permission</a>.', [
'@perm-link' => Url::fromRoute('entity.user_role.edit_permissions_form', ['user_role' => DRUPAL_ANONYMOUS_RID], ['fragment' => 'module-user'])->toString(),
]),
'severity' => REQUIREMENT_ERROR,
];
}
......@@ -346,7 +353,11 @@ function xmlsitemap_uninstall() {
*/
function xmlsitemap_update_8001() {
\Drupal::database()->schema()->dropPrimaryKey('xmlsitemap');
\Drupal::database()->schema()->addPrimaryKey('xmlsitemap', ['id', 'type', 'language']);
\Drupal::database()->schema()->addPrimaryKey('xmlsitemap', [
'id',
'type',
'language',
]);
\Drupal::database()->schema()->dropIndex('xmlsitemap', 'language');
}
......
This diff is collapsed.
......@@ -92,7 +92,19 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
'#default_value' => $this->config('xmlsitemap_engines.settings')->get('engines'),
'#options' => $engine_options,
];
$lifetimes = [3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 604800 * 2, 604800 * 4];
$lifetimes = [
3600,
10800,
21600,
32400,
43200,
86400,
172800,
259200,
604800,
604800 * 2,
604800 * 4,
];
$lifetimes = array_combine($lifetimes, $lifetimes);
$format_lifetimes = [];
foreach ($lifetimes as $value) {
......@@ -112,7 +124,10 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
$form['custom_urls'] = [
'#type' => 'textarea',
'#title' => $this->t('Custom submission URLs'),
'#description' => $this->t('Enter one URL per line. The token [sitemap] will be replaced with the URL to your sitemap. For example: %example-before would become %example-after.', ['%example-before' => 'http://example.com/ping?[sitemap]', '%example-after' => xmlsitemap_engines_prepare_url('http://example.com/ping?[sitemap]', Url::fromRoute('xmlsitemap.sitemap_xml', [], ['absolute' => TRUE])->toString())]),
'#description' => $this->t('Enter one URL per line. The token [sitemap] will be replaced with the URL to your sitemap. For example: %example-before would become %example-after.', [
'%example-before' => 'http://example.com/ping?[sitemap]',
'%example-after' => xmlsitemap_engines_prepare_url('http://example.com/ping?[sitemap]', Url::fromRoute('xmlsitemap.sitemap_xml', [], ['absolute' => TRUE])->toString()),
]),
'#default_value' => $this->config('xmlsitemap_engines.settings')->get('custom_urls'),
'#rows' => 2,
'#wysiwyg' => FALSE,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment