Commit bb0fbae5 authored by gbyte.co's avatar gbyte.co

Clean up

parent cc325973
...@@ -41,7 +41,7 @@ class EntityHelper { ...@@ -41,7 +41,7 @@ class EntityHelper {
* @return string * @return string
*/ */
public function getEntityInstanceBundleName(EntityInterface $entity) { public function getEntityInstanceBundleName(EntityInterface $entity) {
return $entity->getEntityTypeId() == 'menu_link_content' return $entity->getEntityTypeId() === 'menu_link_content'
// Menu fix. // Menu fix.
? $entity->getMenuName() : $entity->bundle(); ? $entity->getMenuName() : $entity->bundle();
} }
...@@ -53,7 +53,7 @@ class EntityHelper { ...@@ -53,7 +53,7 @@ class EntityHelper {
* @return null|string * @return null|string
*/ */
public function getBundleEntityTypeId(EntityInterface $entity) { public function getBundleEntityTypeId(EntityInterface $entity) {
return $entity->getEntityTypeId() == 'menu' return $entity->getEntityTypeId() === 'menu'
// Menu fix. // Menu fix.
? 'menu_link_content' : $entity->getEntityType()->getBundleOf(); ? 'menu_link_content' : $entity->getEntityType()->getBundleOf();
} }
...@@ -84,20 +84,19 @@ class EntityHelper { ...@@ -84,20 +84,19 @@ class EntityHelper {
* @return bool * @return bool
*/ */
public function entityTypeIsAtomic($entity_type_id) { public function entityTypeIsAtomic($entity_type_id) {
// Menu fix. // Menu fix.
if ($entity_type_id == 'menu_link_content') { if ($entity_type_id === 'menu_link_content') {
return FALSE; return FALSE;
} }
$sitemap_entity_types = $this->getSupportedEntityTypes(); $entity_types = $this->entityTypeManager->getDefinitions();
if (isset($sitemap_entity_types[$entity_type_id])) {
$entity_type = $sitemap_entity_types[$entity_type_id]; if (!isset($entity_types[$entity_type_id])) {
if (empty($entity_type->getBundleEntityType())) { // todo: Throw exception.
return TRUE;
}
} }
// todo: throw exception.
return FALSE; return empty($entity_types[$entity_type_id]->getBundleEntityType()) ? TRUE : FALSE;
} }
/** /**
......
...@@ -197,7 +197,7 @@ class FormHelper { ...@@ -197,7 +197,7 @@ class FormHelper {
// Do not alter the form, if sitemap is disabled for the entity type of this // Do not alter the form, if sitemap is disabled for the entity type of this
// entity instance. // entity instance.
elseif ($this->getEntityCategory() == 'instance' elseif ($this->getEntityCategory() === 'instance'
&& !$this->generator->bundleIsIndexed($this->getEntityTypeId(), $this->getBundleName())) { && !$this->generator->bundleIsIndexed($this->getEntityTypeId(), $this->getBundleName())) {
return FALSE; return FALSE;
} }
...@@ -317,7 +317,7 @@ class FormHelper { ...@@ -317,7 +317,7 @@ class FormHelper {
* TRUE if this is a bundle or bundle instance form, FALSE otherwise. * TRUE if this is a bundle or bundle instance form, FALSE otherwise.
*/ */
protected function getEntityDataFromFormEntity() { protected function getEntityDataFromFormEntity() {
if (FALSE === $form_entity = $this->getFormEntity()) { if (!$form_entity = $this->getFormEntity()) {
return FALSE; return FALSE;
} }
...@@ -339,7 +339,7 @@ class FormHelper { ...@@ -339,7 +339,7 @@ class FormHelper {
} }
// Menu fix. // Menu fix.
$this->setEntityCategory(NULL === $this->getEntityCategory() && $entity_type_id == 'menu' ? 'bundle' : $this->getEntityCategory()); $this->setEntityCategory(NULL === $this->getEntityCategory() && $entity_type_id === 'menu' ? 'bundle' : $this->getEntityCategory());
switch ($this->getEntityCategory()) { switch ($this->getEntityCategory()) {
case 'bundle': case 'bundle':
......
...@@ -71,7 +71,7 @@ class SimplesitemapCustomLinksForm extends SimplesitemapFormBase { ...@@ -71,7 +71,7 @@ class SimplesitemapCustomLinksForm extends SimplesitemapFormBase {
} }
// Making sure the paths start with a slash. // Making sure the paths start with a slash.
if ($link_config['path'][0] != '/') { if ($link_config['path'][0] !== '/') {
$form_state->setErrorByName('', $this->t("<strong>Line @line</strong>: The path <em>@path</em> needs to start with a '/'.", $placeholders)); $form_state->setErrorByName('', $this->t("<strong>Line @line</strong>: The path <em>@path</em> needs to start with a '/'.", $placeholders));
} }
......
...@@ -88,7 +88,7 @@ class SimplesitemapEntitiesForm extends SimplesitemapFormBase { ...@@ -88,7 +88,7 @@ class SimplesitemapEntitiesForm extends SimplesitemapFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues(); $values = $form_state->getValues();
foreach ($values as $field_name => $value) { foreach ($values as $field_name => $value) {
if (substr($field_name, -strlen('_enabled')) == '_enabled') { if (substr($field_name, -strlen('_enabled')) === '_enabled') {
$entity_type_id = substr($field_name, 0, -8); $entity_type_id = substr($field_name, 0, -8);
if ($value) { if ($value) {
$this->generator->enableEntityType($entity_type_id); $this->generator->enableEntityType($entity_type_id);
......
...@@ -154,7 +154,7 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase { ...@@ -154,7 +154,7 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
public function validateForm(array &$form, FormStateInterface $form_state) { public function validateForm(array &$form, FormStateInterface $form_state) {
$base_url = $form_state->getValue('base_url'); $base_url = $form_state->getValue('base_url');
$form_state->setValue('base_url', rtrim($base_url, '/')); $form_state->setValue('base_url', rtrim($base_url, '/'));
if ($base_url != '' && !UrlHelper::isValid($base_url, TRUE)) { if ($base_url !== '' && !UrlHelper::isValid($base_url, TRUE)) {
$form_state->setErrorByName('base_url', t('The base URL is invalid.')); $form_state->setErrorByName('base_url', t('The base URL is invalid.'));
} }
} }
......
...@@ -25,7 +25,7 @@ class EntityUrlGenerator extends UrlGeneratorBase { ...@@ -25,7 +25,7 @@ class EntityUrlGenerator extends UrlGeneratorBase {
$keys = $sitemap_entity_types[$entity_type_name]->getKeys(); $keys = $sitemap_entity_types[$entity_type_name]->getKeys();
// Menu fix. // Menu fix.
$keys['bundle'] = $entity_type_name == 'menu_link_content' ? 'menu_name' : $keys['bundle']; $keys['bundle'] = $entity_type_name === 'menu_link_content' ? 'menu_name' : $keys['bundle'];
foreach ($bundles as $bundle_name => $bundle_settings) { foreach ($bundles as $bundle_name => $bundle_settings) {
if ($bundle_settings['index']) { if ($bundle_settings['index']) {
......
...@@ -155,7 +155,7 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe ...@@ -155,7 +155,7 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
* @return bool * @return bool
*/ */
protected function isBatch() { protected function isBatch() {
return $this->batchSettings['from'] != 'nobatch'; return $this->batchSettings['from'] !== 'nobatch';
} }
protected function getProcessedElements() { protected function getProcessedElements() {
......
...@@ -392,7 +392,7 @@ class Simplesitemap { ...@@ -392,7 +392,7 @@ class Simplesitemap {
$keys = $entity_type->getKeys(); $keys = $entity_type->getKeys();
// Menu fix. // Menu fix.
$keys['bundle'] = $entity_type_id == 'menu_link_content' ? 'menu_name' : $keys['bundle']; $keys['bundle'] = $entity_type_id === 'menu_link_content' ? 'menu_name' : $keys['bundle'];
$query = $this->entityTypeManager->getStorage($entity_type_id)->getQuery(); $query = $this->entityTypeManager->getStorage($entity_type_id)->getQuery();
if (!$this->entityHelper->entityTypeIsAtomic($entity_type_id)) { if (!$this->entityHelper->entityTypeIsAtomic($entity_type_id)) {
...@@ -622,7 +622,7 @@ class Simplesitemap { ...@@ -622,7 +622,7 @@ class Simplesitemap {
// todo: log error. // todo: log error.
return $this; return $this;
} }
if ($path[0] != '/') { if ($path[0] !== '/') {
// todo: log error. // todo: log error.
return $this; return $this;
} }
......
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