You are here

public function EntityStatus::isSourceEntity in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::isSourceEntity()
  2. 2.1.x src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::isSourceEntity()

Returns the information if the entity has originally been created on this site.

Parameters

bool $set: Optional parameter to set the value for IsSourceEntity

mixed $individual:

Return value

bool

File

src/Entity/EntityStatus.php, line 701

Class

EntityStatus
Defines the "Content Sync - Entity Status" entity type.

Namespace

Drupal\cms_content_sync\Entity

Code

public function isSourceEntity($set = null, $individual = false) {
  $status = EntityStatus::getInfosForEntity($this
    ->getEntityTypeName(), $this
    ->getUuid());
  if (true === $set) {
    if ($individual) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_IS_SOURCE_ENTITY);
    }
    else {
      foreach ($status as $info) {
        $info
          ->isSourceEntity(true, true);
      }
      $this
        ->isSourceEntity(true, true);
    }
    return true;
  }
  if (false === $set) {
    if ($individual) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_IS_SOURCE_ENTITY);
    }
    else {
      foreach ($status as $info) {
        $info
          ->isSourceEntity(false, true);
      }
      $this
        ->isSourceEntity(false, true);
    }
    return false;
  }
  if ($individual) {
    return (bool) ($this
      ->get('flags')->value & self::FLAG_IS_SOURCE_ENTITY);
  }
  foreach ($status as $info) {
    if ($info
      ->isSourceEntity(null, true)) {
      return true;
    }
  }
  return $this
    ->isSourceEntity(null, true);
}