<?php namespace Eae\Backoffice\Generic\Actions;

use Eae\Exception\InvalidConfigurationException;
use Illuminate\Support\Contracts\JsonableInterface;
use Illuminate\Support\Contracts\ArrayableInterface;
use Lang;

abstract class BaseAction implements ArrayableInterface, JsonableInterface{
    const TYPE_GRID                 = "grid";
    const TYPE_ROW                  = "row";
    
    protected $type                 = "";
    protected $cssClass             = "";
    protected $actionType           = "";
    protected $languageKey          = "";
    protected $permission           = false;
    protected $btnFunction          = false;

    public function __construct(){
         
    }
    
    public function getPermission(){
        return $this->permission;    
    }
    
    public function getType(){
        return $this->type;    
    }
    
    public function setCssClass($cssClass){
        $this->cssClass = $cssClass;    
    }
    
    public function getCssClass(){
        return $this->cssClass;    
    }
    
    public function getLabel(){
        return Lang::get($this->languageKey);        
    }
    
    public function setActionType($actionType){
        $this->actionType = $actionType;    
    }
    
    public function getActionType(){
        return $this->actionType;    
    }
    
    public function setBtnFunction($btnFunction){
        $this->btnFunction = $btnFunction;    
    }
    
    public function getBtnFunction(){
        return $this->btnFunction;    
    }

    public function toArray(){
        return array(
            "type"          => $this->getType(),
            "cssClass"      => $this->getCssClass(),
            "actionType"    => $this->getActionType(),
            "label"         => $this->getLabel(),
            "btnFunction"   => $this->getBtnFunction()
        );    
    }
    
    public function toJson($options = 0){
        return json_encode($this->toArray(), $options);   
    }
  
}
  

