/**
  * Returns cached entity or null
  *
  * @param string $class
  * @param array  $identifiers
  *
  * @return mixed Entity source data
  */
 public function get($class, array $identifiers)
 {
     $metadata = $this->manager->getClassMetadata($class);
     $configuration = $this->manager->getConfiguration()->getCacheConfiguration($metadata->getName());
     if (null === $configuration || $configuration['enabled'] === false) {
         $this->logger->debug(sprintf('Skipping entity cache for %s: not configured', $metadata->getName()));
         return null;
     }
     $item = $this->cache->getItem($this->getEntityKey($metadata, $identifiers));
     $this->logger->debug(sprintf('Entity cache %s', $item->isHit() ? 'HIT' : 'MISS'), ['class' => $class, 'identifiers' => $identifiers]);
     return $item->get();
 }
 /**
  * convert foreign identifiers into scalar foreign key values to avoid object to string conversion failures.
  *
  * @param ApiMetadata $class
  * @param array       $id
  *
  * @return array
  */
 public function flattenIdentifier(ApiMetadata $class, array $id)
 {
     $flatId = [];
     foreach ($class->getIdentifierFieldNames() as $field) {
         if ($class->hasAssociation($field) && array_key_exists($field, $id) && is_object($id[$field])) {
             /* @var EntityMetadata $targetClassMetadata */
             $targetClassMetadata = $this->manager->getClassMetadata($class->getAssociationMapping($field)['target']);
             if ($this->unitOfWork->isInIdentityMap($id[$field])) {
                 $associatedId = $this->flattenIdentifier($targetClassMetadata, $this->unitOfWork->getEntityIdentifier($id[$field]));
             } else {
                 $associatedId = $this->flattenIdentifier($targetClassMetadata, $targetClassMetadata->getIdentifierValues($id[$field]));
             }
             $flatId[$field] = implode(' ', $associatedId);
         } else {
             $flatId[$field] = $id[$field];
         }
     }
     return $flatId;
 }