本文整理汇总了PHP中Zend\Config\Config::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::toArray方法的具体用法?PHP Config::toArray怎么用?PHP Config::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Config\Config
的用法示例。
在下文中一共展示了Config::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
*
* @throws \Exception
* @return boolean
*/
public function connect()
{
$this->session = ssh2_connect($this->config->host, $this->config->port);
if (false === $this->session) {
throw new \Exception("Echec de la connexion ssh " . print_r($this->config->toArray(), true));
}
$auth = ssh2_auth_pubkey_file($this->session, $this->config->username, $this->config->pubkeyfile, $this->config->privkeyfile);
if (true !== $auth) {
throw new \Exception("Echec de l'authentification ssh " . print_r($this->config->toArray(), true));
}
return true;
}
示例2: getDocumentManager
/**
* @return DocumentManager
*/
public function getDocumentManager()
{
$factory = new DocumentManagerFactory();
$sm = Bootstrap::getServiceManager();
$sm->setAllowOverride(true);
$config = $sm->get('Config');
$c = new Config(['eoko' => ['odm' => ['hydrator' => ['class' => 'Zend\\Stdlib\\Hydrator\\ClassMethods', 'strategies' => ['Eoko\\ODM\\Metadata\\Annotation\\DateTime' => new DateTimeFormatterStrategy()]]]]]);
$c->merge(new Config($config));
$sm->setService('Config', $c->toArray());
return $factory->createService($sm);
}
示例3: init
/**
* Merges the app config with the siteaccess config
*/
public function init()
{
// Add siteaccess specific config
$configHandler = new Config($this->serviceManager->get('config'));
$configHandler->merge($this->addConfig());
$this->serviceManager->setAllowOverride(true);
$this->serviceManager->setService('config', $configHandler->toArray());
$this->serviceManager->setAllowOverride(false);
// not needed I think
#$this->baseXMSServices->setService( 'siteaccess', $this );
}
示例4: process
/**
* Process
*
* @param Config $config
* @return Config
* @throws InvalidArgumentException
*/
public function process(Config $config)
{
$data = $config->toArray();
array_walk_recursive($data, function (&$value, $key) {
if (preg_match('/callable\\((.*)\\)/', $value, $matches)) {
list($class, $method) = array_map('trim', explode(',', $matches[1]));
$value = [new $class(), $method];
}
});
return new Config($data, true);
}
示例5: getFormatsForRecord
/**
* Get an array of strings representing formats in which a specified record's
* data may be exported (empty if none). Legal values: "BibTeX", "EndNote",
* "MARC", "MARCXML", "RDF", "RefWorks".
*
* @param \VuFind\RecordDriver\AbstractBase $driver Record driver
*
* @return array Strings representing export formats.
*/
public function getFormatsForRecord($driver)
{
// Get an array of enabled export formats (from config, or use defaults
// if nothing in config array).
$active = isset($this->mainConfig->Export) ? $this->mainConfig->Export->toArray() : ['RefWorks' => true, 'EndNote' => true];
// Loop through all possible formats:
$formats = [];
foreach (array_keys($this->exportConfig->toArray()) as $format) {
if (isset($active[$format]) && $active[$format] && $this->recordSupportsFormat($driver, $format)) {
$formats[] = $format;
}
}
// Send back the results:
return $formats;
}
示例6: getFormatsForRecord
/**
* Get an array of strings representing formats in which a specified record's
* data may be exported (empty if none). Legal values: "BibTeX", "EndNote",
* "MARC", "MARCXML", "RDF", "RefWorks".
*
* @param \VuFind\RecordDriver\AbstractBase $driver Record driver
*
* @return array Strings representing export formats.
*/
public function getFormatsForRecord($driver)
{
// Get an array of enabled export formats (from config, or use defaults
// if nothing in config array).
$active = $this->getActiveFormats('record');
// Loop through all possible formats:
$formats = [];
foreach (array_keys($this->exportConfig->toArray()) as $format) {
if (in_array($format, $active) && $this->recordSupportsFormat($driver, $format)) {
$formats[] = $format;
}
}
// Send back the results:
return $formats;
}
示例7: getNavigation
/**
* @throws \ErrorException
*
* @return array
*/
public function getNavigation()
{
try {
$navigationDefinition = Factory::fromFile($this->rootNavigationFile, true);
} catch (\Exception $e) {
$navigationDefinition = new Config([]);
}
foreach ($this->navigationSchemaFinder->getSchemaFiles() as $moduleNavigationFile) {
if (!file_exists($moduleNavigationFile->getPathname())) {
throw new ErrorException('Navigation-File does not exist: ' . $moduleNavigationFile);
}
$configFromFile = Factory::fromFile($moduleNavigationFile->getPathname(), true);
$navigationDefinition->merge($configFromFile);
}
return $navigationDefinition->toArray();
}
示例8: substituteVars
/**
* Substitute defined variables, if any found and return the new configuration object
*
* @param Config $config
* @param string $prefix
* @param string $suffix
* @return Config
*/
protected function substituteVars(Config $config, $prefix = '{', $suffix = '}')
{
$arrayConfig = $config->toArray();
if (isset($arrayConfig['variables'])) {
$vars = array_map(function ($x) use($prefix, $suffix) {
return $prefix . $x . $suffix;
}, array_keys($arrayConfig['variables']));
$vals = array_values($arrayConfig['variables']);
$tokens = array_combine($vars, $vals);
$processor = new Token();
$processor->setTokens($tokens);
$processor->process($config);
// Remove variables node
unset($config->variables);
}
return $config;
}
示例9: __construct
/**
* 构造函数
*
* @param Config $config
* @param string $collection
* @param string $database
* @param string $cluster
* @param string $collectionOptions
* @throws \Exception
*/
public function __construct(Config $config, $collection = null, $database = DEFAULT_DATABASE, $cluster = DEFAULT_CLUSTER, $collectionOptions = null)
{
// 检测是否加载了FirePHP
if (!class_exists("FirePHP")) {
throw new \Exception('请安装FirePHP');
}
if (!class_exists("MongoClient")) {
throw new \Exception('请安装MongoClient');
}
if ($collection === null) {
throw new \Exception('$collection集合为空');
}
$this->_collection = $collection;
$this->_database = $database;
$this->_cluster = $cluster;
$this->_collectionOptions = $collectionOptions;
$this->_configInstance = $config;
$this->_config = $config->toArray();
if (!isset($this->_config[$this->_cluster])) {
throw new \Exception('Config error:no cluster key');
}
if (!isset($this->_config[$this->_cluster]['dbs'][$this->_database])) {
throw new \Exception('Config error:no database init');
}
if (!isset($this->_config[$this->_cluster]['dbs'][DB_ADMIN])) {
throw new \Exception('Config error:admin database init');
}
if (!isset($this->_config[$this->_cluster]['dbs'][DB_BACKUP])) {
throw new \Exception('Config error:backup database init');
}
if (!isset($this->_config[$this->_cluster]['dbs'][DB_MAPREDUCE])) {
throw new \Exception('Config error:mapreduce database init');
}
$this->_db = $this->_config[$this->_cluster]['dbs'][$this->_database];
if (!$this->_db instanceof \MongoDB) {
throw new \Exception('$this->_db is not instanceof \\MongoDB');
}
$this->_admin = $this->_config[$this->_cluster]['dbs'][DB_ADMIN];
if (!$this->_admin instanceof \MongoDB) {
throw new \Exception('$this->_admin is not instanceof \\MongoDB');
}
$this->_backup = $this->_config[$this->_cluster]['dbs'][DB_BACKUP];
if (!$this->_backup instanceof \MongoDB) {
throw new \Exception('$this->_backup is not instanceof \\MongoDB');
}
$this->_mapreduce = $this->_config[$this->_cluster]['dbs'][DB_MAPREDUCE];
if (!$this->_mapreduce instanceof \MongoDB) {
throw new \Exception('$this->_mapreduce is not instanceof \\MongoDB');
}
$this->_fs = new \MongoGridFS($this->_db, GRIDFS_PREFIX);
// 默认执行几个操作
// 第一个操作,判断集合是否创建,如果没有创建,则进行分片处理(目前采用_ID作为片键)
if (APPLICATION_ENV === 'production') {
$this->shardingCollection();
}
parent::__construct($this->_db, $this->_collection);
/**
* 设定读取优先级
* MongoClient::RP_PRIMARY 只读取主db
* MongoClient::RP_PRIMARY_PREFERRED 读取主db优先
* MongoClient::RP_SECONDARY 只读从db优先
* MongoClient::RP_SECONDARY_PREFERRED 读取从db优先
*/
// $this->db->setReadPreference(\MongoClient::RP_SECONDARY_PREFERRED);
$this->db->setReadPreference(\MongoClient::RP_PRIMARY_PREFERRED);
}
示例10: testSetOptionsOmitsAccessorsRequiringObjectsOrMultipleParams
public function testSetOptionsOmitsAccessorsRequiringObjectsOrMultipleParams()
{
$options = $this->getOptions();
$config = new Config($options);
$options['config'] = $config;
$options['options'] = $config->toArray();
$options['pluginLoader'] = true;
$options['view'] = true;
$options['translator'] = true;
$options['attrib'] = true;
$this->group->setOptions($options);
}
示例11: _sortRootElements
/**
* Root elements that are not assigned to any section needs to be
* on the top of config.
*
* @see http://framework.zend.com/issues/browse/ZF-6289
* @param Zend\Config
* @return Zend\Config
*/
protected function _sortRootElements(\Zend\Config\Config $config)
{
$configArray = $config->toArray();
$sections = array();
// remove sections from config array
foreach ($configArray as $key => $value) {
if (is_array($value)) {
$sections[$key] = $value;
unset($configArray[$key]);
}
}
// readd sections to the end
foreach ($sections as $key => $value) {
$configArray[$key] = $value;
}
return new \Zend\Config\Config($configArray);
}
示例12: dumpConfig
/**
* Export config in a format to be stored to config file
*
* @param Config $config
* @return string
*/
private static function dumpConfig(Config $config)
{
return '<' . "?php\nreturn " . var_export($config->toArray(), 1) . ";\n";
}
示例13: testZF6995_toArrayDoesNotDisturbInternalIterator
public function testZF6995_toArrayDoesNotDisturbInternalIterator()
{
$config = new Config(range(1, 10));
$config->rewind();
$this->assertEquals(1, $config->current());
$config->toArray();
$this->assertEquals(1, $config->current());
}
示例14: getMapTreeElement
/**
* Return from element with system map tree
* @return \Zly\Form\Element\Tree
*/
public function getMapTreeElement()
{
$sysmap = $this->getSysmap();
$root = $this->getRoot();
$root->name = 'Modules';
$root->_childrens = $sysmap;
$rootedSysmap = new Config($root->toArray(), true);
$formElement = new \Zly\Form\Element\Tree('sysmap_id');
$formElement->setValueKey('hash');
$formElement->setTitleKey('name');
$formElement->setChildrensKey('_childrens');
$formElement->setMultiOptions(array($rootedSysmap->toArray()));
return $formElement;
}
示例15: process
/**
*
* @param Config $value
* @return Config
*/
public function process(Config $value)
{
return new Config($this->interpolator->interpolate($value->toArray(), $this->variables));
}