I am building a plugin that's uses an enum for custom statuses. The statuses are integrated within my plugin with the exception of changing the status in my template code.
pluginname/enums/PluginStatus.php
<?php
namespace Craft;
class PluginNameStatus
{
const Approved = 'approved';
const Denied = 'denied';
const Pending = 'pending';
}
What is the best method to grab the enum values and display those in a select field for my edit template? All of my templates are rendered via controller actions so I am thinking that assigning the enums to an array and passing to the templates as $variables might be the most practical method.
pluginname/controllers/PluginNameController.php
<?php
namespace Craft;
class PluginNameController extends BaseController
{
public function actionShowIndex()
{
$variables['customStatuses'] = array(
PluginStatus::Approved => 'Approved',
PluginStatus::Denied => 'Denied',
PluginStatus::Pending => 'Pending',
),
$this->renderTemplate('pluginname/_edit', $variables);
}
}