当前位置: 首页>>代码示例>>PHP>>正文


PHP Pimcore\Config类代码示例

本文整理汇总了PHP中Pimcore\Config的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dispatchLoopShutdown

    /**
     *
     */
    public function dispatchLoopShutdown()
    {
        if (!Tool::isHtmlResponse($this->getResponse())) {
            return;
        }
        $siteKey = \Pimcore\Tool\Frontend::getSiteKey();
        $reportConfig = \Pimcore\Config::getReportConfig();
        if ($this->enabled && isset($reportConfig->tagmanager->sites->{$siteKey}->containerId)) {
            $containerId = $reportConfig->tagmanager->sites->{$siteKey}->containerId;
            if ($containerId) {
                $code = <<<CODE
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id={$containerId}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{$containerId}');</script>
<!-- End Google Tag Manager -->
CODE;
                $body = $this->getResponse()->getBody();
                // insert code after the opening <body> tag
                $body = preg_replace("@<body(>|.*?[^?]>)@", "<body\$1\n\n" . $code, $body);
                $this->getResponse()->setBody($body);
            }
        }
    }
开发者ID:jjpeters67,项目名称:pimcore,代码行数:31,代码来源:GoogleTagManager.php

示例2: init

 /**
  * @throws \Exception
  */
 public function init()
 {
     $conf = Config::getSystemConfig();
     if (!$conf->webservice->enabled) {
         throw new \Exception("Webservice API isn't enabled");
     }
     if (!$this->getParam("apikey") && $_COOKIE["pimcore_admin_sid"]) {
         $user = Authentication::authenticateSession();
         if (!$user instanceof User) {
             throw new \Exception("User is not valid");
         }
     } else {
         if (!$this->getParam("apikey")) {
             throw new \Exception("API key missing");
         } else {
             $apikey = $this->getParam("apikey");
             $userList = new User\Listing();
             $userList->setCondition("apiKey = ? AND type = ? AND active = 1", array($apikey, "user"));
             $users = $userList->load();
             if (!is_array($users) or count($users) !== 1) {
                 throw new \Exception("API key error.");
             }
             if (!$users[0]->getApiKey()) {
                 throw new \Exception("Couldn't get API key for user.");
             }
             $user = $users[0];
         }
     }
     \Zend_Registry::set("pimcore_admin_user", $user);
     parent::init();
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:34,代码来源:Webservice.php

示例3: config

 /**
  * @param array $config
  */
 public function config($config = [])
 {
     $settings = null;
     // check for an initial configuration template
     // used eg. by the demo installer
     $configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.template.php";
     if (file_exists($configTemplatePath)) {
         try {
             $configTemplate = new \Zend_Config(include $configTemplatePath);
             if ($configTemplate->general) {
                 // check if the template contains a valid configuration
                 $settings = $configTemplate->toArray();
                 // unset database configuration
                 unset($settings["database"]["params"]["host"]);
                 unset($settings["database"]["params"]["port"]);
             }
         } catch (\Exception $e) {
         }
     }
     // set default configuration if no template is present
     if (!$settings) {
         // write configuration file
         $settings = ["general" => ["timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"], "database" => ["adapter" => "Mysqli", "params" => ["username" => "root", "password" => "", "dbname" => ""]], "documents" => ["versions" => ["steps" => "10"], "default_controller" => "default", "default_action" => "default", "error_pages" => ["default" => "/"], "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "generatepreview" => "1"], "objects" => ["versions" => ["steps" => "10"]], "assets" => ["versions" => ["steps" => "10"]], "services" => [], "cache" => ["excludeCookie" => ""], "httpclient" => ["adapter" => "Zend_Http_Client_Adapter_Socket"]];
     }
     $settings = array_replace_recursive($settings, $config);
     // create initial /website/var folder structure
     // @TODO: should use values out of startup.php (Constants)
     $varFolders = ["areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"];
     foreach ($varFolders as $folder) {
         \Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder);
     }
     $configFile = \Pimcore\Config::locateConfigFile("system.php");
     File::putPhpFile($configFile, to_php_data_file_format($settings));
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:37,代码来源:Setup.php

示例4: preparePdfGeneration

 /**
  * @param $documentId
  * @param $config
  * @throws \Exception
  */
 public function preparePdfGeneration($documentId, $config)
 {
     $document = $this->getPrintDocument($documentId);
     if (Model\Tool\TmpStore::get($document->getLockKey())) {
         throw new \Exception("Process with given document alredy running.");
     }
     Model\Tool\TmpStore::add($document->getLockKey(), true);
     $jobConfig = new \stdClass();
     $jobConfig->documentId = $documentId;
     $jobConfig->config = $config;
     $this->saveJobConfigObjectFile($jobConfig);
     $this->updateStatus($documentId, 0, "prepare_pdf_generation");
     $args = ["-p " . $jobConfig->documentId];
     $env = \Pimcore\Config::getEnvironment();
     if ($env !== false) {
         $args[] = "--environment=" . $env;
     }
     $cmd = Tool\Console::getPhpCli() . " " . realpath(PIMCORE_PATH . DIRECTORY_SEPARATOR . "cli" . DIRECTORY_SEPARATOR . "console.php") . " web2print:pdf-creation " . implode(" ", $args);
     Logger::info($cmd);
     if (!$config['disableBackgroundExecution']) {
         Tool\Console::execInBackground($cmd, PIMCORE_LOG_DIRECTORY . DIRECTORY_SEPARATOR . "web2print-output.log");
     } else {
         Processor::getInstance()->startPdfGeneration($jobConfig->documentId);
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:30,代码来源:Processor.php

示例5: addLanguage

 public function addLanguage($languageToAdd)
 {
     // Check if language is not already added
     if (in_array($languageToAdd, Tool::getValidLanguages())) {
         $result = false;
     } else {
         // Read all the documents from the first language
         $availableLanguages = Tool::getValidLanguages();
         $firstLanguageDocument = \Pimcore\Model\Document::getByPath('/' . reset($availableLanguages));
         \Zend_Registry::set('SEI18N_add', 1);
         // Add the language main folder
         $document = Page::create(1, array('key' => $languageToAdd, "userOwner" => 1, "userModification" => 1, "published" => true, "controller" => 'default', "action" => 'go-to-first-child'));
         $document->setProperty('language', 'text', $languageToAdd);
         // Set the language to this folder and let it inherit to the child pages
         $document->setProperty('isLanguageRoot', 'text', 1, false, false);
         // Set as language root document
         $document->save();
         // Add Link to other languages
         $t = new Keys();
         $t->insert(array("document_id" => $document->getId(), "language" => $languageToAdd, "sourcePath" => $firstLanguageDocument->getFullPath()));
         // Lets add all the docs
         $this->addDocuments($firstLanguageDocument->getId(), $languageToAdd);
         \Zend_Registry::set('SEI18N_add', 0);
         $oldConfig = Config::getSystemConfig();
         $settings = $oldConfig->toArray();
         $languages = explode(',', $settings['general']['validLanguages']);
         $languages[] = $languageToAdd;
         $settings['general']['validLanguages'] = implode(',', $languages);
         $config = new \Zend_Config($settings, true);
         $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         $result = true;
     }
     return $result;
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:35,代码来源:Document.php

示例6: init

 public function init()
 {
     // Disable plugin if the allowed domain is not yet set
     $settingDomain = WebsiteSetting::getByName("subdomainAdmin");
     if (!is_object($settingDomain) || $settingDomain->getData() == "") {
         return;
     }
     // Create temporary request object - not available yet in front controller
     $currentUrl = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
     $request = new \Zend_Controller_Request_Http($currentUrl);
     // Disable main domain setting to allow admin access on another domain
     $conf = Config::getSystemConfig();
     $mainDomain = $conf->general->domain;
     if (Tool::isRequestToAdminBackend($request) && Tool::isDomainAllowedToAdminBackend($request)) {
         $confArr = $conf->toArray();
         $mainDomain = $confArr['general']['domain'];
         $confArr['general']['domain'] = "";
         Config::setSystemConfig(new \Zend_Config($confArr));
     }
     // Register plugin
     \Pimcore::getEventManager()->attach("system.startup", function ($event) use(&$mainDomain) {
         $front = \Zend_Controller_Front::getInstance();
         $frontControllerPlugin = new FrontControllerPlugin();
         $front->registerPlugin($frontControllerPlugin);
         // Restore main domain
         $conf = Config::getSystemConfig();
         $confArr = $conf->toArray();
         $confArr['general']['domain'] = $mainDomain;
         Config::setSystemConfig(new \Zend_Config($confArr));
     });
 }
开发者ID:shanky0110,项目名称:pimcore-plugin-subdomain-admin,代码行数:31,代码来源:Plugin.php

示例7: saveAction

 public function saveAction()
 {
     $this->checkPermission("system_settings");
     $values = \Zend_Json::decode($this->getParam("data"));
     $configFile = \Pimcore\Config::locateConfigFile("reports.php");
     File::put($configFile, to_php_data_file_format($values));
     $this->_helper->json(array("success" => true));
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:8,代码来源:SettingsController.php

示例8: getSiteConfig

 /**
  * @param null $site
  * @return bool
  */
 public static function getSiteConfig($site = null)
 {
     $siteKey = \Pimcore\Tool\Frontend::getSiteKey($site);
     if (Config::getReportConfig()->webmastertools->sites->{$siteKey}->verification) {
         return Config::getReportConfig()->webmastertools->sites->{$siteKey};
     }
     return false;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:12,代码来源:Webmastertools.php

示例9: _handleError

 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @throws mixed
  */
 protected function _handleError(\Zend_Controller_Request_Abstract $request)
 {
     // remove zend error handler
     $front = \Zend_Controller_Front::getInstance();
     $front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
     $response = $this->getResponse();
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         // get errorpage
         try {
             // enable error handler
             $front->setParam('noErrorHandler', false);
             $errorPath = Config::getSystemConfig()->documents->error_pages->default;
             if (Site::isSiteRequest()) {
                 $site = Site::getCurrentSite();
                 $errorPath = $site->getErrorDocument();
             }
             if (empty($errorPath)) {
                 $errorPath = "/";
             }
             $document = Document::getByPath($errorPath);
             if (!$document instanceof Document\Page) {
                 // default is home
                 $document = Document::getById(1);
             }
             if ($document instanceof Document\Page) {
                 $params = Tool::getRoutingDefaults();
                 if ($module = $document->getModule()) {
                     $params["module"] = $module;
                 }
                 if ($controller = $document->getController()) {
                     $params["controller"] = $controller;
                     $params["action"] = "index";
                 }
                 if ($action = $document->getAction()) {
                     $params["action"] = $action;
                 }
                 $this->setErrorHandler($params);
                 $request->setParam("document", $document);
                 \Zend_Registry::set("pimcore_error_document", $document);
                 // ensure that a viewRenderer exists, and is enabled
                 if (!\Zend_Controller_Action_HelperBroker::hasHelper("viewRenderer")) {
                     $viewRenderer = new \Pimcore\Controller\Action\Helper\ViewRenderer();
                     \Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
                 }
                 $viewRenderer = \Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
                 $viewRenderer->setNoRender(false);
                 if ($viewRenderer->view === null) {
                     $viewRenderer->initView(PIMCORE_WEBSITE_PATH . "/views");
                 }
             }
         } catch (\Exception $e) {
             \Logger::emergency("error page not found");
         }
     }
     // call default ZF error handler
     parent::_handleError($request);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:61,代码来源:ErrorHandler.php

示例10: setSystemInstanceIdentifier

 public function setSystemInstanceIdentifier()
 {
     $instanceIdentifier = \Pimcore\Config::getSystemConfig()->general->instanceIdentifier;
     if (!$instanceIdentifier) {
         throw new \Exception("No instance identifier set in system config!");
     }
     $this->setInstanceIdentifier($instanceIdentifier);
     return $this;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:9,代码来源:UUID.php

示例11: dispatchLoopShutdown

    /**
     *
     */
    public function dispatchLoopShutdown()
    {
        $config = \Pimcore\Config::getSystemConfig();
        if (!$config->general->show_cookie_notice || !Tool::useFrontendOutputFilters($this->getRequest()) || !Tool::isHtmlResponse($this->getResponse())) {
            return;
        }
        $template = file_get_contents(__DIR__ . "/EuCookieLawNotice/template.html");
        # cleanup code
        $template = preg_replace('/[\\r\\n\\t]+/', ' ', $template);
        #remove new lines, spaces, tabs
        $template = preg_replace('/>[\\s]+</', '><', $template);
        #remove new lines, spaces, tabs
        $template = preg_replace('/[\\s]+/', ' ', $template);
        #remove new lines, spaces, tabs
        $translations = $this->getTranslations();
        foreach ($translations as $key => &$value) {
            $value = htmlentities($value, ENT_COMPAT, "UTF-8");
            $template = str_replace("%" . $key . "%", $value, $template);
        }
        $linkContent = "";
        if (array_key_exists("linkTarget", $translations)) {
            $linkContent = '<a href="' . $translations["linkTarget"] . '" data-content="' . $translations["linkText"] . '"></a>';
        }
        $template = str_replace("%link%", $linkContent, $template);
        $templateCode = \Zend_Json::encode($template);
        $code = '
            <script>
                (function () {
                    var ls = window["localStorage"];
                    if(ls && !ls.getItem("pc-cookie-accepted")) {

                        var code = ' . $templateCode . ';
                        var ci = window.setInterval(function () {
                            if(document.body) {
                                clearInterval(ci);
                                document.body.insertAdjacentHTML("beforeend", code);

                                document.getElementById("pc-button").onclick = function () {
                                    document.getElementById("pc-cookie-notice").style.display = "none";
                                    ls.setItem("pc-cookie-accepted", "true");
                                };
                            }
                        }, 100);
                    }
                })();
            </script>
        ';
        $body = $this->getResponse()->getBody();
        // search for the end <head> tag, and insert the google analytics code before
        // this method is much faster than using simple_html_dom and uses less memory
        $headEndPosition = stripos($body, "</head>");
        if ($headEndPosition !== false) {
            $body = substr_replace($body, $code . "</head>", $headEndPosition, 7);
        }
        $this->getResponse()->setBody($body);
    }
开发者ID:sfie,项目名称:pimcore,代码行数:59,代码来源:EuCookieLawNotice.php

示例12: adminerAction

 public function adminerAction()
 {
     $conf = \Pimcore\Config::getSystemConfig()->database->params;
     if (empty($_SERVER["QUERY_STRING"])) {
         $this->redirect("/admin/external_adminer/adminer/?username=" . $conf->username . "&db=" . $conf->dbname);
         exit;
     }
     chdir($this->adminerHome . "adminer");
     include $this->adminerHome . "adminer/index.php";
     $this->removeViewRenderer();
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:11,代码来源:AdminerController.php

示例13: getInstance

 /**
  * @return PdfReactor8|WkHtmlToPdf
  * @throws \Exception
  */
 public static function getInstance()
 {
     $config = Config::getWeb2PrintConfig();
     if ($config->generalTool == "pdfreactor") {
         return new PdfReactor8();
     } elseif ($config->generalTool == "wkhtmltopdf") {
         return new WkHtmlToPdf();
     } else {
         throw new \Exception("Invalid Configuation - " . $config->generalTool);
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:15,代码来源:Processor.php

示例14: getSiteConfig

 /**
  * @param null $site
  * @return bool
  */
 public static function getSiteConfig($site = null)
 {
     $siteKey = \Pimcore\Tool\Frontend::getSiteKey($site);
     $config = Config::getReportConfig();
     if (!$config->analytics) {
         return false;
     }
     if ($config->analytics->sites->{$siteKey}) {
         return Config::getReportConfig()->analytics->sites->{$siteKey};
     }
     return false;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:16,代码来源:Analytics.php

示例15: getErrorDocument

 private function getErrorDocument()
 {
     $config = Config::getSystemConfig();
     $errorDocPath = $config->documents->error_pages->default;
     if (Site::isSiteRequest()) {
         $site = Site::getCurrentSite();
         $errorDocPath = $site->getErrorDocument();
     }
     $errorDoc = Document::getByPath($errorDocPath);
     \Zend_Registry::set("pimcore_error_document", $errorDoc);
     return $errorDoc;
 }
开发者ID:shanky0110,项目名称:pimcore-plugin-subdomain-admin,代码行数:12,代码来源:FrontControllerPlugin.php


注:本文中的Pimcore\Config类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。