/**
  * Constructs a new FieldStorageConfigListBuilder object.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type definition.
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager.
  * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
  *   The 'field type' plugin manager.
  */
 public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, EntityTypeBundleInfoInterface $bundle_info_service)
 {
     parent::__construct($entity_type, $entity_manager->getStorage($entity_type->id()));
     $this->entityManager = $entity_manager;
     $this->bundles = $bundle_info_service->getAllBundleInfo();
     $this->fieldTypeManager = $field_type_manager;
     $this->fieldTypes = $this->fieldTypeManager->getDefinitions();
 }
예제 #2
0
 /**
  * Writes the cache of type links.
  *
  * @param array $context
  *   Context from the normalizer/serializer operation.
  *
  * @return array
  *   An array of typed data ids (entity_type and bundle) keyed by
  *   corresponding type URI.
  */
 protected function writeCache($context = array())
 {
     $data = array();
     // Type URIs correspond to bundles. Iterate through the bundles to get the
     // URI and data for them.
     $entity_types = \Drupal::entityManager()->getDefinitions();
     foreach ($this->bundleInfoService->getAllBundleInfo() as $entity_type_id => $bundles) {
         // Only content entities are supported currently.
         // @todo Consider supporting config entities.
         if ($entity_types[$entity_type_id]->isSubclassOf('\\Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
             continue;
         }
         foreach ($bundles as $bundle => $bundle_info) {
             // Get a type URI for the bundle.
             $bundle_uri = $this->getTypeUri($entity_type_id, $bundle, $context);
             $data[$bundle_uri] = array('entity_type' => $entity_type_id, 'bundle' => $bundle);
         }
     }
     // These URIs only change when entity info changes, so cache it permanently
     // and only clear it when entity_info is cleared.
     $this->cache->set('rest:links:types', $data, Cache::PERMANENT, array('entity_types'));
     return $data;
 }