protected function FormHelper::getEntityDataFromFormEntity in Simple XML sitemap 8.3
Same name and namespace in other branches
- 8.2 src/Form/FormHelper.php \Drupal\simple_sitemap\Form\FormHelper::getEntityDataFromFormEntity()
- 4.x src/Form/FormHelper.php \Drupal\simple_sitemap\Form\FormHelper::getEntityDataFromFormEntity()
Checks if this particular form is a bundle form, or a bundle instance form and gathers sitemap settings from the database.
Return value
bool TRUE if this is a bundle or bundle instance form, FALSE otherwise.
1 call to FormHelper::getEntityDataFromFormEntity()
- FormHelper::processForm in src/
Form/ FormHelper.php
File
- src/
Form/ FormHelper.php, line 385
Class
- FormHelper
- Class FormHelper @package Drupal\simple_sitemap\Form
Namespace
Drupal\simple_sitemap\FormCode
protected function getEntityDataFromFormEntity() {
if (!($form_entity = $this
->getFormEntity())) {
return FALSE;
}
$entity_type_id = $form_entity
->getEntityTypeId();
$sitemap_entity_types = $this->entityHelper
->getSupportedEntityTypes();
if (isset($sitemap_entity_types[$entity_type_id])) {
$this
->setEntityCategory('instance');
}
else {
/** @var \Drupal\Core\Entity\EntityType $sitemap_entity_type */
foreach ($sitemap_entity_types as $sitemap_entity_type) {
if ($sitemap_entity_type
->getBundleEntityType() === $entity_type_id) {
$this
->setEntityCategory('bundle');
break;
}
}
}
// Menu fix.
$this
->setEntityCategory(NULL === $this
->getEntityCategory() && $entity_type_id === 'menu' ? 'bundle' : $this
->getEntityCategory());
switch ($this
->getEntityCategory()) {
case 'bundle':
$this
->setEntityTypeId($this->entityHelper
->getBundleEntityTypeId($form_entity));
$this
->setBundleName($form_entity
->id());
$this
->setInstanceId(NULL);
break;
case 'instance':
$this
->setEntityTypeId($entity_type_id);
$this
->setBundleName($this->entityHelper
->getEntityInstanceBundleName($form_entity));
// New menu link's id is '' instead of NULL, hence checking for empty.
$this
->setInstanceId(!$this
->entityIsNew() ? $form_entity
->id() : NULL);
break;
default:
return FALSE;
}
return TRUE;
}