本文整理汇总了PHP中zibo\core\Zibo::getConfigValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Zibo::getConfigValue方法的具体用法?PHP Zibo::getConfigValue怎么用?PHP Zibo::getConfigValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zibo\core\Zibo
的用法示例。
在下文中一共展示了Zibo::getConfigValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBaseUrl
/**
* Gets the base URL of the system
* @return string
*/
public function getBaseUrl()
{
if ($this->baseUrl) {
return $this->baseUrl;
}
$baseUrl = $this->zibo->getConfigValue(self::CONFIG_URL);
if (!$baseUrl) {
$baseUrl = $this->generateBaseUrl();
}
return $this->baseUrl = rtrim($baseUrl, '/');
}
示例2: setInvertToCreatedFilter
protected static function setInvertToCreatedFilter(AbstractInvertLogItemFilter $filter, Zibo $zibo, $name, $configBase)
{
$configInvert = $configBase . Module::CONFIG_INVERT;
$invert = $zibo->getConfigValue($configInvert);
if ($invert !== null) {
$filter->setInvert($invert);
}
}
示例3: readRoutesFromFile
/**
* Reads the routes from the provided file
* @param zibo\library\filesystem\File $file
* @return array Array with Route objects as value and their path as key
*/
private function readRoutesFromFile(File $file)
{
$dom = new Document();
$relaxNg = $this->zibo->getConfigValue(self::CONFIG_RNG);
if ($relaxNg) {
$dom->setRelaxNGFile($relaxNg);
}
$dom->load($file);
return $this->getRoutesFromElement($file, $dom->documentElement);
}
示例4: getMimeType
/**
* Gets the MIME type of a file based on it's extension
* @param zibo\core\Zibo $zibo Instance of Zibo
* @param zibo\library\filesystem\File $file The file to get the MIME from
* @return string The MIME type of the file
*/
public static function getMimeType(Zibo $zibo, File $file)
{
$extension = $file->getExtension();
if (empty($extension)) {
return self::MIME_UNKNOWN;
}
$mime = $zibo->getConfigValue(self::CONFIG_MIME . $extension);
if (!$mime) {
$mime = self::MIME_UNKNOWN;
}
return $mime;
}
示例5: createValidator
/**
* Create a new validator
* @param string $validatorName name of the validator
* @param array $options options for the validator
* @return zibo\library\validation\validator\Validator
* @throws zibo\ZiboException when the validator does not exist
*/
public function createValidator($validatorName, array $options = array())
{
if (!String::isString($validatorName, String::NOT_EMPTY)) {
throw new ZiboException('Provided validator name is empty or invalid');
}
if (!isset($this->validators[$validatorName])) {
$validatorClass = $this->zibo->getConfigValue(self::CONFIG_VALIDATOR . '.' . $validatorName);
if (!$validatorClass) {
throw new ZiboException('Unsupported validator: ' . $validatorName);
}
$this->registerValidator($validatorName, $validatorClass);
}
$className = $this->validators[$validatorName];
return new $className($options);
}
示例6: loadListeners
private function loadListeners(Zibo $zibo)
{
$config = $zibo->getConfigValue(self::CONFIG_LOG);
if (isset($config[self::CONFIG_LISTENER])) {
unset($config[self::CONFIG_LISTENER]);
}
if (isset($config[self::CONFIG_FILTER])) {
unset($config[self::CONFIG_FILTER]);
}
$listenerFactory = new LogListenerFactory($zibo);
foreach ($config as $name => $parameters) {
$listener = $listenerFactory->createListener($name);
if ($listener != null) {
$this->log->addLogListener($listener);
}
}
}
示例7: loadModules
/**
* Loads the defined modules from the Zibo Configuration
* @param zibo\core\Zibo $zibo Instance of Zibo
* @return array Array with the defined modules
* @throws zibo\ZiboException when a module could not be created
* @see Module
* @see CONFIG_MODULE
*/
public function loadModules(Zibo $zibo)
{
$configModules = $zibo->getConfigValue(self::CONFIG_MODULE);
if (!$configModules) {
return array();
}
$objectFactory = new ObjectFactory();
$modules = array();
$configModules = Config::parseConfigTree($configModules);
foreach ($configModules as $configKey => $moduleClass) {
try {
$modules[] = $objectFactory->create($moduleClass, self::INTERFACE_MODULE);
} catch (ZiboException $exception) {
throw new ZiboException('Could not create ' . $moduleClass . ' from the ' . $configKey . ' configuration key', 0, $exception);
}
}
return $modules;
}
示例8: addFiltersToCreatedListener
protected static function addFiltersToCreatedListener(AbstractFilteredLogListener $listener, Zibo $zibo, $name, $configBase)
{
$configBase .= Module::CONFIG_FILTER;
$config = $zibo->getConfigValue($configBase);
if (empty($config)) {
return;
}
if (isset($config[Module::CONFIG_FILTER_ALL])) {
$listener->setFilterAllFilters($config[Module::CONFIG_FILTER_ALL]);
unset($config[Module::CONFIG_FILTER_ALL]);
}
if (isset($config[Module::CONFIG_INVERT])) {
$listener->setInvert($config[Module::CONFIG_INVERT]);
unset($config[Module::CONFIG_INVERT]);
}
$filterFactory = new LogItemFilterFactory($zibo);
foreach ($config as $name => $parameters) {
$filterConfigBase = $configBase . Config::TOKEN_SEPARATOR . $name . Config::TOKEN_SEPARATOR;
$filter = $filterFactory->createFilter($name, $filterConfigBase);
if ($filter != null) {
$listener->addFilter($filter);
}
}
}
示例9: parseConfiguration
/**
* Assign the smarty configuration to the engine
* @param zibo\core\Zibo $zibo instance of Zibo to get the configuration from
* @return null
*/
private function parseConfiguration(Zibo $zibo)
{
$this->smarty->caching = false;
$this->smarty->compile_dir = $zibo->getConfigValue(self::CONFIG_COMPILE_DIRECTORY, self::DEFAULT_COMPILE_DIRECTORY);
$directory = new File($this->smarty->compile_dir);
$directory->create();
$smartyPluginDirectories = $zibo->getConfigValue(self::CONFIG_PLUGINS, array());
if (!is_array($smartyPluginDirectories)) {
$smartyPluginDirectories = array($smartyPluginDirectories);
}
foreach ($smartyPluginDirectories as $directory) {
$this->smarty->plugins_dir[] = $directory;
}
}
示例10: setParametersToCreatedListener
protected static function setParametersToCreatedListener(FileListener $listener, Zibo $zibo, $name, $configBase)
{
$configFileTruncateSize = $configBase . self::CONFIG_FILE_TRUNCATE_SIZE;
$fileTruncateSize = $zibo->getConfigValue($configFileTruncateSize);
if ($fileTruncateSize !== null) {
$listener->setFileTruncateSize($fileTruncateSize);
}
$configDateFormat = $configBase . self::CONFIG_DATE_FORMAT;
$dateFormat = $zibo->getConfigValue($configDateFormat);
if ($dateFormat !== null) {
$listener->setDateFormat($dateFormat);
}
}
示例11: loadConnectionsFromConfig
/**
* Loads the database connections from the Zibo configuration
* @param zibo\core\Zibo $zibo Instance of Zibo
* @return null
* @throws zibo\library\database\exception\DatabaseException when the configuration contains an invalid connection
* @throws zibo\library\database\exception\DatabaseException when the default connection does not exist
*/
private function loadConnectionsFromConfig(Zibo $zibo)
{
$zibo->runEvent(Zibo::EVENT_LOG, 'Loading database connections', '', 0, self::LOG_NAME);
$connections = $zibo->getConfigValue(self::CONFIG_CONNECTION, array());
if (!is_array($connections)) {
$connections = array(self::NAME_DEFAULT => $connections);
}
$defaultConnectionName = null;
foreach ($connections as $name => $dsn) {
if ($name == self::NAME_DEFAULT) {
$defaultConnectionName = $name;
}
try {
$dsn = new Dsn($dsn);
$this->registerConnection($name, $dsn);
} catch (DatabaseException $e) {
if ($name == self::NAME_DEFAULT) {
$defaultConnectionName = $dsn;
} else {
throw $e;
}
}
}
if ($defaultConnectionName != null) {
$this->setDefaultConnectionName($defaultConnectionName);
}
}
示例12: setDefaultAction
/**
* Sets the default action and controller to the router
* @param zibo\core\Zibo $zibo
* @return null
*/
private function setDefaultAction(Zibo $zibo)
{
$router = $zibo->getRouter();
if ($router === null) {
$router = new GenericRouter();
$zibo->setRouter($router);
}
if (!$router instanceof GenericRouter) {
return;
}
$defaultController = $router->getDefaultController();
if ($defaultController) {
return;
}
$defaultController = $zibo->getConfigValue(self::CONFIG_CONTROLLER_DEFAULT, self::CONTROLLER_DEFAULT);
$router->setDefaultAction($defaultController);
}
示例13: initializeHashAlgorithm
/**
* Initializes the hash algorithm from the Zibo configuration
* @param zibo\core\Zibo $zibo The Zibo instance
* @param zibo\library\ObjectFactory $objectFactory Instance of an object factory
* @return null
*/
private function initializeHashAlgorithm(Zibo $zibo, ObjectFactory $objectFactory)
{
$hashAlgorithms = $zibo->getConfigValue(EncryptionModule::CONFIG_HASH_ALGORITHM);
$hashAlgorithmName = $zibo->getConfigValue(self::CONFIG_HASH_ALGORITHM, self::DEFAULT_HASH_ALGORITHM);
if (!array_key_exists($hashAlgorithmName, $hashAlgorithms)) {
throw new ZiboException('Provided password hash algorithm ' . $hashAlgorithmName . ' could not be found');
}
$hashAlgorithmClass = $hashAlgorithms[$hashAlgorithmName];
$this->hashAlgorithm = $objectFactory->create($hashAlgorithmClass, EncryptionModule::INTERFACE_HASH_ALGORITHM);
}
示例14: loadTypes
/**
* Loads the archive types from the Zibo configuration
* @return null
*/
private function loadTypes(Zibo $zibo)
{
$this->types = array();
$types = $zibo->getConfigValue(self::CONFIG_TYPES, array());
foreach ($types as $typeName => $className) {
$this->register($typeName, $className);
}
}