本文整理汇总了PHP中Pimcore\Config::getSystemConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getSystemConfig方法的具体用法?PHP Config::getSystemConfig怎么用?PHP Config::getSystemConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Config
的用法示例。
在下文中一共展示了Config::getSystemConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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();
}
示例3: 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));
});
}
示例4: _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);
}
示例5: 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;
}
示例6: 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);
}
示例7: getExecutable
/**
* @param $name
* @param bool $throwException
* @return bool|mixed|string
* @throws \Exception
*/
public static function getExecutable($name, $throwException = false)
{
if (isset(self::$executableCache[$name])) {
return self::$executableCache[$name];
}
$pathVariable = Config::getSystemConfig()->general->path_variable;
$paths = [];
if ($pathVariable) {
$paths = explode(":", $pathVariable);
}
array_unshift($paths, "");
// allow custom setup routines for certain programs
$customSetupMethod = "setup" . ucfirst($name);
if (method_exists(__CLASS__, $customSetupMethod)) {
self::$customSetupMethod();
}
// allow custom check routines for certain programs
$customCheckMethod = "check" . ucfirst($name);
if (!method_exists(__CLASS__, $customCheckMethod)) {
$customCheckMethod = "checkDummy";
}
foreach ($paths as $path) {
foreach (["--help", "-h", "-help"] as $option) {
try {
$path = rtrim($path, "/\\ ");
if ($path) {
$executablePath = $path . DIRECTORY_SEPARATOR . $name;
} else {
$executablePath = $name;
}
$process = new Process($executablePath . " " . $option);
$process->run();
if ($process->isSuccessful() || self::$customCheckMethod($process)) {
if (empty($path) && self::getSystemEnvironment() == "unix") {
// get the full qualified path, seems to solve a lot of problems :)
// if not using the full path, timeout, nohup and nice will fail
$fullQualifiedPath = shell_exec("which " . $executablePath);
$fullQualifiedPath = trim($fullQualifiedPath);
if ($fullQualifiedPath) {
$executablePath = $fullQualifiedPath;
}
}
self::$executableCache[$name] = $executablePath;
return $executablePath;
}
} catch (\Exception $e) {
}
}
}
self::$executableCache[$name] = false;
if ($throwException) {
throw new \Exception("No '{$name}' executable found, please install the application or add it to the PATH (in system settings or to your PATH environment variable");
}
return false;
}
示例8: 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();
}
示例9: 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;
}
示例10: routeStartup
/**
* @param \Zend_Controller_Request_Abstract $request
* @return bool|void
*/
public function routeStartup(\Zend_Controller_Request_Abstract $request)
{
$this->conf = \Pimcore\Config::getSystemConfig();
if ($request->getParam('disable_less_compiler') || $_COOKIE["disable_less_compiler"]) {
return $this->disable();
}
if (!$this->conf->outputfilters) {
return $this->disable();
}
if (!$this->conf->outputfilters->less) {
return $this->disable();
}
}
示例11: getConnection
/**
* @param bool $raw
* @param bool $writeOnly
* @return Wrapper|\Zend_Db_Adapter_Abstract
* @throws \Exception
* @throws \Zend_Db_Profiler_Exception
*/
public static function getConnection($raw = false, $writeOnly = false)
{
// just return the wrapper (for compatibility reasons)
// the wrapper itself get's then the connection using $raw = true
if (!$raw) {
return new Wrapper();
}
$charset = "UTF8";
// explicit set charset for connection (to the adapter)
$config = Config::getSystemConfig()->database->toArray();
// write only handling
if ($writeOnly && isset($config["writeOnly"])) {
// overwrite params with write only configuration
$config["params"] = $config["writeOnly"]["params"];
} else {
if ($writeOnly) {
throw new \Exception("writeOnly connection is requested but not configured");
}
}
$config["params"]["charset"] = $charset;
try {
$db = \Zend_Db::factory($config["adapter"], $config["params"]);
$db->query("SET NAMES " . $charset);
} catch (\Exception $e) {
\Logger::emerg($e);
\Pimcore\Tool::exitWithError("Database Error! See debug.log for details");
}
// try to set innodb as default storage-engine
try {
$db->query("SET storage_engine=InnoDB;");
} catch (\Exception $e) {
\Logger::warn($e);
}
// try to set mysql mode
try {
$db->query("SET sql_mode = '';");
} catch (\Exception $e) {
\Logger::warn($e);
}
$connectionId = $db->fetchOne("SELECT CONNECTION_ID()");
// enable the db-profiler if the devmode is on and there is no custom profiler set (eg. in system.xml)
if (PIMCORE_DEVMODE && !$db->getProfiler()->getEnabled() || array_key_exists("pimcore_log", $_REQUEST) && \Pimcore::inDebugMode()) {
$profiler = new \Pimcore\Db\Profiler('All DB Queries');
$profiler->setEnabled(true);
$profiler->setConnectionId($connectionId);
$db->setProfiler($profiler);
}
\Logger::debug(get_class($db) . ": Successfully established connection to MySQL-Server, Process-ID: " . $connectionId);
return $db;
}
示例12: getInstance
public static function getInstance()
{
if (!self::$instance) {
if (\Pimcore\Tool::classExists("\\Elements\\Logging\\Log")) {
$logger = new \Elements\Logging\Log();
$logger->addWriter(new \Elements\Logging\Writer\LogWriterDb(\Zend_Log::DEBUG));
$logger->addWriter(new \Zend_Log_Writer_Stream(PIMCORE_WEBSITE_PATH . "/var/log/trustedshop.log"));
$systemConfig = \Pimcore\Config::getSystemConfig();
$debugAddresses = explode(',', $systemConfig->email->debug->emailaddresses);
$logger->addWriter(new \Elements\Logging\Writer\LogWriterMail($debugAddresses, "TrustedShop-Importer", "", \Zend_Log::ERR));
self::$instance = $logger;
}
}
return self::$instance;
}
示例13: getByKeyLocalized
/**
* @param $id
* @param bool $create
* @param bool $returnIdIfEmpty
* @param null $language
* @return array
* @throws \Exception
* @throws \Zend_Exception
*/
public static function getByKeyLocalized($id, $create = false, $returnIdIfEmpty = false, $language = null)
{
if ($user = Tool\Admin::getCurrentUser()) {
$language = $user->getLanguage();
} elseif ($user = Tool\Authentication::authenticateSession()) {
$language = $user->getLanguage();
} elseif (\Zend_Registry::isRegistered("Zend_Locale")) {
$language = (string) \Zend_Registry::get("Zend_Locale");
}
if (!in_array($language, Tool\Admin::getLanguages())) {
$config = \Pimcore\Config::getSystemConfig();
$language = $config->general->language;
}
return self::getByKey($id, $create, $returnIdIfEmpty)->getTranslation($language);
}
示例14: update
/**
*
*/
protected function update()
{
$oldPath = $this->getDao()->getCurrentFullPath();
parent::update();
$config = \Pimcore\Config::getSystemConfig();
if ($oldPath && $config->documents->createredirectwhenmoved && $oldPath != $this->getFullPath()) {
// create redirect for old path
$redirect = new Redirect();
$redirect->setTarget($this->getId());
$redirect->setSource("@" . $oldPath . "/?@");
$redirect->setStatusCode(301);
$redirect->setExpiry(time() + 86400 * 60);
// this entry is removed automatically after 60 days
$redirect->save();
}
}
示例15: getWkhtmltoimageBinary
/**
* @return bool
*/
public static function getWkhtmltoimageBinary()
{
if (Config::getSystemConfig()->documents->wkhtmltoimage) {
if (@is_executable(Config::getSystemConfig()->documents->wkhtmltoimage)) {
return (string) Config::getSystemConfig()->documents->wkhtmltoimage;
} else {
\Logger::critical("wkhtmltoimage binary: " . Config::getSystemConfig()->documents->wkhtmltoimage . " is not executable");
}
}
$paths = array("/usr/bin/wkhtmltoimage-amd64", "/usr/local/bin/wkhtmltoimage-amd64", "/bin/wkhtmltoimage-amd64", "/usr/bin/wkhtmltoimage", "/usr/local/bin/wkhtmltoimage", "/bin/wkhtmltoimage", realpath(PIMCORE_DOCUMENT_ROOT . "/../wkhtmltox/wkhtmltoimage.exe"));
foreach ($paths as $path) {
if (@is_executable($path)) {
return $path;
}
}
return false;
}