コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $moduleHandler = $this->moduleHandler;
     $moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
     $moduleHandler->loadInclude('locale', 'module');
     $language = $input->getArgument('language');
     $languagesObjects = locale_translatable_language_list();
     $languages = $this->site->getStandardLanguages();
     if (isset($languagesObjects[$language])) {
         $languageEntity = $languagesObjects[$language];
     } elseif (array_search($language, $languages)) {
         $langcode = array_search($language, $languages);
         $languageEntity = $languagesObjects[$langcode];
     } else {
         $io->error(sprintf($this->trans('commands.locale.language.delete.messages.invalid-language'), $language));
         return 1;
     }
     try {
         $configurable_language_storage = $this->entityTypeManager->getStorage('configurable_language');
         $configurable_language_storage->load($languageEntity->getId())->delete();
         $io->info(sprintf($this->trans('commands.locale.language.delete.messages.language-deleted-successfully'), $languageEntity->getName()));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     return 0;
 }
コード例 #2
0
 /**
  * On workflow transition.
  *
  * @param \Drupal\state_machine\Event\StateChangeEvent $event
  *   The state change event.
  *
  * @throws \Drupal\message_notify\Exception\MessageNotifyException
  */
 public function onChangeToValidated(StateChangeEvent $event)
 {
     $entity = $event->getEntity();
     $bundle = $entity->bundle();
     if ($bundle != 'solution') {
         return;
     }
     $message_template = MessageTemplate::load('workflow_transition');
     $storage = $this->entityTypeManager->getStorage('og_membership');
     // Sent a message to all solution administrators.
     $membership_query = $storage->getQuery()->condition('state', 'active')->condition('entity_id', $entity->id());
     $memberships_ids = $membership_query->execute();
     $memberships = OgMembership::loadMultiple($memberships_ids);
     $memberships = array_filter($memberships, function ($membership) {
         return $membership->hasPermission('message notification on validate');
     });
     /** @var OgMembership $membership */
     foreach ($memberships as $membership) {
         $uid = $membership->get('uid')->first()->getValue()['target_id'];
         // Create the actual message and save it to the db.
         $message = Message::create(['template' => $message_template->id(), 'uid' => $uid, 'field_message_content' => $entity->id()]);
         $message->save();
         // Send the saved message as an e-mail.
         $this->messageNotifier->send($message, [], 'email');
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($io);
         $input->setOption('module', $module);
     }
     // view-id argument
     $viewId = $input->getArgument('view-id');
     if (!$viewId) {
         $views = $this->entityTypeManager->getStorage('view')->loadMultiple();
         $viewList = [];
         foreach ($views as $view) {
             $viewList[$view->get('id')] = $view->get('label');
         }
         $viewId = $io->choiceNoList($this->trans('commands.config.export.view.questions.view'), $viewList);
         $input->setArgument('view-id', $viewId);
     }
     $optionalConfig = $input->getOption('optional-config');
     if (!$optionalConfig) {
         $optionalConfig = $io->confirm($this->trans('commands.config.export.view.questions.optional-config'), true);
         $input->setOption('optional-config', $optionalConfig);
     }
     $includeModuleDependencies = $input->getOption('include-module-dependencies');
     if (!$includeModuleDependencies) {
         $includeModuleDependencies = $io->confirm($this->trans('commands.config.export.view.questions.include-module-dependencies'), true);
         $input->setOption('include-module-dependencies', $includeModuleDependencies);
     }
 }
