/**
  * @see PropertyLookup::getPropertyForId
  */
 public function getPropertyForId(PropertyId $propertyId)
 {
     try {
         return $this->entityCache->fetch($propertyId);
     } catch (EntityNotFoundException $e) {
         $property = $this->itemLookup->getPropertyForId($propertyId);
         $this->entityCache->save($property);
         return $property;
     }
 }
 /**
  * @see ItemLookup::getItemForId
  */
 public function getItemForId(ItemId $itemId)
 {
     try {
         return $this->entityCache->fetch($itemId);
     } catch (EntityNotFoundException $e) {
         $item = $this->itemLookup->getItemForId($itemId);
         $this->entityCache->save($item);
         return $item;
     }
 }
Exemplo n.º 3
0
 /**
  * @see PropertyLookup::getPropertyForId
  */
 public function getPropertyForId(PropertyId $propertyId)
 {
     $property = $this->entityCache->fetch($propertyId);
     if ($property === null) {
         $property = $this->propertyLookup->getPropertyForId($propertyId);
         if ($property !== null) {
             $this->entityCache->save($property);
         }
     }
     return $property;
 }
Exemplo n.º 4
0
 /**
  * @see ItemLookup::getItemForId
  */
 public function getItemForId(ItemId $itemId)
 {
     $item = $this->entityCache->fetch($itemId);
     if ($item === null) {
         $item = $this->itemLookup->getItemForId($itemId);
         if ($item !== null) {
             $this->entityCache->save($item);
         }
     }
     return $item;
 }
 /**
  * @see EntityDocumentLookup::getEntityDocumentsForIds
  */
 public function getEntityDocumentsForIds(array $entityIds)
 {
     $entities = array();
     $entityIdsToRetrieve = array();
     foreach ($entityIds as $entityId) {
         try {
             $entities[] = $this->entityCache->fetch($entityId);
         } catch (EntityNotFoundException $e) {
             $entityIdsToRetrieve[] = $entityId;
         }
     }
     $additionalEntities = array();
     if (!empty($entityIdsToRetrieve)) {
         $additionalEntities = $this->entityLookup->getEntityDocumentsForIds($entityIdsToRetrieve);
     }
     foreach ($additionalEntities as $entity) {
         $this->entityCache->save($entity);
     }
     return array_merge($entities, $additionalEntities);
 }
 /**
  * @see EntityDocumentLookup::getEntityDocumentsForIds
  */
 public function getEntityDocumentsForIds(array $entityIds)
 {
     $entities = [];
     $entityIdsToRetrieve = [];
     foreach ($entityIds as $entityId) {
         $entity = $this->entityCache->fetch($entityId);
         if ($entity === null) {
             $entityIdsToRetrieve[] = $entityId;
         } else {
             $entities[] = $entity;
         }
     }
     $additionalEntities = [];
     if (!empty($entityIdsToRetrieve)) {
         $additionalEntities = $this->entityLookup->getEntityDocumentsForIds($entityIdsToRetrieve);
     }
     foreach ($additionalEntities as $entity) {
         $this->entityCache->save($entity);
     }
     return array_merge($entities, $additionalEntities);
 }
 public function testFetchWithException()
 {
     $this->setExpectedException('Wikibase\\EntityStore\\EntityNotFoundException');
     $cache = new EntityDocumentCache(new ArrayCache());
     $cache->fetch(new ItemId('Q42'));
 }
 public function testFetchWithMiss()
 {
     $cache = new EntityDocumentCache(new ArrayCache());
     $this->assertNull($cache->fetch(new ItemId('Q42')));
 }