Commit d0a6f668 authored by Kingdutch's avatar Kingdutch

Fix coding standards

parent a44d9852
......@@ -51,10 +51,11 @@
String.prototype.endsWith = function (searchStr, Position) {
// This works much better than >= because
// it compensates for NaN:
if (!(Position < this.length))
if (!(Position < this.length)) {
Position = this.length;
else
Position |= 0; // round position
} else {
Position | = 0; // round position
}
return this.substr(Position - searchStr.length,
searchStr.length) === searchStr;
};
......@@ -74,7 +75,6 @@
}
}
if (typeof RealTimeSEO === 'undefined') {
$('#' + config.targets.output).html('<p><strong>' + Drupal.t('It looks like something went wrong when we tried to load the Real-Time SEO content analysis library. Please check it the module is installed correctly.') + '</strong></p>');
throw 'RealTimeSEO is not defined. Is the library attached?';
......@@ -224,7 +224,6 @@
this.app.runAnalyzer();
};
/**
* Sends a request to our Drupal endpoint to refresh our local data.
*
......
......@@ -34,7 +34,7 @@ class SettingsController extends ControllerBase {
}
elseif ($xmlsitemap_enabled) {
// Inform the user about altering the XML Sitemap configuration on the
// module configuration page if he has access to do so.
// module configuration page if they have access to do so.
if (\Drupal::currentUser()->hasPermission('administer xmlsitemap')) {
$xmlsitemap_description = $this->t(
'You can configure the XML Sitemap settings at the @url.',
......@@ -53,7 +53,7 @@ class SettingsController extends ControllerBase {
}
elseif (\Drupal::moduleHandler()->moduleExists('simple_sitemap')) {
// Inform the user about altering the XML Sitemap configuration on the
// module configuration page if he has access to do so.
// module configuration page if they have access to do so.
if (\Drupal::currentUser()->hasPermission('administer simple_sitemap')) {
$xmlsitemap_description = $this->t(
'You can configure the Simple XML Sitemap settings at the @url.',
......@@ -71,7 +71,7 @@ class SettingsController extends ControllerBase {
}
}
else {
// XML Sitemap is not enabled, inform the user he should think about
// XML Sitemap is not enabled, inform the user they should think about
// installing and enabling it.
$xmlsitemap_description = $this->t(
'You currently do not have a sitemap module enabled. We strongly recommend you to install a sitemap module. You can download the <a href="@project1-url">@project1-name</a> or <a href="@project2-url">@project2-name</a> module to use as sitemap generator.',
......@@ -92,7 +92,7 @@ class SettingsController extends ControllerBase {
];
// Inform the user about altering the Metatag configuration on the module
// configuration page if he has access to do so.
// configuration page if they have access to do so.
// We do not check if the module is enabled since it is our dependency.
if (\Drupal::currentUser()->hasPermission('administer meta tags')) {
$metatag_description = $this->t(
......
......@@ -9,7 +9,18 @@ use Drupal\Core\Entity\EntityInterface;
*/
class EntityPagePreview implements EntityPreviewInterface {
/**
* The entity being previewed.
*
* @var \Drupal\Core\Entity\EntityInterface
*/
protected $entity;
/**
* The language the preview is in.
*
* @var \Drupal\Core\Language\LanguageInterface
*/
protected $language;
/**
......
......@@ -139,7 +139,7 @@ class EntityAnalyser {
public function renderEntity(EntityInterface $entity) {
$type = $entity->getEntityTypeId();
$view_builder = $this->entityTypeManager->getViewBuilder($type);
// TODO: Make the view mode configurable in Yoast SEO settings.
// @todo Make the view mode configurable in Yoast SEO settings.
$render_array = $view_builder->view($entity, 'full');
return $this->renderer->renderRoot($render_array);
}
......@@ -154,7 +154,7 @@ class EntityAnalyser {
* @param array $metatags
* The metatags array that contains the tokens.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to use as context
* The entity to use as context.
*/
protected function replaceContextAwareTokens(array &$metatags, EntityInterface $entity) {
foreach ($metatags as $tag => $value) {
......
......@@ -27,7 +27,7 @@ class YoastSeoFormatter extends FormatterBase {
foreach ($items as $delta => $item) {
$status = $yoast_seo_manager->getScoreStatus($item->status);
// TODO : find a way to give a weight, so the column doesn't appear
// @todo find a way to give a weight, so the column doesn't appear
// at the end.
// Get template for the snippet.
$overall_score_tpl = [
......
......@@ -173,8 +173,8 @@ class YoastSeoWidget extends WidgetBase implements ContainerFactoryPluginInterfa
*/
public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
foreach ($values as &$value) {
$value['title'] = ($this->getSetting('edit_title') ? $value['edit_title'] : null);
$value['description'] = ($this->getSetting('edit_description') ? $value['edit_description'] : null);
$value['title'] = ($this->getSetting('edit_title') ? $value['edit_title'] : NULL);
$value['description'] = ($this->getSetting('edit_description') ? $value['edit_description'] : NULL);
}
return $values;
}
......@@ -239,8 +239,8 @@ class YoastSeoWidget extends WidgetBase implements ContainerFactoryPluginInterfa
global $base_root;
$score_rules = $this->seoManager->getScoreRules();
// TODO: Use dependency injection for language manager.
// TODO: Translate to something usable by YoastSEO.js.
// @todo Use dependency injection for language manager.
// @todo Translate to something usable by YoastSEO.js.
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$configuration = [
......
......@@ -10,7 +10,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
* Class SeoManager.
* Utility service for the Real-Time SEO module.
*
* @package Drupal\yoast_seo
*/
......@@ -48,6 +48,8 @@ class SeoManager {
* Entity Type Bundle Info service.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager
* Entity Field Manager service.
* @param \Drupal\Core\StringTranslation\TranslationInterface $stringTranslation
* The string traslation service.
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager, EntityTypeBundleInfoInterface $entityTypeBundleInfo, EntityFieldManagerInterface $entityFieldManager, TranslationInterface $stringTranslation) {
$this->entityTypeBundleInfo = $entityTypeBundleInfo;
......@@ -99,7 +101,7 @@ class SeoManager {
* @param \Drupal\Core\Entity\FieldableEntityInterface $entity
* The entity for which to find the Real-Time SEO field.
*
* @return NULL|\Drupal\Core\Field\FieldItemListInterface
* @return null|\Drupal\Core\Field\FieldItemListInterface
* The field item list of the field or NULL if no RTSEO field was found.
*/
public function getSeoField(FieldableEntityInterface $entity) {
......@@ -120,7 +122,7 @@ class SeoManager {
/**
* Get the status for a given score.
*
* TODO: Move this back to something like an SEO Assessor.
* @todo Move this back to something like an SEO Assessor.
*
* @param int $score
* Score in points.
......@@ -144,7 +146,7 @@ class SeoManager {
/**
* Retrieves the score rules from configuration.
*
* @return string[] rules
* @return string[]
* A list of labels indexed by the minimum score required. Ordered from high
* to low.
*/
......@@ -153,6 +155,7 @@ class SeoManager {
// Ensure rules are sorted from high to low score.
ksort($rules);
return array_reverse($rules, true);
return array_reverse($rules, TRUE);
}
}
......@@ -15,3 +15,4 @@ dependencies:
test_dependencies:
- drupal:node
- paragraphs:paragraphs
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