本文整理汇总了PHP中Setup类的典型用法代码示例。如果您正苦于以下问题:PHP Setup类的具体用法?PHP Setup怎么用?PHP Setup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Setup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
date_default_timezone_set(@date_default_timezone_get());
session_start();
$session = new Session($_SESSION);
$request = new Request($_REQUEST);
$setup = new Setup($request->query_boolean('refresh', false));
$context = new Context($session, $request, $setup);
if ($context->is_api_request()) {
(new Api($context))->apply();
} else {
if ($context->is_info_request()) {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
require __DIR__ . '/pages/info.php';
} else {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
$fallback_html = (new Fallback($context))->get_html();
require __DIR__ . '/pages/index.php';
}
}
}
示例2: __construct
public function __construct(Setup $setup)
{
$this->setup = $setup;
$this->storageMode = 'flat-file';
$metadata_file = $this->setup->dir . '/.metadata';
$update_metadata = false;
// Read exist metadata file if one exists
if (file_exists($metadata_file)) {
$json_metadata = json_decode(file_get_contents($metadata_file), true);
$this->setup->metadata = array_merge($this->setup->metadata, $json_metadata);
}
// Check if comment thread directory exists
if ($setup->mode !== 'api') {
if (file_exists(dirname($metadata_file)) and is_writable(dirname($metadata_file))) {
// Check whether the page and metadata URLs differ
if ($this->setup->metadata['title'] !== $setup->pageTitle) {
$this->setup->metadata['title'] = $setup->pageTitle;
$update_metadata = true;
}
// Check whether the page and metadata titles differ
if ($this->setup->metadata['url'] !== $setup->pageURL) {
$this->setup->metadata['url'] = $setup->pageURL;
$update_metadata = true;
}
// Update metadata if the data has changed
if ($update_metadata === true) {
if ($this->save_metadata($this->setup->metadata, $metadata_file) === false) {
exit($setup->escapeOutput('<b>HashOver</b>: Failed to create metadata file.', 'single'));
}
}
}
}
}
示例3: InterafceWithSiCDS
/**
* Given a valid servive URI and a valid string of JSON,
* this method communcates with the SiCDS and returns a
* list of all unique ID's
*
* @param string $uri
* @param string $json
* @return string
*/
public function InterafceWithSiCDS($uri, $json)
{
include_once Setup::Modules_Directory() . "/SiSW/ServiceWrapper.php";
$service = new \Swiftriver\Core\Modules\SiSW\ServiceWrapper($uri);
$jsonFromService = $service->MakePOSTRequest(array("data" => $json), 5);
return $jsonFromService;
}
示例4: __construct
private function __construct()
{
$settings = Setup::getSettings();
$config = \Doctrine\ORM\Tools\Setup::createXMLMetadataConfiguration([__DIR__ . '/../Mapper', 'Bh/Mapper'], $settings['DevMode']);
$conn = array('driver' => 'pdo_mysql', 'user' => $settings['DbUser'], 'password' => $settings['DbPass'], 'dbname' => $settings['DbName']);
self::$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
}
示例5: setUp
protected function setUp()
{
include_once dirname(__FILE__) . "/../Setup.php";
$config = Setup::Configuration();
include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/Content.php";
include_once dirname(__FILE__) . "/../TextForUrlParser.php";
}
示例6: saveConfig
/**
* If you made changes to config, you may call this to persist the changes
* back to disk
*/
protected function saveConfig()
{
if (!isset($this->config)) {
return;
}
Setup::save();
}
示例7: setUp
protected function setUp()
{
include_once dirname(__FILE__) . "/../../../Modules/TagTheNetInterface/Setup.php";
$config = Setup::Configuration();
include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/Content.php";
include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/Tag.php";
include_once dirname(__FILE__) . "/../../../Modules/TagTheNetInterface/ContentFromJSONParser.php";
}
示例8: __construct
/**
* @param \Saigon\Conpago\IDbConfig $dbConfig
* @param \Saigon\Conpago\IDoctrineConfig $doctrineConfig
*/
public function __construct(IDBConfig $dbConfig, IDoctrineConfig $doctrineConfig)
{
$this->dbConfig = $dbConfig;
$this->doctrineConfig = $doctrineConfig;
$paths = array($this->doctrineConfig->getModelPath());
$this->setDbParams();
$config = Setup::createAnnotationMetadataConfiguration($paths, $this->doctrineConfig->getDevMode());
$this->entityManager = EntityManager::create($this->dbParams, $config);
}
示例9: maybe_self_deactivate
/**
* Check plugin requirements.
*
* @return bool True is fails requirements. False otherwise.
*/
public function maybe_self_deactivate()
{
if (false === Setup::meets_requirements()) {
add_action('admin_init', array('HM\\BackUpWordPress\\Setup', 'self_deactivate'));
add_action('admin_notices', array('HM\\BackUpWordPress\\Setup', 'display_admin_notices'));
return true;
}
return false;
}
示例10: database
public function database(\Base $f3)
{
$this->response->data['SUBPART'] = 'settings_database.html';
$cfg = \Config::instance();
if ($f3->get('VERB') == 'POST' && $f3->exists('POST.active_db')) {
$type = $f3->get('POST.active_db');
$cfg->{'DB_' . $type} = $f3->get('POST.DB_' . $type);
$cfg->ACTIVE_DB = $type;
$cfg->save();
\Flash::instance()->addMessage('Config saved', 'success');
$setup = new \Setup();
$setup->install($type);
// logout
$f3->clear('SESSION.user_id');
}
$cfg->copyto('POST');
$f3->set('JIG_format', array('JSON', 'Serialized'));
}
示例11: __construct
public function __construct(Setup $setup)
{
$this->setup = $setup;
$this->storageMode = $setup->databaseType;
try {
if ($setup->databaseType === 'sqlite') {
$this->database = new PDO('sqlite:' . $setup->rootDirectory . '/pages/' . $setup->databaseName . '.sqlite');
} else {
$sql_connection = 'host=' . $setup->databaseHost . ';' . 'dbname=' . $setup->databaseName . ';' . 'charset=' . $setup->databaseCharset;
$this->database = new PDO($setup->databaseType . ':' . $sql_connection, $setup->databaseUser, $setup->databasePassword);
}
} catch (PDOException $error) {
exit($setup->escapeOutput($error->getMessage(), 'single'));
}
// Create comment tread table
$create = 'CREATE TABLE IF NOT EXISTS \'' . $setup->threadDirectory . '\' ' . '(id TEXT PRIMARY KEY,' . ' name TEXT,' . ' password TEXT,' . ' login_id TEXT,' . ' email TEXT,' . ' encryption TEXT,' . ' website TEXT,' . ' date TEXT,' . ' likes TEXT,' . ' dislikes TEXT,' . ' notifications TEXT,' . ' ipaddr TEXT,' . ' status TEXT,' . ' body TEXT)';
$this->database->exec($create);
}
示例12: InterafceWithService
/**
* Given a valid servive URI and a valid string of text
* this service wraps the TagThe.Net taggin service
*
* @param string $uri
* @param string $json
* @return string
*/
public function InterafceWithService($uri, $text)
{
$config = Setup::Configuration();
require $config["SwiftriverModulesDirectory"] . "/SwiftriverServiceWrapper/ServiceWrapper.php";
$uri = str_replace("?view=json", "", $uri);
$uri = $uri . "?view=json&text=" . $text;
$service = new \Swiftriver\Core\Modules\SiSW\ServiceWrapper($uri);
$jsonFromService = $service->MakeGETRequest();
return $jsonFromService;
}
示例13: GetLogger
/**
* Get the shared instance for the logger
* @return \Log
*/
public static function GetLogger()
{
$log = new \Log("this message is ignored, however not supplying one throws an error :o/");
$logger = $log->singleton('file', Setup::Configuration()->CachingDirectory . "/log.log", ' ');
if (!self::Configuration()->EnableDebugLogging) {
$mask = \Log::UPTO(\PEAR_LOG_INFO);
$logger->setMask($mask);
}
return $logger;
}
示例14: getConfig
/**
* Get database config.
* load it from setup, fall back to legacy config.php constants
*
* @return array
*/
public static function getConfig()
{
$setup = Setup::get();
if (isset($setup['database'])) {
$config = $setup['database']->toArray();
} else {
// legacy: import from constants
$config = array('driver' => APP_SQL_DBTYPE, 'hostname' => APP_SQL_DBHOST, 'database' => APP_SQL_DBNAME, 'username' => APP_SQL_DBUSER, 'password' => APP_SQL_DBPASS, 'port' => APP_SQL_DBPORT, 'table_prefix' => APP_TABLE_PREFIX);
// save it back. this will effectively do the migration
Setup::save(array('database' => $config));
}
return $config;
}
示例15: testParseToRequestJson
public function testParseToRequestJson()
{
include_once dirname(__FILE__) . "/../../../Setup.php";
include_once dirname(__FILE__) . "/../../../Modules/SiCDSInterface/Parser.php";
include_once dirname(__FILE__) . "/../../../Modules/SiCDSInterface/SiCDSPreProcessingStep.php";
include_once dirname(__FILE__) . "/../../../Modules/SiCDSInterface/ServiceInterface.php";
$item = new ObjectModel\Content();
$item->id = "testId";
$item->difs = array(new ObjectModel\DuplicationIdentificationFieldCollection("names", array(new ObjectModel\DuplicationIdentificationField("first", "homer"), new ObjectModel\DuplicationIdentificationField("second", "simpson"))));
$configuration = new MockConfiguration();
$SiCDS = new \Swiftriver\PreProcessingSteps\SiCDSPreProcessingStep();
$SiCDS->Process(array($item), $configuration, Setup::GetLogger());
}