buildBaseFieldDefinitions example


  public function getBaseFieldDefinitions($entity_type_id) {
    // Check the static cache.     if (!isset($this->baseFieldDefinitions[$entity_type_id])) {
      // Not prepared, try to load from cache.       $cid = 'entity_base_field_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->getId();
      if ($cache = $this->cacheGet($cid)) {
        $this->baseFieldDefinitions[$entity_type_id] = $cache->data;
      }
      else {
        // Rebuild the definitions and put it into the cache.         $this->baseFieldDefinitions[$entity_type_id] = $this->buildBaseFieldDefinitions($entity_type_id);
        $this->cacheSet($cid$this->baseFieldDefinitions[$entity_type_id], Cache::PERMANENT, ['entity_types', 'entity_field_info']);
      }
    }
    return $this->baseFieldDefinitions[$entity_type_id];
  }

  /** * Builds base field definitions for an entity type. * * @param string $entity_type_id * The entity type ID. Only entity types that implement * \Drupal\Core\Entity\FieldableEntityInterface are supported. * * @return \Drupal\Core\Field\FieldDefinitionInterface[] * An array of field definitions, keyed by field name. * * @throws \LogicException * Thrown if a config entity type is given or if one of the entity keys is * flagged as translatable. */
Home | Imprint | This part of the site doesn't use cookies.