diff --git "a/include/class-mw\\WikibaseSite.php" "b/include/class-mw\\WikibaseSite.php" index 9ec59b6..2cee77c 100644 --- "a/include/class-mw\\WikibaseSite.php" +++ "b/include/class-mw\\WikibaseSite.php" @@ -1,108 +1,108 @@ . # MediaWiki namespace mw; /** * A site with wikibase enabled */ class WikibaseSite extends Site { /** * Fetch a single Wikidata entity using the wbgetentities API * * See: * https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities * * @param $entity_id string Entity Q-ID * @param $data array Additional data such as [ 'props' => '..' ] * Some available props: * aliases, claims, datatype, descriptions, info, labels, sitelinks, sitelinks/urls * @return wb\DataModel */ public function fetchSingleEntity( $entity_id, $data = [] ) { $data = array_replace( [ 'action' => 'wbgetentities', 'ids' => $entity_id, ], $data ); $entity = $this->fetch( $data ); if( ! isset( $entity->entities->{ $entity_id } ) ) { - throw new Exception( "$wikidata_item does not exist" ); + throw new Exception( "$entity_id does not exist" ); } return $this->createDataModelFromObject( $entity->entities->{ $entity_id } ); } /** * Edit a Wikidata entity using the wbeditentity API * * You do not need to send the CSRF 'token' and the 'action' parameters. * * See: * https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity * * @param $data array API data request (with some extensions) * Allowed extensions: * summary.pre Add something before the summary * summary.post Add something after the summary * @return mixed */ public function editEntity( $data = [] ) { // extends the API arguments adding a 'summary.pre' argument if( isset( $data[ 'summary.pre' ] ) ) { $data[ 'summary' ] = $data[ 'summary.pre' ] . $data[ 'summary' ]; unset( $data[ 'summary.pre' ] ); } // extends the API arguments adding a 'summary.post' argument if( isset( $data[ 'summary.post' ] ) ) { $data[ 'summary' ] .= $data[ 'summary.post' ]; unset( $data[ 'summary.post' ] ); } return $this->post( array_replace( [ 'action' => 'wbeditentity', 'token' => $this->getToken( \mw\Tokens::CSRF ), ], $data ) ); } /** * Create an empty Wikibase data model related to this site * * @param $entity_id string Entity Q-ID * @return DataModel */ public function createDataModel( $entity_id = null ) { return new \wb\DataModel( $this, $entity_id ); } /** * Create an empty Wikibase data model related to this site * * @param $data object Single Entity object retrieved from wbgetentities API * @return DataModel */ public function createDataModelFromObject( $data ) { $id = $data->id; return \wb\DataModel::createFromObject( $data, $this, $id ); } }