コード例 #4
0
 /**
  * Create node and populate fields.
  *
  * @param string $title
  * @param array $fields
  * @param string $type
  * @param int $uid
  */
 public function createNode($title = '', $fields = [], $type = 'video', $uid = 1)
 {
     $node = $this->entity_type_manager->getStorage('node')->create(['type' => $type, 'title' => $title, 'uid' => $uid]);
     foreach ($fields as $field => $value) {
         $node->set($field, $value);
     }
     $node->save();
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $uid = $input->getArgument('user-id');
     $user = $this->entityTypeManager->getStorage('user')->load($uid);
     if (!$user) {
         $io->error(sprintf($this->trans('commands.user.login.url.errors.invalid-user'), $uid));
         return 1;
     }
     $url = user_pass_reset_url($user);
     $io->success(sprintf($this->trans('commands.user.login.url.messages.url'), $user->getUsername(), $url));
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $entityDefinitionID = $input->getArgument('entity-definition-id');
     $entityID = $input->getArgument('entity-id');
     try {
         $this->entityTypeManager->getStorage($entityDefinitionID)->load($entityID)->delete();
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $io->success(sprintf($this->trans('commands.entity.delete.messages.deleted'), $entityDefinitionID, $entityID));
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $roles = $input->getOption('roles');
     $limit = $input->getOption('limit');
     $uids = $this->splitOption($input->getOption('uid'));
     $usernames = $this->splitOption($input->getOption('username'));
     $mails = $this->splitOption($input->getOption('mail'));
     $userStorage = $this->entityTypeManager->getStorage('user');
     $systemRoles = $this->drupalApi->getRoles();
     $query = $this->entityQuery->get('user');
     $query->condition('uid', 0, '>');
     $query->sort('uid');
     // uid as option
     if (is_array($uids) && $uids) {
         $group = $query->andConditionGroup()->condition('uid', $uids, 'IN');
         $query->condition($group);
     }
     // username as option
     if (is_array($usernames) && $usernames) {
         $group = $query->andConditionGroup()->condition('name', $usernames, 'IN');
         $query->condition($group);
     }
     // mail as option
     if (is_array($mails) && $mails) {
         $group = $query->andConditionGroup()->condition('mail', $mails, 'IN');
         $query->condition($group);
     }
     if ($roles) {
         $query->condition('roles', is_array($roles) ? $roles : [$roles], 'IN');
     }
     if ($limit) {
         $query->range(0, $limit);
     }
     $results = $query->execute();
     $users = $userStorage->loadMultiple($results);
     $tableHeader = [$this->trans('commands.user.debug.messages.user-id'), $this->trans('commands.user.debug.messages.username'), $this->trans('commands.user.debug.messages.roles'), $this->trans('commands.user.debug.messages.status')];
     $tableRows = [];
     foreach ($users as $userId => $user) {
         $userRoles = [];
         foreach ($user->getRoles() as $userRole) {
             $userRoles[] = $systemRoles[$userRole];
         }
         $status = $user->isActive() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled');
         $tableRows[] = [$userId, $user->getUsername(), implode(', ', $userRoles), $status];
     }
     $io->table($tableHeader, $tableRows);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $viewId = $input->getArgument('view-id');
     $view = $this->entityTypeManager->getStorage('view')->load($viewId);
     if (empty($view)) {
         $io->error(sprintf($this->trans('commands.views.debug.messages.not-found'), $viewId));
         return;
     }
     try {
         $view->disable()->save();
         $io->success(sprintf($this->trans('commands.views.disable.messages.disabled-successfully'), $view->get('label')));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
     }
 }
コード例 #9
0
 /**
  * Tests the getStorage() method.
  *
  * @covers ::getStorage
  */
 public function testGetStorage()
 {
     $class = $this->getTestHandlerClass();
     $entity = $this->prophesize(EntityTypeInterface::class);
     $entity->getHandlerClass('storage')->willReturn($class);
     $this->setUpEntityTypeDefinitions(['test_entity_type' => $entity]);
     $this->assertInstanceOf($class, $this->entityTypeManager->getStorage('test_entity_type'));
 }
コード例 #10
0
 /**
  * @cover replacePlaceHolders
  */
 public function testPlaceholdersAcrossReferences()
 {
     $user = $this->entityTypeManager->getStorage('user')->create(['name' => 'test', 'type' => 'user']);
     $this->node->uid->entity = $user;
     $text = 'test {{node.title}} and {{node.uid.entity.name}}';
     $result = $this->placeholderResolver->replacePlaceHolders($text, ['node' => $this->node->getTypedData()]);
     $this->assertEquals('test test and test', $result);
 }
コード例 #11
0
 /**
  * Retrieves the uri of a bundle's graph from the settings.
  *
  * @param string $bundle_type_key
  *    The bundle type key. E.g. 'node_type'.
  * @param string $bundle_id
  *    The bundle machine name.
  * @param string $graph_name
  *    The graph name.
  *
  * @return string
  *    The graph uri.
  *
  * @throws \Exception
  *    Thrown if the graph is not found.
  */
 protected function getBundleGraphUriFromSettings($bundle_type_key, $bundle_id, $graph_name)
 {
     $bundle = $this->entityManager->getStorage($bundle_type_key)->load($bundle_id);
     $graph = $bundle->getThirdPartySetting('rdf_entity', 'graph_' . $graph_name, FALSE);
     if (!$graph) {
         throw new \Exception(format_string('Unable to determine graph %graph for bundle %bundle', ['%graph' => $graph_name, '%bundle' => $bundle->id()]));
     }
     return $graph;
 }
コード例 #12
0
 private function queryBenzinarii($lat_ne, $lon_ne, $lat_sw, $lon_sw)
 {
     $data = new \stdClass();
     $data->pins = [];
     $data->listing = '';
     $query = $this->entity_query->get('node')->condition('field_coordonate.lat', (double) $lat_ne, '<')->condition('field_coordonate.lon', (double) $lon_ne, '<')->condition('field_coordonate.lat', (double) $lat_sw, '>')->condition('field_coordonate.lon', (double) $lon_sw, '>');
     $ids = $query->execute();
     if (!count($ids)) {
         return $data;
     }
     $entities = $this->entity_type_manager->getStorage('node')->loadMultiple($ids);
     foreach ($entities as $entity) {
         $pin = new \stdClass();
         $pin->lat = $entity->field_coordonate->lat;
         $pin->lon = $entity->field_coordonate->lon;
         $pin->pret = PretCarburant::getPretCarburantCurent($entity);
         $pin->id = $entity->id();
         if ($pin->pret) {
             $entity->pret = $pin->pret;
             $data->pins[$pin->id] = $pin;
             $render_entities[] = $entity;
         }
     }
     if (!count($render_entities)) {
         return $data;
     }
     uasort($render_entities, function ($a, $b) {
         if ($a->pret == $b->pret) {
             return 0;
         } else {
             if ($a->pret < $b->pret) {
                 return -1;
             } else {
                 return 1;
             }
         }
     });
     $render = $this->entity_type_manager->getViewBuilder('node')->viewMultiple($render_entities, 'small_teaser');
     $data->listing = '<div class="listing-benzinarii">' . $this->renderer->render($render) . '</div>';
     return $data;
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 public function validateFileSize(EmbridgeAssetEntityInterface $asset, $file_limit = 0, $user_limit = 0)
 {
     $user = $this->currentUser;
     $errors = array();
     if ($file_limit && $asset->getSize() > $file_limit) {
         $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($asset->getSize()), '%maxsize' => format_size($file_limit)));
     }
     // Save a query by only calling spaceUsed() when a limit is provided.
     if ($user_limit && $this->entityTypeManager->getStorage('embridge_asset')->spaceUsed($user->id()) + $asset->getSize() > $user_limit) {
         $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($asset->getSize()), '%quota' => format_size($user_limit)));
     }
     return $errors;
 }
