本文整理汇总了PHP中Zend\Config\Factory::toFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::toFile方法的具体用法?PHP Factory::toFile怎么用?PHP Factory::toFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Config\Factory
的用法示例。
在下文中一共展示了Factory::toFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateConfig
private function generateConfig()
{
$path = "module/{$this->module}/config/table.config.php";
if (file_exists($path)) {
copy($path, $path . '.' . date('mdHis'));
$config = (include $path);
} else {
$config = ['tables' => []];
}
$itemConfig = ['table' => $this->table];
if ($this->params('db')) {
$itemConfig['adapter'] = $this->params('db');
}
if ($this->params('schema')) {
$itemConfig['schema'] = $this->params('schema');
}
if ($this->params('t')) {
$itemConfig['invokable'] = "{$this->module}\\Model\\{$this->name}Table";
}
if ($this->params('e')) {
$itemConfig['row'] = "{$this->module}\\Model\\{$this->name}";
}
if ($this->params('re')) {
$itemConfig['row'] = true;
}
$primaries = [];
foreach ($this->getTableMeta()->getConstraints($this->table, $this->schema) as $constraint) {
/** @var $constraint \Zend\Db\Metadata\Object\ConstraintObject */
if ($constraint->getType() == 'PRIMARY KEY') {
$primaries[] = current($constraint->getColumns());
}
}
if (count($primaries) == 1) {
$primaries = current($primaries);
}
$itemConfig['primary'] = $primaries;
$config['tables'][$this->name . 'Table'] = $itemConfig;
ConfigFactory::toFile($path, $config);
echo 'Generate config success!';
}
示例2: testFactoryCanRegisterCustomWriterPlugin
public function testFactoryCanRegisterCustomWriterPlugin()
{
$dummyWriter = new Writer\TestAssets\DummyWriter();
Factory::getWriterPluginManager()->setService('DummyWriter', $dummyWriter);
Factory::registerWriter('dum', 'DummyWriter');
$file = $this->getTestAssetFileName('dum');
$res = Factory::toFile($file, array('one' => 1));
$this->assertEquals($res, true);
}
示例3: getenv
<?php
use Zend\Config\Factory;
$env = getenv('APP_ENV') ?: 'dev';
$mergedConfigFile = __DIR__ . '/../data/cache/config_cache.php';
// If in production and merged config exists, return it
if ($env === 'pro' && is_file($mergedConfigFile)) {
return include $mergedConfigFile;
}
// Merge configuration files
$mergedConfig = Factory::fromFiles(glob(__DIR__ . '/autoload/{,*.}{global,local}.php', GLOB_BRACE));
// If in production, cache merged config
if ($env === 'pro') {
Factory::toFile($mergedConfigFile, $mergedConfig);
}
// Finally, Return the merged configuration
return $mergedConfig;