Lack of interest New ControllerHelper Request

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

xf_phantom

Well-known member
PHP:
'addOnOptions' => $this->_getAddOnModel()->getAddOnOptionsListIfAvailable(),
       'addOnSelected' => (isset($entry['addon_id']) ? $entry['addon_id'] : $addOnModel->getDefaultAddOnId())
is being used very often in admin controllers

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:cool:


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
This suggestion has been closed. Votes are no longer accepted.
Back
Top Bottom