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

Clean up

parent cc325973
......@@ -41,7 +41,7 @@ class EntityHelper {
* @return string
*/
public function getEntityInstanceBundleName(EntityInterface $entity) {
return $entity->getEntityTypeId() == 'menu_link_content'
return $entity->getEntityTypeId() === 'menu_link_content'
// Menu fix.
? $entity->getMenuName() : $entity->bundle();
}
......@@ -53,7 +53,7 @@ class EntityHelper {
* @return null|string
*/
public function getBundleEntityTypeId(EntityInterface $entity) {
return $entity->getEntityTypeId() == 'menu'
return $entity->getEntityTypeId() === 'menu'
// Menu fix.
? 'menu_link_content' : $entity->getEntityType()->getBundleOf();
}
......@@ -84,20 +84,19 @@ class EntityHelper {
* @return bool
*/
public function entityTypeIsAtomic($entity_type_id) {
// Menu fix.
if ($entity_type_id == 'menu_link_content') {
if ($entity_type_id === 'menu_link_content') {
return FALSE;
}
$sitemap_entity_types = $this->getSupportedEntityTypes();
if (isset($sitemap_entity_types[$entity_type_id])) {
$entity_type = $sitemap_entity_types[$entity_type_id];
if (empty($entity_type->getBundleEntityType())) {
return TRUE;
}
$entity_types = $this->entityTypeManager->getDefinitions();
if (!isset($entity_types[$entity_type_id])) {
// todo: Throw exception.
}
// todo: throw exception.
return FALSE;
return empty($entity_types[$entity_type_id]->getBundleEntityType()) ? TRUE : FALSE;
}
/**
......
......@@ -197,7 +197,7 @@ class FormHelper {
// Do not alter the form, if sitemap is disabled for the entity type of this
// entity instance.
elseif ($this->getEntityCategory() == 'instance'
elseif ($this->getEntityCategory() === 'instance'
&& !$this->generator->bundleIsIndexed($this->getEntityTypeId(), $this->getBundleName())) {
return FALSE;
}
......@@ -317,7 +317,7 @@ class FormHelper {
* TRUE if this is a bundle or bundle instance form, FALSE otherwise.
*/
protected function getEntityDataFromFormEntity() {
if (FALSE === $form_entity = $this->getFormEntity()) {
if (!$form_entity = $this->getFormEntity()) {
return FALSE;
}
......@@ -339,7 +339,7 @@ class FormHelper {
}
// 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()) {
case 'bundle':
......
......@@ -71,7 +71,7 @@ class SimplesitemapCustomLinksForm extends SimplesitemapFormBase {
}
// 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));
}
......
......@@ -88,7 +88,7 @@ class SimplesitemapEntitiesForm extends SimplesitemapFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
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);
if ($value) {
$this->generator->enableEntityType($entity_type_id);
......
......@@ -154,7 +154,7 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
public function validateForm(array &$form, FormStateInterface $form_state) {
$base_url = $form_state->getValue('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.'));
}
}
......
......@@ -25,7 +25,7 @@ class EntityUrlGenerator extends UrlGeneratorBase {
$keys = $sitemap_entity_types[$entity_type_name]->getKeys();
// 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) {
if ($bundle_settings['index']) {
......
......@@ -155,7 +155,7 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
* @return bool
*/
protected function isBatch() {
return $this->batchSettings['from'] != 'nobatch';
return $this->batchSettings['from'] !== 'nobatch';
}
protected function getProcessedElements() {
......
......@@ -392,7 +392,7 @@ class Simplesitemap {
$keys = $entity_type->getKeys();
// 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();
if (!$this->entityHelper->entityTypeIsAtomic($entity_type_id)) {
......@@ -622,7 +622,7 @@ class Simplesitemap {
// todo: log error.
return $this;
}
if ($path[0] != '/') {
if ($path[0] !== '/') {
// todo: log error.
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