예제 #1
0
 public function getDetails()
 {
     $pageid = $this->getRequiredParam('pageid');
     $title = Title::newFromID($pageid);
     $data = PortableInfoboxDataService::newFromTitle($title)->getData();
     $output = isset($data) && is_array($data) ? array_map(function ($infobox) {
         return isset($infobox['data']) ? $infobox['data'] : $infobox;
     }, $data) : [];
     $this->setResponseData(['items' => $output]);
 }
 public static function onImageServingCollectImages(&$imageNamesArray, $articleTitle)
 {
     if ($articleTitle) {
         $infoboxImages = PortableInfoboxDataService::newFromTitle($articleTitle)->getImages();
         if (!empty($infoboxImages)) {
             $imageNamesArray = array_merge($infoboxImages, (array) $imageNamesArray);
         }
     }
     return true;
 }
 public function testTitleNullConstructor()
 {
     $service = PortableInfoboxDataService::newFromTitle(null);
     $result = $service->getData();
     $this->assertEquals([], $result);
 }
 public static function titleHasPortableInfobox(Title $title)
 {
     $portableData = PortableInfoboxDataService::newFromTitle($title)->getData();
     return !empty($portableData);
 }