Discuss Hooks
- [View source↑]
- [History↑]
Contents
Thread title | Replies | Last modified |
---|---|---|
Correct way to register "SMW::Store::AfterDataUpdateComplete" hook in extension.json | 3 | 10:10, 1 May 2018 |
Alias for a special property | 2 | 13:12, 4 May 2015 |
Correct way to register "SMW::Store::AfterDataUpdateComplete" hook in extension.json
I tried to register "SMW::Store::AfterDataUpdateComplete" in my extention.json but it seems not to be working.
"Hooks": {
"SMW::SQLStore::AfterDataUpdateComplete": [
"SomeExtensionNs\\Hook::onAfterDataUpdateComplete"
]
},
Could it be that there some typo?
It works when i register the Hook the old way like:
global $wgHooks;
$wgHooks['SMW::SQLStore::AfterDataUpdateComplete'][] = 'SomeExtenionNs::onAfterDataUpdateComplete'
@mwjames, many thanks for looking into this. After reading your reply, I saw that I meant "I tried to register "SMW::SQLStore::AfterDataUpdateComplete" in my extention.json but it seems to be not working." Did I get you right, that it should be possible to register "SMW::SQLStore::AfterDataUpdateComplete" via extension.json? Maybe I did something wrong with namespaces:
"Hooks": { "SMW::SQLStore::AfterDataUpdateComplete": [ "SomeExtensionNs\\Hook::onAfterDataUpdateComplete" ] },
I need to add an alias to a special property (redirect won't work because of the collation).
Ufter the last SMW update the code to do it in LocalSettings.php
stopped working again.
The best I could think of is:
use SMW\DIProperty;
DIProperty::registerPropertyAlias ('_SUBP', 'Подчинённое свойству');
Unfortunately, now it causes a fatal error due to the fact that $smwgContLang
is not initialised yet.
Looks like I should use a hook. But which hook should it be? The SMW hooks that look useful are listed as deprecated.
> 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 ); };
[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/PropertyRegistry.php#L334