shqawe
Member
I'm trying to extend AbstractOption class to render thread_prefix in my addon options and this is my code:
but i got this error:
and when i change the extend to this
i got this error:
and line 12 in Prefix.php is this
can someone help me in this issue?
PHP:
class Prefix extends XFCP_AbstractOption
{
public static function renderSelect(\XF\Entity\Option $option, array $htmlParams)
{
$data = self::getSelectData($option, $htmlParams);
return self::getTemplater()->formSelectRow(
$data['controlOptions'], $data['choices'], $data['rowOptions']
);
}
protected static function getSelectData(\XF\Entity\Option $option, array $htmlParams)
{
/** @var \XF\Repository\AbstractPrefix $prefixRepo */
$prefixRepo = \XF::repository('XF:AbstractPrefix');
$choices = $prefixRepo->getClassIdentifier()->getPrefixListData();
$choices = array_map(function($v) {
$v['label'] = \XF::escapeString($v['label']);
return $v;
}, $choices);
return [
'choices' => $choices,
'controlOptions' => self::getControlOptions($option, $htmlParams),
'rowOptions' => self::getRowOptions($option, $htmlParams)
];
}
}
but i got this error:
PHP:
XF\Option\XFCP_AbstractOption' not found
and when i change the extend to this
PHP:
class Prefix extends \XF\Option\AbstractOption
i got this error:
Code:
An exception occurred: [Error] Cannot instantiate abstract class XF\Repository\AbstractPrefix in src\XF\Mvc\Entity\Manager.php on line 261
XF\Mvc\Entity\Manager->getRepository() in src/XF/App.php at line 2585
XF\App->repository() in src/XF.php at line 671
XF::repository() in src/addons/myAddons/XF/Option/Prefix.php at line 23
myAddons\XF\Option\Prefix::getSelectData() in src/addons/myAddons/XF/Option/Prefix.php at line 12
myAddons\XF\Option\Prefix::renderSelect()
call_user_func() in src/XF/Entity/Option.php at line 76
XF\Entity\Option->renderDisplayCallback()
call_user_func_array() in src/XF/Template/Templater.php at line 999
XF\Template\Templater->method() in internal_data/code_cache/templates/l2/s0/admin/option_macros.php at line 196
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 701
XF\Template\Templater->callMacro() in internal_data/code_cache/templates/l2/s0/admin/option_macros.php at line 480
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 701
XF\Template\Templater->callMacro() in internal_data/code_cache/templates/l2/s0/admin/option_list.php at line 79
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 1315
XF\Template\Templater->renderTemplate() in src/XF/Template/Template.php at line 24
XF\Template\Template->render() in src/XF/Mvc/Renderer/Html.php at line 48
XF\Mvc\Renderer\Html->renderView() in src/XF/Mvc/Dispatcher.php at line 418
XF\Mvc\Dispatcher->renderView() in src/XF/Mvc/Dispatcher.php at line 400
XF\Mvc\Dispatcher->renderReply() in src/XF/Mvc/Dispatcher.php at line 360
XF\Mvc\Dispatcher->render() in src/XF/Mvc/Dispatcher.php at line 53
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2178
XF\App->run() in src/XF.php at line 390
XF::runApp() in admin.php at line 13
and line 12 in Prefix.php is this
$data = self::getSelectData($option, $htmlParams);
can someone help me in this issue?