本文整理汇总了PHP中Pimcore_Resource::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Pimcore_Resource::reset方法的具体用法?PHP Pimcore_Resource::reset怎么用?PHP Pimcore_Resource::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore_Resource
的用法示例。
在下文中一共展示了Pimcore_Resource::reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installAction
public function installAction()
{
// try to establish a mysql connection
try {
$db = Zend_Db::factory($this->_getParam("mysql_adapter"), array('host' => $this->_getParam("mysql_host"), 'username' => $this->_getParam("mysql_username"), 'password' => $this->_getParam("mysql_password"), 'dbname' => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port")));
$db->getConnection();
// check utf-8 encoding
$result = $db->fetchRow('SHOW VARIABLES LIKE "character\\_set\\_database"');
if ($result['Value'] != "utf8") {
$errors[] = "Database charset is not utf-8";
}
} catch (Exception $e) {
$errors[] = "Couldn't establish connection to mysql: " . $e->getMessage();
}
// check username & password
if (strlen($this->_getParam("admin_password")) < 4 || strlen($this->_getParam("admin_username")) < 4) {
$errors[] = "Username and password should have at least 4 characters";
}
if (empty($errors)) {
// write configuration file
$settings = array("general" => array("timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "theme" => "/pimcore/static/js/lib/ext/resources/css/xtheme-gray.css", "loginscreenimageservice" => "1", "welcomescreen" => "1", "loglevel" => array("debug" => "1", "info" => "1", "notice" => "1", "warning" => "1", "error" => "1", "critical" => "1", "alert" => "1", "emergency" => "1")), "database" => array("adapter" => $this->_getParam("mysql_adapter"), "params" => array("host" => $this->_getParam("mysql_host"), "username" => $this->_getParam("mysql_username"), "password" => $this->_getParam("mysql_password"), "dbname" => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port"))), "documents" => array("versions" => array("steps" => "10"), "default_controller" => "default", "default_action" => "default", "error_page" => "/", "allowtrailingslash" => "no", "allowcapitals" => "no"), "objects" => array("versions" => array("steps" => "10")), "assets" => array("versions" => array("steps" => "10")), "services" => array(), "cache" => array("excludeCookie" => "pimcore_admin_sid"), "httpclient" => array("adapter" => "Zend_Http_Client_Adapter_Socket"));
$config = new Zend_Config($settings, true);
$writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
$writer->write();
// insert db dump
$db = Pimcore_Resource::get();
$mysqlInstallScript = file_get_contents(PIMCORE_PATH . "/modules/install/mysql/install.sql");
// remove comments in SQL script
$mysqlInstallScript = preg_replace("/\\s*(?!<\")\\/\\*[^\\*]+\\*\\/(?!\")\\s*/", "", $mysqlInstallScript);
// get every command as single part
$mysqlInstallScripts = explode(";", $mysqlInstallScript);
// execute every script with a separate call, otherwise this will end in a PDO_Exception "unbufferd queries, ..." seems to be a PDO bug after some googling
foreach ($mysqlInstallScripts as $m) {
$sql = trim($m);
if (strlen($sql) > 0) {
$sql .= ";";
$db->query($m);
}
}
// get a new database connection
$db = Pimcore_Resource::reset();
// insert data into database
$db->insert("assets", array("id" => 1, "parentId" => 0, "type" => "folder", "filename" => "", "path" => "/", "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
$db->insert("documents", array("id" => 1, "parentId" => 0, "type" => "page", "key" => "", "path" => "/", "index" => 999999, "published" => 1, "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
$db->insert("documents_page", array("id" => 1, "controller" => "", "action" => "", "template" => "", "title" => "", "description" => "", "keywords" => ""));
$db->insert("objects", array("o_id" => 1, "o_parentId" => 0, "o_type" => "folder", "o_key" => "", "o_path" => "/", "o_index" => 999999, "o_published" => 1, "o_creationDate" => time(), "o_modificationDate" => time(), "o_userOwner" => 1, "o_userModification" => 1));
$userPermissions = array(array("key" => "assets", "translation" => "permission_assets"), array("key" => "classes", "translation" => "permission_classes"), array("key" => "clear_cache", "translation" => "permission_clear_cache"), array("key" => "clear_temp_files", "translation" => "permission_clear_temp_files"), array("key" => "document_types", "translation" => "permission_document_types"), array("key" => "documents", "translation" => "permission_documents"), array("key" => "objects", "translation" => "permission_objects"), array("key" => "plugins", "translation" => "permission_plugins"), array("key" => "predefined_properties", "translation" => "permission_predefined_properties"), array("key" => "routes", "translation" => "permission_routes"), array("key" => "seemode", "translation" => "permission_seemode"), array("key" => "system_settings", "translation" => "permission_system_settings"), array("key" => "thumbnails", "translation" => "permission_thumbnails"), array("key" => "translations", "translation" => "permission_translations"), array("key" => "users", "translation" => "permission_users"), array("key" => "update", "translation" => "permissions_update"), array("key" => "redirects", "translation" => "permissions_redirects"), array("key" => "glossary", "translation" => "permissions_glossary"), array("key" => "reports", "translation" => "permissions_reports_marketing"));
foreach ($userPermissions as $up) {
$db->insert("users_permission_definitions", $up);
}
Pimcore::initConfiguration();
$user = User::create(array("parentId" => 0, "username" => $this->_getParam("admin_username"), "password" => Pimcore_Tool_Authentication::getPasswordHash($this->_getParam("admin_username"), $this->_getParam("admin_password")), "hasCredentials" => true, "active" => true));
$user->setAdmin(true);
$user->save();
$this->_helper->json(array("success" => true));
} else {
echo implode("<br />", $errors);
die;
}
}
示例2: collectGarbage
/**
* foreces a garbage collection
* @static
* @return void
*/
public static function collectGarbage($keepItems = array())
{
// close mysql-connection
Pimcore_Resource::close();
$protectedItems = array("pimcore_config_system", "Zend_Locale", "pimcore_tag_block_current", "pimcore_tag_block_numeration", "pimcore_user", "Zend_Translate", "pimcore_admin_user", "pimcore_admin_initialized", "Pimcore_API_Plugin_Broker", "pimcore_config_website", "pimcore_editmode", "pimcore_error_document", "pimcore_site");
if (is_array($keepItems) && count($keepItems) > 0) {
$protectedItems = array_merge($protectedItems, $keepItems);
}
$registryBackup = array();
foreach ($protectedItems as $item) {
if (Zend_Registry::isRegistered($item)) {
$registryBackup[$item] = Zend_Registry::get($item);
}
}
Zend_Registry::_unsetInstance();
foreach ($registryBackup as $key => $value) {
Zend_Registry::set($key, $value);
}
Pimcore_Resource::reset();
}
示例3: launchJob
/**
* Launch a job from the job queue
* @param Schedule_Maintenance_Job $job
*/
protected function launchJob($job)
{
$pid = pcntl_fork();
if ($pid == -1) {
//Problem launching the job
Logger::error('Could not launch new job with id [ ' . $job->getId() . ' ], exiting');
return false;
} else {
if ($pid) {
$this->currentJobs[$pid] = $job->getId();
if (isset($this->signalQueue[$pid])) {
$this->childSignalHandler(SIGCHLD, $pid, $this->signalQueue[$pid]);
unset($this->signalQueue[$pid]);
}
} else {
//Forked child
try {
Logger::debug("Executing job [ " . $job->getId() . " ] as forked child");
Pimcore_Resource::reset();
$job->execute();
} catch (Exception $e) {
Logger::error($e);
Logger::error("Failed to execute job with id [ " . $job->getId() . " ] and method [ " . $job->getMethod() . " ]");
}
$job->unlock();
Logger::debug("Done with job [ " . $job->getId() . " ]");
exit(0);
}
}
return true;
}
示例4: mysqlData
public function mysqlData($name, $type)
{
$db = Pimcore_Resource::reset();
$dumpData = "\n\n";
if ($type != "VIEW") {
// backup tables
$tableData = $db->fetchAll("SELECT * FROM " . $name);
foreach ($tableData as $row) {
$cells = array();
foreach ($row as $cell) {
$cells[] = $db->quote($cell);
}
$dumpData .= "INSERT INTO `" . $name . "` VALUES (" . implode(",", $cells) . ");";
$dumpData .= "\n";
}
} else {
// dump view structure
$dumpData .= "\n\n";
$dumpData .= "DROP VIEW IF EXISTS `" . $name . "`;";
$dumpData .= "\n";
$viewData = $db->fetchRow("SHOW CREATE VIEW " . $name);
$dumpData .= $viewData["Create View"] . ";";
}
$dumpData .= "\n\n";
$h = fopen(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/backup-dump.sql", "a+");
fwrite($h, $dumpData);
fclose($h);
return array("success" => true);
}