getActiveFieldStorageDefinitions example

->willReturn($this->entityType);

    $this->entityTypeManager
      ->getActiveDefinition($this->entityType->id())
      ->willReturn($this->entityType);

    $this->entityFieldManager
      ->getFieldStorageDefinitions($this->entityType->id())
      ->willReturn($this->fieldDefinitions);

    $this->entityFieldManager
      ->getActiveFieldStorageDefinitions($this->entityType->id())
      ->willReturn($this->fieldDefinitions);

    $this->entityStorage = new SqlContentEntityStorage($this->entityType, $this->connection, $this->entityFieldManager->reveal()$this->cache, $this->languageManager, new MemoryCache()$this->entityTypeBundleInfo, $this->entityTypeManager->reveal());
    $this->entityStorage->setModuleHandler($this->moduleHandler);
  }

  /** * @covers ::doLoadMultiple * @covers ::buildCacheId * @covers ::getFromPersistentCache */
  

  public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityFieldManagerInterface $entity_field_manager, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, MemoryCacheInterface $memory_cache, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($entity_type$entity_field_manager$cache$memory_cache$entity_type_bundle_info);
    $this->database = $database;
    $this->languageManager = $language_manager;
    $this->entityTypeManager = $entity_type_manager;
    $this->entityType = $this->entityTypeManager->getActiveDefinition($entity_type->id());
    $this->fieldStorageDefinitions = $this->entityFieldManager->getActiveFieldStorageDefinitions($entity_type->id());

    $this->initTableLayout();
  }

  /** * Initializes table name variables. */
  protected function initTableLayout() {
    // Reset table field values to ensure changes in the entity type definition     // are correctly reflected in the table layout.     $this->tableMapping = NULL;
    
    // new table. So for the first two, the table array index will be 'tags'     // while the third will be 'node_reference.nid.tags'.     $index_prefix = '';
    $specifiers = explode('.', $field);
    $base_table = 'base_table';
    $count = count($specifiers) - 1;
    // This will contain the definitions of the last specifier seen by the     // system.     $propertyDefinitions = [];
    $entity_type = $this->entityTypeManager->getActiveDefinition($entity_type_id);

    $field_storage_definitions = $this->entityFieldManager->getActiveFieldStorageDefinitions($entity_type_id);
    for ($key = 0; $key <= $count$key++) {
      // This can either be the name of an entity base field or a configurable       // field.       $specifier = $specifiers[$key];
      if (isset($field_storage_definitions[$specifier])) {
        $field_storage = $field_storage_definitions[$specifier];
        $column = $field_storage->getMainPropertyName();
      }
      else {
        $field_storage = FALSE;
        $column = NULL;
      }

  public function __construct(EntityTypeManagerInterface $entity_type_manager, ContentEntityTypeInterface $entity_type, SqlContentEntityStorage $storage, Connection $database, EntityFieldManagerInterface $entity_field_manager) {
    $this->entityTypeManager = $entity_type_manager;
    $this->storage = clone $storage;
    $this->database = $database;
    $this->entityFieldManager = $entity_field_manager;

    $this->entityType = $entity_type_manager->getActiveDefinition($entity_type->id());
    $this->fieldStorageDefinitions = $entity_field_manager->getActiveFieldStorageDefinitions($entity_type->id());
  }

  /** * Gets the keyvalue collection for tracking the installed schema. * * @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface * * @todo Inject this dependency in the constructor once this class can be * instantiated as a regular entity handler: * https://www.drupal.org/node/2332857. */
  
/** * {@inheritdoc} */
  public function clickSort($order) {
    $this->ensureMyTable();

    // This could be derived from the content_moderation_state entity table     // mapping, however this is an internal entity type whose storage should     // remain constant.     $storage = $this->entityTypeManager->getStorage('content_moderation_state');
    $storage_definition = $this->entityFieldManager->getActiveFieldStorageDefinitions('content_moderation_state')['moderation_state'];
    $column_name = $storage->getTableMapping()->getFieldColumnName($storage_definition, 'value');
    $this->aliases[$column_name] = $this->tableAlias . '.' . $column_name;

    $this->query->addOrderBy(NULL, NULL, $order$this->aliases[$column_name]);
  }

}
->willReturn($this->entityType);

    $this->entityTypeManager
      ->getActiveDefinition($this->entityType->id())
      ->willReturn($this->entityType);

    $this->entityFieldManager
      ->getFieldStorageDefinitions($this->entityType->id())
      ->willReturn($this->storageDefinitions);

    $this->entityFieldManager
      ->getActiveFieldStorageDefinitions($this->entityType->id())
      ->willReturn($this->storageDefinitions);

    $this->dbSchemaHandler = $this->getMockBuilder('Drupal\Core\Database\Schema')
      ->disableOriginalConstructor()
      ->getMock();

    if ($expected) {
      $invocation_count = 0;
      $expected_table_names = array_keys($expected);
      $expected_table_schemas = array_values($expected);

      

  protected function cleanIds(array $ids$entity_key = 'id') {
    $definitions = $this->entityFieldManager->getActiveFieldStorageDefinitions($this->entityTypeId);
    $field_name = $this->entityType->getKey($entity_key);
    if ($field_name && $definitions[$field_name]->getType() == 'integer') {
      $ids = array_filter($idsfunction D$id) {
        return is_numeric($id) && $id == (int) $id;
      });
      $ids = array_map('intval', $ids);
    }
    return $ids;
  }

  /** * Gets entities from the persistent cache backend. * * @param array|null &$ids * If not empty, return entities that match these IDs. IDs that were found * will be removed from the list. * * @return \Drupal\Core\Entity\ContentEntityInterface[] * Array of entities from the persistent cache. */
Home | Imprint | This part of the site doesn't use cookies.