コード例 #14
0
ファイル: Query.php プロジェクト: ec-europa/joinup-dev
 /**
  * Constructs a query object.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type definition.
  * @param string $conjunction
  *   - AND: all of the conditions on the query need to match.
  *   - OR: at least one of the conditions on the query need to match.
  * @param \Drupal\rdf_entity\Database\Driver\sparql\Connection $connection
  *   The database connection to run the query against.
  * @param array $namespaces
  *   List of potential namespaces of the classes belonging to this query.
  * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
  *   The entity type manager service object.
  * @param \Drupal\rdf_entity\RdfGraphHandler $rdf_graph_handler
  *    The rdf graph handler service.
  * @param \Drupal\rdf_entity\RdfMappingHandler $rdf_mapping_handler
  *    The rdf mapping handler service.
  *
  * @throws \Exception
  *   Thrown when the storage passed is not an RdfEntitySparqlStorage.
  *
  * @todo: Is this exception check needed?
  */
 public function __construct(EntityTypeInterface $entity_type, $conjunction, Connection $connection, array $namespaces, EntityTypeManager $entity_type_manager, RdfGraphHandler $rdf_graph_handler, RdfMappingHandler $rdf_mapping_handler)
 {
     parent::__construct($entity_type, $conjunction, $namespaces);
     $this->filter = new SparqlFilter();
     $this->connection = $connection;
     $this->entityTypeManager = $entity_type_manager;
     $this->entityStorage = $this->entityTypeManager->getStorage($this->entityTypeId);
     $this->graphHandler = $rdf_graph_handler;
     $this->mappingHandler = $rdf_mapping_handler;
     if (!$this->entityStorage instanceof RdfEntitySparqlStorage) {
         throw new \Exception('Sparql storage is required for this query.');
     }
 }
