<?php

class ReviewsRootType implements INodeType
{

    public function getName()
    {
        return 'Отзывы';
    }

    public function isRootNode()
    {
        return true;
    }

    public function getNestedTypes()
    {
        return array(
        );
    }


    public function getActions()
    {
        return array(
            'editReviewsRoot',
            'review',
        );
    }

    public function actionLabels(){
        return array(
            'editReviewsRoot'=>'Данные страницы',
            'review'=>'Отзывы',
        );
    }

    public function createAction($name, $controller, $id = null)
    {
        if($id===null)$id = $name;
        require __DIR__ . '/actions/' . ucfirst($name) . 'Action.php';
        $actionClass = ucfirst($name) . 'Action';
        return new $actionClass($controller, $id);
    }

    /**
     * @return string
     */
    public function getDefaultAction()
    {
        return 'editReviewsRoot';
    }


    public function deleteData($id)
    {
        $model = ReviewsRoot::model()->findByPk($id);
        if($model != null) $model->delete();
    }
}
