xf_phantom
Well-known member
PHP:
'addOnOptions' => $this->_getAddOnModel()->getAddOnOptionsListIfAvailable(),
'addOnSelected' => (isset($entry['addon_id']) ? $entry['addon_id'] : $addOnModel->getDefaultAddOnId())
I would request to move this to a own controllerhelper. Then it would become reusable and we would need less code if we would want to use it in our own controllers
e.g. something like following code would be enough
PHP:
<?php
class Dev_ControllerHelper_AddOn extends XenForo_ControllerHelper_Abstract{
/**
* @param null $selectedAddonId
* @param bool $includeCustomOptions
* @param bool $includeXenForoOptions
* @return array
*/
public function getDefaultViewParams($selectedAddonId = null, $includeCustomOptions = true, $includeXenForoOptions = true){
/** @var XenForo_Model_AddOn $addOnModel */
$addOnModel = $this->_controller->getModelFromCache('XenForo_Model_AddOn');
$viewParams = array(
'addOnOptions' => $addOnModel->getAddOnOptionsListIfAvailable($includeCustomOptions,$includeXenForoOptions),
'addOnSelected' => (isset($selectedAddonId) ? $selectedAddonId : $addOnModel->getDefaultAddOnId())
);
return $viewParams;
}
}
// usage in controller:
$viewParams += $this->getHelper('Dev_ControllerHelper_AddOn')->getDefaultViewParams();
$viewParams += $this->getHelper('Dev_ControllerHelper_AddOn')->getDefaultViewParams($template['addon_id']);
Last edited:
Upvote
0