protected TypeLinkManager::writeCache($context = array())
Writes the cache of type links.
Parameters
array $context: Context from the normalizer/serializer operation.
Return value
array An array of typed data ids (entity_type and bundle) keyed by corresponding type URI.
File
- core/modules/rest/src/LinkManager/TypeLinkManager.php, line 121
Class
Namespace
Drupal\rest\LinkManager
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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 ; } |
Please login to continue.