View source
<?php
namespace Drupal\social_demo\Plugin\DemoContent;
use Drupal\social_demo\DemoNode;
use Drupal\social_demo\DemoContentParserInterface;
use Drupal\user\UserStorageInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\file\FileStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Page extends DemoNode {
protected $fileStorage;
public function __construct(array $configuration, $plugin_id, $plugin_definition, DemoContentParserInterface $parser, UserStorageInterface $user_storage, EntityStorageInterface $group_storage, FileStorageInterface $file_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $parser, $user_storage, $group_storage);
$this->fileStorage = $file_storage;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('social_demo.yaml_parser'), $container
->get('entity.manager')
->getStorage('user'), $container
->get('entity.manager')
->getStorage('group'), $container
->get('entity.manager')
->getStorage('file'));
}
protected function getEntry(array $item) {
$entry = parent::getEntry($item);
$entry['field_content_visibility'] = $item['field_content_visibility'];
if (!empty($item['image'])) {
$entry['field_page_image'] = $this
->prepareImage($item['image'], $item['image_alt']);
}
if (!empty($item['alias'])) {
$entry['path'] = [
'alias' => $item['alias'],
];
}
return $entry;
}
}