コード例 #15
0
 /**
  * Get the directly previous revision.
  *
  * $entity->original will not ALWAYS be the previous revision.
  *
  * @param \Drupal\Core\Entity\ContentEntityInterface $entity
  *
  * @return \Drupal\Core\Entity\EntityInterface|null
  */
 public function getPreviousRevision(ContentEntityInterface $entity)
 {
     $storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
     $query = $storage->getQuery();
     $type = $entity->getEntityType();
     $query->allRevisions()->condition($type->getKey('id'), $entity->id())->condition($type->getKey('revision'), $entity->getRevisionId(), '<')->sort($type->getKey('revision'), 'DESC')->pager(1);
     $revision_ids = $query->execute();
     if ($revision_ids) {
         $revision_id = array_keys($revision_ids)[0];
         return $storage->loadRevision($revision_id);
     }
     return NULL;
 }
コード例 #16
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $userId = $input->getOption('user-id');
     if ($userId && $userId <= 1) {
         $io->error(sprintf($this->trans('commands.user.delete.errors.invalid-user-id'), $userId));
         return 1;
     }
     if ($userId) {
         $user = $this->entityTypeManager->getStorage('user')->load($userId);
         if (!$user) {
             $io->error(sprintf($this->trans('commands.user.delete.errors.invalid-user'), $userId));
             return 1;
         }
         try {
             $user->delete();
             $io->info(sprintf($this->trans('commands.user.delete.messages.user-deleted'), $user->getUsername()));
         } catch (\Exception $e) {
             $io->error($e->getMessage());
             return 1;
         }
     }
     $roles = $input->getOption('roles');
     if ($roles) {
         $userStorage = $this->entityManager->getStorage('user');
         $query = $this->entityQuery->get('user');
         $query->condition('roles', is_array($roles) ? $roles : [$roles], 'IN');
         $query->condition('uid', 1, '>');
         $results = $query->execute();
         $users = $userStorage->loadMultiple($results);
         $tableHeader = [$this->trans('commands.user.debug.messages.user-id'), $this->trans('commands.user.debug.messages.username')];
         $tableRows = [];
         foreach ($users as $userId => $user) {
             try {
                 $user->delete();
                 $tableRows['success'][] = [$userId, $user->getUsername()];
             } catch (\Exception $e) {
                 $tableRows['error'][] = [$userId, $user->getUsername()];
                 $io->error($e->getMessage());
                 return 1;
             }
         }
         if ($tableRows['success']) {
             $io->table($tableHeader, $tableRows['success']);
             $io->success(sprintf($this->trans('commands.user.delete.messages.users-deleted'), count($tableRows['success'])));
         }
     }
 }
