public function process()
    {
        $ajax = [];

        /* @var $cmd \Core\Ajax\Commands\AjaxCommandInterface */
        foreach ($this->commands as $cmd) {

            // Create alert on missing target when type is in need-target list
            if ($cmd instanceof DomCommandInterface && empty($cmd->getSelector())) {
                $cmd->setSelector('body');
            }

            // Create funcion/arguments array
            $fa = [
                'f' => $cmd->getFunction(),
                'a' => $cmd->getArgs()
            ];

            if ($cmd instanceof DomCommandInterface) {
                $ajax['dom'][$cmd->getSelector()][] = $fa;
            }
            else {
                $ajax['act'][] = $fa;
            }
        }

        // Return JSON encoded ajax command stack
        return !empty($ajax) ? json_encode($ajax) : '';
    }