protected function Book::getEntry in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 8.2 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 8.3 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 8.4 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 8.5 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 8.6 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 8.7 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 8.8 modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 10.3.x modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 10.0.x modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 10.1.x modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
- 10.2.x modules/custom/social_demo/src/Plugin/DemoContent/Book.php \Drupal\social_demo\Plugin\DemoContent\Book::getEntry()
Makes an array with data of an entity.
Parameters
array $item: Array with items.
Return value
array Returns an array.
Overrides DemoNode::getEntry
File
- modules/
custom/ social_demo/ src/ Plugin/ DemoContent/ Book.php, line 69
Class
- Book
- Book Plugin for demo content.
Namespace
Drupal\social_demo\Plugin\DemoContentCode
protected function getEntry(array $item) {
$entry = parent::getEntry($item);
$entry['field_content_visibility'] = $item['field_content_visibility'];
// Load image by uuid and set to node.
if (!empty($item['field_book_image'])) {
$entry['field_book_image'] = $this
->prepareImage($item['field_book_image']);
}
// Load attachments to node.
if (!empty($item['field_files'])) {
$entry['field_files'] = $this
->prepareAttachment($item['field_files']);
}
if (!empty($item['alias'])) {
$entry['path'] = [
'alias' => $item['alias'],
];
}
if (!empty($item['book'])) {
// Top level book.
if ($item['book']['id'] === $item['uuid']) {
$entry['book']['bid'] = 'new';
unset($entry['book']['id']);
}
$mainbook = $this->entityStorage
->loadByProperties([
'uuid' => $item['book']['id'],
]);
$mainbook = current($mainbook);
// Must be a valid node.
if ($mainbook instanceof Node) {
$entry['book']['bid'] = $mainbook
->id();
$entry['book']['weight'] = $item['book']['weight'];
unset($entry['book']['id']);
if (isset($item['book']['parent'])) {
$parentbook = $this->entityStorage
->loadByProperties([
'uuid' => $item['book']['parent'],
]);
$parentbook = current($parentbook);
if ($parentbook instanceof Node) {
$entry['book']['pid'] = $parentbook
->id();
}
}
else {
$entry['book']['pid'] = $mainbook
->id();
}
}
}
return $entry;
}