Esempio n. 1
0
 public function storeMetaInDb($data)
 {
     $errors = [];
     foreach ($data as $title => $meta) {
         $errors[$title] = 'OK';
         try {
             $model = ArticleMetadataModel::newFromString($title);
             foreach ($meta as $field => $val) {
                 $model->setField($field, $val);
             }
             $model->save(true);
         } catch (TitleNotFoundException $e) {
             $errors[$title] = 'Title not found';
         } catch (FieldNotArrayException $e) {
             $errors[$title] = 'Field should not be an array: ' . $e->getMessage();
         } catch (NotValidPOIMetadataFieldException $e) {
             $errors[$title] = 'Unknown field: ' . $e->getMessage();
         }
     }
     return $errors;
 }
 /**
  * @group UsingDB
  * @expectedException TitleNotFoundException
  * @covers ArticleMetadataModel::newFromString
  */
 public function testIndexNotFound()
 {
     ArticleMetadataModel::newFromString("bnvghcfrt6t7y8uhgftdr567");
 }
Esempio n. 3
0
 protected function getPOIMetadata()
 {
     $service = $this->getService();
     $extensionEnabled = $service->getGlobal('EnablePOIExt');
     if ($extensionEnabled) {
         $articleMetadata = new \ArticleMetadataModel($this->currentPageId, true);
         $solrMapping = $articleMetadata->getSolrMapping();
         $metadata = $articleMetadata->getMetadata();
         $output = [];
         foreach ($metadata as $field => $value) {
             if (isset($solrMapping[$field])) {
                 $output[$solrMapping[$field]] = $value;
             }
         }
         return $output;
     }
     return null;
 }