You are here

public function Entity::process in Convert Media Tags to Markup 8

Same name and namespace in other branches
  1. 2.x src/ConvertMediaTagsToMarkup/Entity.php \Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup\Entity::process()

Process this entity; change the media tags code to an image tag.

Parameters

bool $simulate: Whether or not to Simulate the results.

string $log: For example "print_r" or "dpm".

Throws

Exception

File

src/ConvertMediaTagsToMarkup/Entity.php, line 35

Class

Entity
Represents a Drupal entity for our purposes.

Namespace

Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup

Code

public function process(bool $simulate = TRUE, string $log = 'print_r') {
  foreach ($this->entity
    ->getFields() as $fieldname => $field) {
    $this
      ->processField($fieldname, $field, $simulate, $log);
  }
  if ($simulate) {
    $log('Not actually saving entity ' . $this->entity
      ->id() . ' because we are in simulation mode.' . PHP_EOL);
  }
  else {
    $log('Saving entity ' . $this->entity
      ->id() . ' because we are not in simulation mode.' . PHP_EOL);
    $this->entity
      ->save();
  }
}