Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | $omegaWikiAttributes; // It would be even better if this was |
37 | 37 | // passed to objects explicitly |
38 | 38 | // but one step at a time... |
39 | | - $omegaWikiAttributes= new OmegaWikiAttributes($viewInformation); |
| 39 | + $omegaWikiAttributes= OmegaWikiAttributes::getInstance($viewInformation); |
40 | 40 | initializeOmegaWikiAttributesOld($viewInformation); //backward compatibility, will be removed. |
41 | 41 | } |
42 | 42 | |
— | — | @@ -356,6 +356,20 @@ |
357 | 357 | |
358 | 358 | |
359 | 359 | class OmegaWikiAttributes { |
| 360 | + |
| 361 | + /** pseudo-Singleton, if viewinformation changes, will construct new instance*/ |
| 362 | + static function getInstance(ViewInformation $viewInformation=null) { |
| 363 | + static $instance=array(); |
| 364 | + if (!is_null($viewInformation)) { |
| 365 | + if (!array_key_exists($viewInformation->hashCode(), $instance)) { |
| 366 | + $instance["last"] = new OmegaWikiAttributes($viewInformation); |
| 367 | + $instance[$viewInformation->hashCode()] = $instance["last"]; |
| 368 | + } |
| 369 | + } |
| 370 | + |
| 371 | + return $instance["last"]; |
| 372 | + } |
| 373 | + |
360 | 374 | protected $attributes = array(); |
361 | 375 | |
362 | 376 | function __construct(ViewInformation $viewInformation) { |