Admin_MiscController::scriptProxyAction PHP Метод

scriptProxyAction() публичный Метод

public scriptProxyAction ( )
    public function scriptProxyAction()
    {
        $this->disableViewAutoRender();
        $allowedFileTypes = ["js", "css"];
        $scripts = explode(",", $this->getParam("scripts"));
        $scriptPath = $this->getParam("scriptPath");
        $scriptsContent = "";
        foreach ($scripts as $script) {
            $filePath = PIMCORE_DOCUMENT_ROOT . $scriptPath . $script;
            if (is_file($filePath) && is_readable($filePath) && in_array(\Pimcore\File::getFileExtension($script), $allowedFileTypes)) {
                $scriptsContent .= file_get_contents($filePath);
            }
        }
        $fileExtension = \Pimcore\File::getFileExtension($scripts[0]);
        $contentType = "text/javascript";
        if ($fileExtension == "css") {
            $contentType = "text/css";
        }
        $lifetime = 86400;
        $this->getResponse()->setHeader("Cache-Control", "max-age=" . $lifetime, true);
        $this->getResponse()->setHeader("Pragma", "", true);
        $this->getResponse()->setHeader("Content-Type", $contentType, true);
        $this->getResponse()->setHeader("Expires", gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT", true);
        echo $scriptsContent;
    }