Alias for a special property

From semantic-mediawiki.org
Fragment of a discussion from Help talk:Hooks

> DIProperty::registerPropertyAlias ('_SUBP', 'Подчинённое свойству');

DIProperty::registerPropertyAlias is deprecated, see [0] (object registration and entity representation are two distinct responsibilities)

> Unfortunately, now it causes a fatal error due to the fact that $smwgContLang is not initialised yet.

Using direct object registration in LocalSettings.php is discouraged as an object might rely on an internal dependency that have not yet been loaded by the time LocalSettings is accessed (as with the Language, or NS constants etc.).

> Looks like I should use a hook. But which hook should it be? The SMW hooks that look useful are listed as deprecated.

'SMW::Property::initProperties', see [1]

$GLOBALS['wgHooks']['SMW::Property::initProperties'][] = function () {
  \SMW\PropertyRegistry::getInstance()->registerPropertyAlias( $id, $label );
};

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/includes/dataitems/SMW_DI_Property.php#L379

[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/PropertyRegistry.php#L334

13:56, 4 May 2015

Thank you, looks like it works.

14:12, 4 May 2015