You are here

public function EntityStatus::isOverriddenLocally in CMS Content Sync 8

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

Returns the information if the user override the entity locally.

Parameters

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

bool $individual:

Return value

bool

File

src/Entity/EntityStatus.php, line 649

Class

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

Namespace

Drupal\cms_content_sync\Entity

Code

public function isOverriddenLocally($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_EDIT_OVERRIDE);
    }
    else {
      foreach ($status as $info) {
        $info
          ->isOverriddenLocally(true, true);
      }
    }
    return true;
  }
  if (false === $set) {
    if ($individual) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_EDIT_OVERRIDE);
    }
    else {
      foreach ($status as $info) {
        $info
          ->isOverriddenLocally(false, true);
      }
    }
    return false;
  }
  if ($individual) {
    return (bool) ($this
      ->get('flags')->value & self::FLAG_EDIT_OVERRIDE);
  }
  foreach ($status as $info) {
    if ($info
      ->isOverriddenLocally(null, true)) {
      return true;
    }
  }
  return false;
}