You are here

public function Post::getEntry in Open Social 8

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

Makes an array with data of an entity.

Parameters

array $item: Array with items.

Return value

array Returns an array.

Overrides DemoEntity::getEntry

File

modules/custom/social_demo/src/Plugin/DemoContent/Post.php, line 22

Class

Post
Post Plugin for demo content.

Namespace

Drupal\social_demo\Plugin\DemoContent

Code

public function getEntry(array $item) {
  $recipient_id = NULL;
  $group_id = NULL;
  $file_id = NULL;
  $entry = parent::getEntry($item);
  $created = $this
    ->createDate($item['created']);
  if (!empty($item['recipient']) && ($recipient = $this
    ->loadByUuid('user', $item['recipient']))) {
    $recipient_id = $recipient
      ->id();
  }
  if (!empty($item['group']) && ($group = $this
    ->loadByUuid('group', $item['group']))) {
    $group_id = $group
      ->id();
  }

  // Load image by uuid and set to post.
  if (!empty($item['field_post_image']) && ($file = $this
    ->loadByUuid('file', $item['field_post_image']))) {
    $file_id = $file
      ->id();
  }
  return $entry + [
    'langcode' => $item['langcode'],
    'type' => $item['type'],
    'field_post' => [
      'value' => $this
        ->checkMentionOrLinkByUuid($item['field_post']),
      'format' => 'basic_html',
    ],
    'field_visibility' => $item['field_visibility'],
    'field_recipient_user' => $recipient_id,
    'field_recipient_group' => $group_id,
    'field_post_image' => $file_id,
    'user_id' => $this
      ->loadByUuid('user', $item['uid'])
      ->id(),
    'created' => $created,
    'changed' => $created,
  ];
}