You are here

protected function DemoContent::loadByUuid in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  2. 8 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  3. 8.2 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  4. 8.3 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  5. 8.5 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  6. 8.6 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  7. 8.7 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  8. 8.8 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  9. 10.3.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  10. 10.0.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  11. 10.1.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()
  12. 10.2.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::loadByUuid()

Load entity by uuid.

Parameters

string $entity_type_id: Identifier of entity type.

string|int $id: Identifier or uuid.

bool $all: If set true, method will return all loaded entity. If set false, will return only one.

Return value

\Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\EntityInterface[]|mixed Returns the entity.

7 calls to DemoContent::loadByUuid()
DemoComment::createContent in modules/custom/social_demo/src/DemoComment.php
Creates content.
DemoContent::checkMentionOrLinkByUuid in modules/custom/social_demo/src/DemoContent.php
Extract the mention from the content by [~Uuid].
DemoContent::prepareImage in modules/custom/social_demo/src/DemoContent.php
Prepares data about an image.
DemoGroup::createContent in modules/custom/social_demo/src/DemoGroup.php
Creates content.
DemoNode::createContent in modules/custom/social_demo/src/DemoNode.php
Creates content.

... See full list

File

modules/custom/social_demo/src/DemoContent.php, line 146

Class

DemoContent
Class DemoContent.

Namespace

Drupal\social_demo

Code

protected function loadByUuid($entity_type_id, $id, $all = FALSE) {
  if (property_exists($this, $entity_type_id . 'Storage')) {
    $storage = $this->{$entity_type_id . 'Storage'};
  }
  else {
    $storage = \Drupal::entityTypeManager()
      ->getStorage($entity_type_id);
  }
  if (is_numeric($id)) {
    $entities = $storage
      ->loadByProperties([
      'uid' => $id,
    ]);
  }
  else {
    $entities = $storage
      ->loadByProperties([
      'uuid' => $id,
    ]);
  }
  if (!$all) {
    return current($entities);
  }
  return $entities;
}