ImportEntityViewBuilder.php in Content Synchronizer 3.x
File
src/Entity/ImportEntityViewBuilder.php
View source
<?php
namespace Drupal\content_synchronizer\Entity;
use Drupal\content_synchronizer\Form\LaunchImportForm;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityViewBuilder;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Theme\Registry;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ImportEntityViewBuilder extends EntityViewBuilder {
private $formBuilder;
public function __construct(EntityTypeInterface $entity_type, EntityRepositoryInterface $entity_repository, LanguageManagerInterface $language_manager, Registry $theme_registry = NULL, EntityDisplayRepositoryInterface $entity_display_repository = NULL, FormBuilderInterface $formBuilder = NULL) {
parent::__construct($entity_type, $entity_repository, $language_manager, $theme_registry, $entity_display_repository);
$this->formBuilder = $formBuilder;
}
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container
->get('entity.repository'), $container
->get('language_manager'), $container
->get('theme.registry'), $container
->get('entity_display.repository'), $container
->get('form_builder'));
}
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
$formState = new FormState();
$formState
->addBuildInfo('import', $entity);
return $this->formBuilder
->buildForm(LaunchImportForm::class, $formState);
}
}