Skip to content
Snippets Groups Projects
Commit 02361714 authored by Jether Paradero's avatar Jether Paradero Committed by Morten Bartvig
Browse files

Issue #3363728 by Priya_Degwekar, paraderojether: Fix the issues reported by phpcs

parent a0f41123
No related branches found
No related tags found
No related merge requests found
......@@ -14,4 +14,3 @@ fieldset#edit-api .prepublish-is-error {
background-color: #f9c9bf;
padding: 5px 10px;
}
......@@ -2,7 +2,7 @@
* @file
* Styles for Siteimprove toolbar.
*/
.siteimprove-toolbar .siteimprove-link {
.siteimprove-toolbar .siteimprove-link {
padding-left: 3.25em;
position: relative;
}
......
......@@ -40,8 +40,8 @@
var _si = window._si || [];
var self = this;
this.urls.forEach(function (url) {
let document_ = document.cloneNode(true);
_si.push([self.method, self.cleanHtml(document_), url, drupalSettings.siteimprove.token, function() { console.log('Pre-publish check ordered (flat dom version'); }]);
let document_ = document.cloneNode(TRUE);
_si.push([self.method, self.cleanHtml(document_), url, drupalSettings.siteimprove.token, function () { console.log('Pre-publish check ordered (flat dom version'); }]);
});
},
onhighlight: function () {
......@@ -91,14 +91,14 @@
recheck: function () {
$('.siteimprove-recheck-button').click(function () {
siteimprove.recheck();
return false;
return FALSE;
});
},
contentcheck: function () {
$('.siteimprove-contentcheck-button').click(function () {
siteimprove.contentcheck();
siteimprove.onhighlight();
return false;
return FALSE;
});
}
}
......@@ -170,7 +170,7 @@
var sicmsplugin = cookies.get('sicmsplugin');
if (!sicmsplugin) {
let siOverlaySettings = drupalSettings?.siteimprove?.overlay_default_collapse ?? null;
let siOverlaySettings = drupalSettings?.siteimprove?.overlay_default_collapse ?? NULL;
if (siOverlaySettings) {
cookies.set('sicmsplugin', OVERLAY_COLLAPSED, {
domain: document.domain,
......
......@@ -42,7 +42,7 @@ function siteimprove_update_8101() {
*/
function siteimprove_update_8102() {
$settings = \Drupal::configFactory()->getEditable('siteimprove.settings');
$settings->set('prepublish_enabled', false);
$settings->set('prepublish_enabled', FALSE);
$settings->set('api_username', '');
$settings->set('api_key', '');
$settings->set('enabled_content_types', []);
......@@ -55,6 +55,6 @@ function siteimprove_update_8102() {
*/
function siteimprove_update_8103() {
$settings = \Drupal::configFactory()->getEditable('siteimprove.settings');
$settings->set('use_latest_experience', true);
$settings->set('use_latest_experience', TRUE);
$settings->save();
}
......@@ -8,6 +8,10 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
use Drupal\Component\Utility\NestedArray;
use Drupal\node\Entity\Node;
use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\group\Entity\Group;
/**
* Implements hook_toolbar().
......@@ -26,7 +30,7 @@ function siteimprove_toolbar() {
// Get entity from route parameter.
$node = \Drupal::routeMatch()->getParameter('node');
$taxonomy = \Drupal::routeMatch()->getParameter('taxonomy_term');
$entity = NULL;
$bundle = NULL;
$bundle_config_key = NULL;
......@@ -39,37 +43,37 @@ function siteimprove_toolbar() {
}
// Get bundle from either node.
if (is_object($node) && $node instanceof \Drupal\node\Entity\Node) {
if (is_object($node) && $node instanceof Node) {
$bundle = $node->bundle();
$entity = $node;
$bundle_config_key = 'enabled_content_types';
}
}
else if (!empty($taxonomy)) {
elseif (!empty($taxonomy)) {
// In the event that taxonomy parameter is not a term object.
if (is_string($taxonomy)) {
$taxonomy = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($taxonomy);
}
// Get bundle from either taxonomy.
if (is_object($taxonomy) && $taxonomy instanceof \Drupal\taxonomy\Entity\Term) {
if (is_object($taxonomy) && $taxonomy instanceof Term) {
$bundle = $taxonomy->bundle();
$entity = $taxonomy;
$bundle_config_key = 'enabled_taxonomies';
}
}
else if ($moduleHandler->moduleExists('group') && $group = \Drupal::routeMatch()->getParameter('group')) {
// In the event that group parameter is not a group object.
if (is_string($group)) {
$group = \Drupal::entityTypeManager()->getStorage('group')->load($group);
}
elseif ($moduleHandler->moduleExists('group') && $group = \Drupal::routeMatch()->getParameter('group')) {
// In the event that group parameter is not a group object.
if (is_string($group)) {
$group = \Drupal::entityTypeManager()->getStorage('group')->load($group);
}
// Get bundle from group object.
if (is_object($group) && $group instanceof \Drupal\group\Entity\Group) {
$bundle = $group->bundle();
$entity = $group;
$bundle_config_key = 'enabled_group_types';
}
// Get bundle from group object.
if (is_object($group) && $group instanceof Group) {
$bundle = $group->bundle();
$entity = $group;
$bundle_config_key = 'enabled_group_types';
}
}
// Check if prepublish is enabled on the bundle in request + get URLs.
......@@ -80,9 +84,7 @@ function siteimprove_toolbar() {
$urls = \Drupal::service('siteimprove.utils')->getEntityUrls($entity);
}
/**
* Prepublish toolbar item.
*/
// Prepublish toolbar item.
$prepublish_access = $user->hasPermission('use siteimprove prepublish');
$prepublish_available = FALSE;
$prepublish_enabled = $config->get('prepublish_enabled');
......@@ -94,14 +96,15 @@ function siteimprove_toolbar() {
'entity.group.canonical',
'entity.group.latest_version',
'entity.group.edit_form',
'entity.group_relationship.canonical'
'entity.group_relationship.canonical',
];
$current_route_name = \Drupal::routeMatch()->getRouteName();
// Set overlay collapse value for js.
$toolbar_items = [];
$toolbar_items['siteimprove_toolbar']['tray']['#attached']['drupalSettings']['siteimprove']['overlay_default_collapse'] = $config->get('overlay_default_collapse');
// Prepublish should be available for an enabled taxonomy, content type or group type.
// Prepublish should be available for an enabled taxonomy, content type or
// group type.
if ($prepublish_enabled && in_array($current_route_name, $enabled_route_names) && $bundle_with_prepublish) {
$prepublish_available = TRUE;
}
......@@ -121,9 +124,7 @@ function siteimprove_toolbar() {
];
}
/**
* Recheck toolbar item.
*/
// Recheck toolbar item.
$recheck_access = $user->hasPermission('use siteimprove');
$enabled_route_names = [
'entity.node.canonical',
......@@ -132,7 +133,7 @@ function siteimprove_toolbar() {
'entity.taxonomy_term.edit_form',
'entity.group.canonical',
'entity.group.edit_form',
'entity.group_relationship.canonical'
'entity.group_relationship.canonical',
];
$current_route_name = \Drupal::routeMatch()->getRouteName();
......@@ -151,9 +152,7 @@ function siteimprove_toolbar() {
$toolbar_items['siteimprove_toolbar']['tray']['#attached']['drupalSettings']['siteimprove']['recheck'] = \Drupal::service('siteimprove.utils')->getSiteimproveSettings($urls, 'recheck', FALSE);
}
/**
* Settings page toolbar item.
*/
// Settings page toolbar item.
if ($user->hasPermission('administer siteimprove')) {
$toolbar_items['siteimprove_toolbar']['tray']['actions']['#items']['settings'] = [
'#type' => 'link',
......@@ -173,7 +172,7 @@ function siteimprove_toolbar() {
}
// Current entity or null.
$current_entity = $node ? $node : ($taxonomy ? $taxonomy : null);
$current_entity = $node ? $node : ($taxonomy ? $taxonomy : NULL);
// Add current viewed entity as cacheable dependency.
$renderer = \Drupal::service('renderer');
......@@ -187,6 +186,7 @@ function siteimprove_toolbar() {
* Basic toolbar array.
*
* @return array[]
* An array representing the basic toolbar.
*/
function _siteimprove_toolbar_basic() {
return [
......@@ -206,7 +206,7 @@ function _siteimprove_toolbar_basic() {
'#url' => Url::fromUserInput('#'),
'#attributes' => [
'class' => ['siteimprove-link'],
]
],
],
'#wrapper_attributes' => [
'class' => ['siteimprove-toolbar'],
......@@ -220,10 +220,8 @@ function _siteimprove_toolbar_basic() {
'class' => ['toolbar-menu'],
],
],
'urls' => [
],
'empty' => [
]
'urls' => [],
'empty' => [],
],
],
];
......@@ -283,7 +281,8 @@ function siteimprove_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = $siteimprove->getSiteimproveOverlayLibrary($use_latest_experience);
$attachments['#attached']['library'][] = $siteimprove->getSiteimproveLibrary();
// If node pages or taxonomy term pages, add input method, else domain method.
// If node pages or taxonomy term pages, add input method, else domain
// method.
$enabled_route_names = [
'entity.node.canonical',
'entity.node.latest_version',
......@@ -294,7 +293,7 @@ function siteimprove_page_attachments(array &$attachments) {
'entity.group.canonical',
'entity.group.latest_version',
'entity.group.edit_form',
'entity.group_relationship.canonical'
'entity.group_relationship.canonical',
];
$route_match = \Drupal::routeMatch();
$current_route_name = $route_match->getRouteName();
......@@ -309,11 +308,11 @@ function siteimprove_page_attachments(array &$attachments) {
$bundle = '';
$parameters = $route_match->getParameters();
foreach ($parameters as $parameter) {
if (is_object($parameter) && $parameter instanceof \Drupal\node\Entity\Node) {
if (is_object($parameter) && $parameter instanceof Node) {
$type = 'enabled_content_types';
$bundle = $parameter->bundle();
}
elseif (is_object($parameter) && $parameter instanceof \Drupal\taxonomy\Entity\Term) {
elseif (is_object($parameter) && $parameter instanceof Term) {
$type = 'enabled_taxonomies';
$bundle = $parameter->bundle();
}
......@@ -326,7 +325,7 @@ function siteimprove_page_attachments(array &$attachments) {
if (!empty($method)) {
$parameters = \Drupal::routeMatch()->getParameters();
foreach ($parameters as $param) {
if (is_object($param) && $param instanceof \Drupal\Core\Entity\ContentEntityInterface) {
if (is_object($param) && $param instanceof ContentEntityInterface) {
if ($param->in_preview !== TRUE) {
/** @var \Drupal\Core\Entity\ContentEntityType $type */
$entity_type = $param->getEntityType()->id();
......
......@@ -17,7 +17,7 @@ function siteimprove_domain_access_help($route_name, RouteMatchInterface $route_
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Add a integration between Siteimprove module and Domain Access. For now only a Siteimprove Domain plugin automatically using the Domain Access domains as frontend domains.') . '</p>';
$output .= '<p><a href="https://www.drupal.org/docs/contributed-modules/siteimprove" target="_blank" title="Siteimprove module documentation guide on Drupal.org">' . t('Find more help in the documentation guide on drupal.org') . '.</a></p>';
$output .= '<p>' . t('Find more help in the @documentation_guide.', ['@documentation_guide' => '<a href="https://www.drupal.org/docs/contributed-modules/siteimprove" target="_blank" title="Siteimprove module documentation guide on Drupal.org">documentation guide on drupal.org</a>']) . '</p>';
return $output;
default:
......
......@@ -60,7 +60,7 @@ class SettingsForm extends ConfigFormBase {
/**
* The module handler.
*
*
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
......@@ -72,7 +72,6 @@ class SettingsForm extends ConfigFormBase {
*/
protected $groupTypeStorage;
/**
* {@inheritdoc}
*/
......@@ -411,7 +410,7 @@ class SettingsForm extends ConfigFormBase {
*/
protected function setRepublish($username, $key) {
$url = 'https://api.siteimprove.com/v2/settings/content_checking';
$res = $this->httpClient->request('POST', $url, [
$this->httpClient->request('POST', $url, [
'auth' => [$username, $key],
'headers' => [
'Accept' => 'application/json',
......
......@@ -147,8 +147,9 @@ class SiteimproveUtils {
/**
* Return Siteimprove js library.
*
* @param $use_latest_experience
* @param bool $use_latest_experience
* Use latest version of overlay when set to true.
*
* @return string
* Siteimprove js library.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment