Lucas_Werkmeister_WMDE added a comment.

  > “Service” probably means something like “an interface, a class implementing 
it which gets other ‘services’ as constructor parameters, and a getter on 
`WikibaseClient`”.
  
  I looked a bit into this. What I had in mind was the standard lazily 
initialized service pattern that you see all over `WikibaseClient` and 
`WikibaseRepo`:
  
    private $dataBridgeReferenceFormatter = null;
    
    public function getDataBridgeReferenceFormatter() {
        if ( $this->dataBridgeReferenceFormatter === null ) {
                 $this->dataBridgeReferenceFormatter = new 
DataBridgeReferenceFormatter( ... );
        }
        return $this->dataBridgeReferenceFormatter;
    }
  
  But I don’t think this works out directly – the 
`DataBridgeReferenceFormatter` needs a `SnakFormatter` and a `MessageLocalizer` 
injected, and both of these depend on a request context. I think the usual 
solution to that in Wikibase is to make the lazily initialized service a 
//factory// (e. g. `WikibaseClient::getSnakFormatterFactory()`, 
`WikibaseClient::getDataAccessSnakFormatterFactory()`), and that factory then 
has a method to create a new instance of the actual service given the request 
context (language etc.). I think that’s a good solution for our case here as 
well – we can even call the factory a more general `ReferenceFormatterFactory`, 
for now only with a method `newDataBridgeReferenceFormatter()` but anticipating 
that the same factory could in future create formatters for other styles as 
well (thus avoiding cluttering `WikibaseClient` itself with one field+getter 
per style).

TASK DETAIL
  https://phabricator.wikimedia.org/T247412

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Aklapper, Alter-paule, Beast1978, Un1tY, 
Sarai-WMDE, Hook696, Daryl-TTMG, RomaAmorRoma, E.S.A-Sheild, darthmon_wmde, 
Meekrab2012, joker88john, Michael, CucyNoiD, Nandana, NebulousIris, Gaboe420, 
Versusxo, Majesticalreaper22, Giuliamocci, Adrian1985, Cpaulf30, Lahi, Gq86, 
Af420, Darkminds3113, Bsandipan, Lordiis, GoranSMilovanovic, Adik2382, 
Th3d3v1ls, Ramalepe, Liugev6, QZanden, LawExplorer, WSH1906, Lewizho99, 
Maathavan, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, 
Lydia_Pintscher, Mbch331
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to