Mapping.php in GatherContent 8.5
File
src/Entity/Mapping.php
View source
<?php
namespace Drupal\gathercontent\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class Mapping extends ConfigEntityBase implements MappingInterface {
use StringTranslationTrait;
protected $id;
protected $gathercontent_project_id;
protected $gathercontent_project;
protected $gathercontent_template_id;
protected $gathercontent_template;
protected $entity_type;
protected $content_type;
protected $content_type_name;
protected $updated_drupal;
protected $data;
protected $template;
public function getGathercontentTemplateId() {
return $this
->get('gathercontent_template_id');
}
public function setGathercontentTemplateId($gathercontent_template_id) {
$this->gathercontent_template_id = $gathercontent_template_id;
}
public function getGathercontentProjectId() {
return $this
->get('gathercontent_project_id');
}
public function setGathercontentProjectId($gathercontent_project_id) {
$this->gathercontent_project_id = $gathercontent_project_id;
}
public function getGathercontentProject() {
return $this
->get('gathercontent_project');
}
public function setGathercontentProject($gathercontent_project) {
$this->gathercontent_project = $gathercontent_project;
}
public function getGathercontentTemplate() {
return $this
->get('gathercontent_template');
}
public function setGathercontentTemplate($gathercontent_template) {
$this->gathercontent_template = $gathercontent_template;
}
public function getMappedEntityType() {
return $this
->get('entity_type');
}
public function setMappedEntityType($entity_type) {
$this->entity_type = $entity_type;
}
public function getContentType() {
return $this
->get('content_type');
}
public function setContentType($content_type) {
$this->content_type = $content_type;
}
public function getContentTypeName() {
return $this
->get('content_type_name');
}
public function setContentTypeName($content_type_name) {
$this->content_type_name = $content_type_name;
}
public function getUpdatedDrupal() {
return $this
->get('updated_drupal');
}
public function setUpdatedDrupal($updated_drupal) {
$this->updated_drupal = $updated_drupal;
}
public function getFormattedContentType() {
$content_type = $this
->get('content_type_name');
if (!empty($content_type)) {
return $content_type;
}
else {
return $this
->t('None');
}
}
public function getFormattedEntityType() {
$entity_type = $this
->get('entity_type');
if (!empty($entity_type)) {
return ucfirst($entity_type);
}
else {
return $this
->t('None');
}
}
public function getFormatterUpdatedDrupal() {
$updated_drupal = $this
->get('updated_drupal');
if (!empty($updated_drupal)) {
return \Drupal::service('date.formatter')
->format($updated_drupal, 'custom', 'M d, Y - H:i');
}
else {
return $this
->t('Never');
}
}
public function getTemplate() {
return $this
->get('template');
}
public function setTemplate($template) {
$this->template = $template;
}
public function getData() {
return $this
->get('data');
}
public function setData($data) {
$this->data = $data;
}
public function hasMapping() {
return !empty($this
->get('data'));
}
public function getMigrations() {
return $this
->get('migration_definitions');
}
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
$entityTypeManager = \Drupal::service('entity_type.manager');
$migrationStorage = $entityTypeManager
->getStorage('migration');
foreach ($entities as $entity) {
$migrationIds = $entity
->getMigrations();
if (!$migrationIds) {
continue;
}
foreach ($migrationIds as $migrationId) {
$migration = $migrationStorage
->load($migrationId);
$migration
->delete();
}
}
}
}
Classes
Name |
Description |
Mapping |
Defines the GatherContent Mapping entity. |