コード例 #1
0
 public function testHasEntityBeenAccessed()
 {
     $lookup = new RestrictedEntityLookup($this->getEntityLookup(), 200);
     $lookup->getEntity(new ItemId('Q2'));
     $this->assertTrue($lookup->entityHasBeenAccessed(new ItemId('Q2')));
     $this->assertFalse($lookup->entityHasBeenAccessed(new ItemId('Q42')));
 }
コード例 #2
0
 /**
  * Gets the entity and increments the expensive parser function count.
  *
  * @param Parser $parser
  * @param string $entityIdString
  *
  * @return EntityId|null
  */
 private function getEntityIdFromString(Parser $parser, $entityIdString)
 {
     try {
         $entityId = $this->entityIdParser->parse($entityIdString);
     } catch (EntityIdParsingException $ex) {
         // Just ignore this
         return null;
     }
     // Getting a foreign item is expensive (unless we already loaded it and it's cached)
     if (!$this->restrictedEntityLookup->entityHasBeenAccessed($entityId)) {
         $parser->incrementExpensiveFunctionCount();
     }
     return $entityId;
 }
 /**
  * @param Parser $parser
  * @param ParserOutput $output
  *
  * @return bool
  */
 public function doParserLimitReportPrepare(Parser $parser, ParserOutput $output)
 {
     $output->setLimitReportData('EntityAccessCount', $this->restrictedEntityLookup->getEntityAccessCount());
     return true;
 }