formatActionName example


    public function getActionMethod(Enlight_Controller_Request_Request $request)
    {
        $action = $request->getActionName();
        if (empty($action)) {
            $action = $this->getDefaultAction();
            $request->setActionName($action);
        }
        $formatted = $this->formatActionName($action);

        return strtolower($formatted[0]) . substr($formatted, 1) . 'Action';
    }

    /** * Returns the full path of the controller name by the given request class. * To generate the full controller path the module and controller name must be set in the given request object. * The module and controller path is imploded by '_' * * @return string */
    

    public function getTemplateName()
    {
        $request = $this->Action()->Request();
        $moduleName = $this->Front()->Dispatcher()->formatModuleName($request->getModuleName());
        $controllerName = $this->Front()->Dispatcher()->formatControllerName($request->getControllerName());
        $actionName = $this->Front()->Dispatcher()->formatActionName($request->getActionName());

        $parts = [$moduleName$controllerName$actionName];
        foreach ($parts as &$part) {
            $part = (string) preg_replace('#[A-Z]#', '_$0', $part);
            $part = trim($part, '_');
            $part = strtolower($part);
        }

        $templateName = implode(DIRECTORY_SEPARATOR, $parts) . '.tpl';

        return $templateName;
    }
Home | Imprint | This part of the site doesn't use cookies.