<?php
/**
 * Class to maintain actions for node administration
 */
abstract class NodeAction extends CAction
{
    /** @var Node */
    public $node = null;
    /** @var INodeType */
    public $nodeType = null;

    /** @var string */
    public $viewAlias;

    public function init()
    {
        $this->nodeType = NodeTypeHelper::getNodeType($this->node->data_type);
        if (!isset($this->viewAlias))
            throw new CException('View alias must be set');
        else {
            $this->viewAlias = 'admin.types.' . $this->node->data_type . '.views.' . $this->viewAlias;
        }
    }

    public function resolveView($view)
    {
        return $this->viewAlias . '.' . $view;
    }
}
