本文整理汇总了PHP中PartKeepr\PartKeepr::getRootDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP PartKeepr::getRootDirectory方法的具体用法?PHP PartKeepr::getRootDirectory怎么用?PHP PartKeepr::getRootDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PartKeepr\PartKeepr
的用法示例。
在下文中一共展示了PartKeepr::getRootDirectory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: minify
/**
* Minifies the given source files into the output file.
*
* "Minify" means that whitespaces and newlines are stripped, which results in a smaller file.
*
* @param array $sourceFiles An array of source files with absolute paths
* @param $outputFile
* @return mixed
*/
public function minify(array $sourceFiles, $outputFile)
{
if (!class_exists("\\JSMin")) {
require_once PartKeepr::getRootDirectory() . "/" . self::JSMIN_SCRIPT;
}
if (file_exists($outputFile)) {
unlink($outputFile);
}
foreach ($sourceFiles as $sourceFile) {
$minifiedJS = \JSMin::minify(file_get_contents($sourceFile));
file_put_contents($outputFile, $minifiedJS, FILE_APPEND);
}
}
示例2: registerAnnotationLoaders
/**
* Register the annotation loader.
* @todo This will happen multiple times, needs a fix to do this only once
*/
public function registerAnnotationLoaders()
{
AnnotationRegistry::registerLoader(function ($class) {
$file = str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
$fullFile = PartKeepr::getRootDirectory() . "/src/backend/" . $file;
if (file_exists($fullFile)) {
// file exists makes sure that the loader fails silently
require $fullFile;
return true;
}
});
AnnotationRegistry::registerAutoloadNamespace('PartKeepr\\Service\\Annotations', PartKeepr::getRootDirectory() . "/src/backend/PartKeepr/Service/Annotations");
require_once 'Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
}
示例3: saveConfig
/**
* Saves the configuration file.
*
* @throws SerializableException An exception which describes what has been going wrong
*/
private function saveConfig()
{
$configFile = PartKeepr::getRootDirectory() . "/config.php";
if (file_exists($configFile)) {
if (!is_writable($configFile)) {
$message = "The config.php file could not be written, because it already exists and the webserver has ";
$message .= "no write access to it.";
throw new SerializableException($message, 10000);
}
} else {
if (!is_writable(PartKeepr::getRootDirectory())) {
$message = "The config.php file could not be written, because the webserver has no write access to it.";
throw new SerializableException($message, 10001);
}
}
file_put_contents($configFile, Configuration::dumpConfig());
}
示例4: execute
/**
* Executes the minify process
*
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$sourceDirs = $input->getOption('source');
if (count($sourceDirs) == 0) {
throw new \RuntimeException("Argument 'source' is required at least once in order to execute this command correctly.");
}
$orderedFileList = $this->getOrderedFileList($sourceDirs);
// Write out the used JS files which are required for the full debug frontend mode.
// @todo Fix that some time - it's a bit ugly.
$frontendFiles = array();
foreach ($orderedFileList as $orderedFile) {
$orderedFile = str_replace(PartKeepr::getRootDirectory() . "/src/frontend/", "", $orderedFile);
$orderedFile = str_replace(PartKeepr::getRootDirectory() . "/3rdparty/extjs/examples/ux/", "js/Ext.ux/", $orderedFile);
$orderedFile = str_replace(PartKeepr::getRootDirectory() . "/3rdparty/ext-wizard/Ext.ux.Wizard/", "js/Ext.ux/", $orderedFile);
$orderedFile = str_replace(PartKeepr::getRootDirectory() . "/3rdparty/Ext.ux.Exporter/", "js/Ext.ux.Exporter/", $orderedFile);
$frontendFiles[] = $orderedFile;
}
file_put_contents(PartKeepr::getRootDirectory() . "/partkeepr.jsfiles", serialize($frontendFiles));
if (count($orderedFileList) == 0) {
throw new \RuntimeException("No files in the source directories found.");
}
switch ($input->getOption("minifier")) {
case "jsmin":
$minifier = new jsminMinifier();
break;
case "yui-compressor":
$minifier = new yuiCompressorMinifier();
break;
default:
$minifier = $this->detectMinifier();
break;
}
$minifier->setOutput($output);
if ($input->getOption("compress") === true) {
return $minifier->compress($orderedFileList, $input->getArgument("outputFile"));
}
if ($input->getOption("minify") === true) {
return $minifier->compress($orderedFileList, $input->getArgument("outputFile"));
}
return $minifier->combine($orderedFileList, $input->getArgument("outputFile"));
}
示例5: array
if (!class_exists("Imagick")) {
$template = $twig->loadTemplate("error.tpl");
echo $template->render(array("title" => PartKeepr::i18n("ImageMagick is not installed"), "error" => PartKeepr::i18n("You are missing the ImageMagick extension. Please install it and restart the setup to verify that the library was installed correctly.")));
exit;
}
/* ImageMagick formats */
$imagick = new \Imagick();
$aParameters["availableImageFormats"] = $imagick->queryFormats();
/* Automatic Login */
if (Configuration::getOption("partkeepr.frontend.autologin.enabled", false) === true) {
$aParameters["autoLoginUsername"] = Configuration::getOption("partkeepr.frontend.autologin.username");
$aParameters["autoLoginPassword"] = Configuration::getOption("partkeepr.frontend.autologin.password");
}
if (Configuration::getOption("partkeepr.frontend.motd", false) !== false) {
$aParameters["motd"] = Configuration::getOption("partkeepr.frontend.motd");
}
/* Load and render the template */
$template = $twig->loadTemplate("index.tpl");
$renderParams = array();
$renderParams["debug_all"] = Configuration::getOption("partkeepr.frontend.debug_all", false);
$renderParams["debug"] = Configuration::getOption("partkeepr.frontend.debug", false);
$renderParams["parameters"] = $aParameters;
if ($renderParams["debug_all"]) {
$renderParams["scripts"] = unserialize(file_get_contents(PartKeepr::getRootDirectory() . "/partkeepr.jsfiles"));
}
if (isset($_SERVER['HTTPS'])) {
$renderParams["https"] = true;
} else {
$renderParams["https"] = false;
}
echo $template->render($renderParams);
示例6: getFilePath
/**
* Returns the path to the image. May be overridden by
* subclasses.
*
* @param none
* @return string The path to the image
*/
public function getFilePath()
{
return Configuration::getOption("partkeepr.images.path", PartKeepr::getRootDirectory() . "/data/images/") . $this->getType() . "/";
}
示例7: createConnectionOptionsFromConfig
public static function createConnectionOptionsFromConfig()
{
$connectionOptions = array();
$driver = PartKeeprConfiguration::getOption("partkeepr.database.driver");
switch ($driver) {
case "pdo_mysql":
// Force SET NAMES, as PHP/PDO <5.3.6 silently ignores "charset"
$connectionOptions["driverOptions"] = array(1002 => 'SET NAMES utf8');
case "pdo_pgsql":
case "pdo_oci":
case "oci8":
case "pdo_sqlsrv":
$connectionOptions["driver"] = $driver;
$connectionOptions["dbname"] = PartKeeprConfiguration::getOption("partkeepr.database.dbname", "partkeepr");
$connectionOptions["user"] = PartKeeprConfiguration::getOption("partkeepr.database.username", "partkeepr");
$connectionOptions["password"] = PartKeeprConfiguration::getOption("partkeepr.database.password", "partkeepr");
$connectionOptions["charset"] = "utf8";
/**
* Compatibility with older configuration files. We check for the key "hostname" as well as "host".
*/
if (PartKeeprConfiguration::getOption("partkeepr.database.hostname", null) !== null) {
$connectionOptions["host"] = PartKeeprConfiguration::getOption("partkeepr.database.hostname");
} else {
$connectionOptions["host"] = PartKeeprConfiguration::getOption("partkeepr.database.host", "localhost");
}
if (PartKeeprConfiguration::getOption("partkeepr.database.port") !== null) {
$connectionOptions["port"] = PartKeeprConfiguration::getOption("partkeepr.database.port");
}
if (PartKeeprConfiguration::getOption("partkeepr.database.mysql_socket", null) !== null) {
$connectionOptions["unix_socket"] = PartKeeprConfiguration::getOption("partkeepr.database.mysql_socket");
}
break;
case "pdo_sqlite":
$connectionOptions["driver"] = $driver;
$connectionOptions["user"] = PartKeeprConfiguration::getOption("partkeepr.database.username", "partkeepr");
$connectionOptions["password"] = PartKeeprConfiguration::getOption("partkeepr.database.password", "partkeepr");
$connectionOptions["path"] = PartKeeprConfiguration::getOption("partkeepr.database.sqlite_path", PartKeepr::getRootDirectory() . "/data/partkeepr.sqlite");
break;
default:
throw new \Exception(sprintf("Unknown driver %s", $driver));
}
return $connectionOptions;
}