コード例 #17
0
ファイル: DebugCommand.php プロジェクト: jeyram/DrupalConsole
 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param $tag
  * @param $status
  */
 protected function viewList(DrupalStyle $io, $tag, $status)
 {
     $views = $this->entityTypeManager->getStorage('view')->loadMultiple();
     $tableHeader = [$this->trans('commands.views.debug.messages.view-id'), $this->trans('commands.views.debug.messages.view-name'), $this->trans('commands.views.debug.messages.tag'), $this->trans('commands.views.debug.messages.status'), $this->trans('commands.views.debug.messages.path')];
     $tableRows = [];
     foreach ($views as $view) {
         if ($status != -1 && $view->status() != $status) {
             continue;
         }
         if (isset($tag) && $view->get('tag') != $tag) {
             continue;
         }
         $tableRows[] = [$view->get('id'), $view->get('label'), $view->get('tag'), $view->status() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled'), $this->viewDisplayPaths($view)];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
コード例 #18
0
 protected function getViewDisplays($contentType, $optional = false)
 {
     $view_display_definition = $this->entityTypeManager->getDefinition('entity_view_display');
     $view_display_storage = $this->entityTypeManager->getStorage('entity_view_display');
     foreach ($view_display_storage->loadMultiple() as $view_display) {
         $view_display_name = $view_display_definition->getConfigPrefix() . '.' . $view_display->id();
         $view_display_name_config = $this->getConfiguration($view_display_name);
         // Only select fields related with content type
         if ($view_display_name_config['bundle'] == $contentType) {
             $this->configExport[$view_display_name] = array('data' => $view_display_name_config, 'optional' => $optional);
             // Include dependencies in export files
             if ($dependencies = $this->fetchDependencies($view_display_name_config, 'config')) {
                 $this->resolveDependencies($dependencies, $optional);
             }
         }
     }
 }
コード例 #19
0
 /**
  * @cover fetchDataByPropertyPath
  */
 public function testBubbleableMetadata()
 {
     $this->node->field_integer->setValue([]);
     // Save the node, so that it gets an ID and it has a cache tag.
     $this->node->save();
     // Also add a user for testing cache tags of references.
     $user = $this->entityTypeManager->getStorage('user')->create(['name' => 'test', 'type' => 'user']);
     $user->save();
     $this->node->uid->entity = $user;
     $bubbleable_metadata = new BubbleableMetadata();
     $this->dataFetcher->fetchDataByPropertyPath($this->node->getTypedData(), 'title.value', $bubbleable_metadata)->getValue();
     $expected = ['node:' . $this->node->id()];
     $this->assertEquals($expected, $bubbleable_metadata->getCacheTags());
     // Test cache tags of references are added correctly.
     $this->dataFetcher->fetchDataByPropertyPath($this->node->getTypedData(), 'uid.entity.name', $bubbleable_metadata)->getValue();
     $expected = ['node:' . $this->node->id(), 'user:' . $user->id()];
     $this->assertEquals($expected, $bubbleable_metadata->getCacheTags());
 }
コード例 #20
0
  /**
   * Helper function to get the image fields.
   *
   * @return array
   *   An array of image fields name.
   */
  public function getImageFields() {
    $image_fields = &drupal_static(__FUNCTION__);

    if (!isset($image_fields)) {
      /** @var \Drupal\field\Entity\FieldConfig[] $field_instance_config_entities */
      $field_instance_config_entities = $this->entityTypeManager->getStorage('field_config')->loadMultiple();

      $image_fields = array();
      foreach ($field_instance_config_entities as $field_instance_config_entity) {
        // Restrict to image fields.
        if ($field_instance_config_entity->get('field_type') == 'image') {
          $field_name = $field_instance_config_entity->get('field_name');

          // Check if we already have this field.
          if (!in_array($field_name, $image_fields)) {
            $image_fields[] = $field_name;
          }
        }
      }
    }

    return $image_fields;
  }
コード例 #21
0
 /**
  * Returns a list of mapped properties for the passed content entity.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   A content entity.
  *
  * @return array
  *    An array of mappings between predicates and field properties. All
  *    fields, and properties of the entity and the fields, that are available
  *    will be returned.
  */
 public function getEntityTypeMappedProperties(EntityInterface $entity)
 {
     $bundle = $entity->bundle();
     $properties = [];
     // Collect impacted fields.
     $definitions = $this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $bundle);
     $base_field_definitions = $this->entityManager->getBaseFieldDefinitions($entity->getEntityTypeId());
     $rdf_bundle_entity = $this->entityManager->getStorage($entity->getEntityType()->getBundleEntityType())->load($bundle);
     /** @var \Drupal\Core\Field\BaseFieldDefinition $field_definition */
     foreach ($definitions as $field_name => $field_definition) {
         /** @var \Drupal\field\Entity\FieldStorageConfig $storage_definition */
         $storage_definition = $field_definition->getFieldStorageDefinition();
         if (!$storage_definition instanceof FieldStorageConfig) {
             continue;
         }
         foreach ($storage_definition->getColumns() as $column => $column_info) {
             if ($property = $storage_definition->getThirdPartySetting('rdf_entity', 'mapping_' . $column, FALSE)) {
                 $properties['by_field'][$field_name][$column] = $property;
                 $properties['flat'][$property] = $property;
             }
         }
     }
     foreach ($base_field_definitions as $field_name => $base_field_definition) {
         $field_data = $rdf_bundle_entity->getThirdPartySetting('rdf_entity', 'mapping_' . $field_name, FALSE);
         if (!$field_data) {
             continue;
         }
         foreach ($field_data as $column => $predicate) {
             if (empty($predicate)) {
                 continue;
             }
             $properties['by_field'][$field_name][$column] = $predicate;
             $properties['flat'][$predicate] = $predicate;
         }
     }
     return $properties;
 }
コード例 #22
0
ファイル: GroupLister.php プロジェクト: eloiv/botafoc.cat
 /**
  * {@inheritdoc}
  */
 public function __construct(EntityTypeManager $entityTypeManager) {
   $this->storage = $entityTypeManager->getStorage('block_visibility_group');
 }
コード例 #23
0
 /**
  * Constructs a FacetForm object.
  *
  * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
  *   The entity manager.
  * @param \Drupal\facets\FacetSource\FacetSourcePluginManager $facet_source_plugin_manager
  *   The plugin manager for facet sources.
  * @param \Drupal\facets\Processor\ProcessorPluginManager $processor_plugin_manager
  *   The plugin manager for processors.
  */
 public function __construct(EntityTypeManager $entity_type_manager, FacetSourcePluginManager $facet_source_plugin_manager, ProcessorPluginManager $processor_plugin_manager)
 {
     $this->facetStorage = $entity_type_manager->getStorage('facets_facet');
     $this->facetSourcePluginManager = $facet_source_plugin_manager;
     $this->processorPluginManager = $processor_plugin_manager;
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 public function __construct(EntityTypeManager $entity_type_manager)
 {
     $this->entityTypeManager = $entity_type_manager;
     $this->entityStorage = $entity_type_manager->getStorage('rdf_entity');
 }
コード例 #25
0
  /**
   * Constructs a new PaymentInfoListBuilder object.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entityType
   *   The entity type definition.
   * @param \Drupal\Core\Entity\EntityTypeManager $entityTypeManager
   *   The entity type manager.
   * @param \Drupal\Core\Datetime\DateFormatter $dateFormatter
   *   The date service.
   */
  public function __construct(EntityTypeInterface $entityType, EntityTypeManager $entityTypeManager, DateFormatter $dateFormatter) {
    parent::__construct($entityType, $entityTypeManager->getStorage($entityType->id()));

    $this->dateFormatter = $dateFormatter;
  }