本文整理汇总了PHP中Doctrine_Parser::dump方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Parser::dump方法的具体用法?PHP Doctrine_Parser::dump怎么用?PHP Doctrine_Parser::dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Parser
的用法示例。
在下文中一共展示了Doctrine_Parser::dump方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFacadeLoadAndDump
public function testFacadeLoadAndDump()
{
Doctrine_Parser::dump(array('test' => 'good job', 'test2' => true, array('testing' => false)), 'yml', 'test.yml');
$array = Doctrine_Parser::load('test.yml', 'yml');
$this->assertEqual($array, array('test' => 'good job', 'test2' => true, array('testing' => false)));
unlink('test.yml');
}
示例2: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$this->logSection('doctrine', 'generating model classes');
$config = $this->getCliConfig();
$this->_checkForPackageParameter($config['yaml_schema_path']);
$tmpPath = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp';
if (!file_exists($tmpPath)) {
Doctrine_Lib::makeDirectories($tmpPath);
}
$plugins = $this->configuration->getPlugins();
foreach ($this->configuration->getAllPluginPaths() as $plugin => $path) {
if (!in_array($plugin, $plugins)) {
continue;
}
$schemas = sfFinder::type('file')->name('*.yml')->in($path . '/config/doctrine');
foreach ($schemas as $schema) {
$tmpSchemaPath = $tmpPath . DIRECTORY_SEPARATOR . $plugin . '-' . basename($schema);
$models = Doctrine_Parser::load($schema, 'yml');
if (!isset($models['package'])) {
$models['package'] = $plugin . '.lib.model.doctrine';
$models['package_custom_path'] = $path . '/lib/model/doctrine';
}
Doctrine_Parser::dump($models, 'yml', $tmpSchemaPath);
}
}
$options = array('generateBaseClasses' => true, 'generateTableClasses' => true, 'packagesPath' => sfConfig::get('sf_plugins_dir'), 'packagesPrefix' => 'Plugin', 'suffix' => '.class.php', 'baseClassesDirectory' => 'base', 'baseClassName' => 'sfDoctrineRecord');
$options = array_merge($options, sfConfig::get('doctrine_model_builder_options', array()));
$import = new Doctrine_Import_Schema();
$import->setOptions($options);
$import->importSchema(array($tmpPath, $config['yaml_schema_path']), 'yml', $config['models_path']);
}
示例3: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$config = $this->getCliConfig();
$pluginSchemaDirectories = glob(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'doctrine');
$pluginSchemas = sfFinder::type('file')->name('*.yml')->in($pluginSchemaDirectories);
$tmpPath = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp';
if (!file_exists($tmpPath)) {
Doctrine_Lib::makeDirectories($tmpPath);
}
foreach ($pluginSchemas as $schema) {
$schema = str_replace('/', DIRECTORY_SEPARATOR, $schema);
$plugin = str_replace(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR, '', $schema);
$e = explode(DIRECTORY_SEPARATOR, $plugin);
$plugin = $e[0];
$name = basename($schema);
$tmpSchemaPath = $tmpPath . DIRECTORY_SEPARATOR . $plugin . '-' . $name;
$models = Doctrine_Parser::load($schema, 'yml');
if (!isset($models['package'])) {
$models['package'] = $plugin . '.lib.model.doctrine';
}
Doctrine_Parser::dump($models, 'yml', $tmpSchemaPath);
}
$import = new Doctrine_Import_Schema();
$import->setOption('generateBaseClasses', true);
$import->setOption('generateTableClasses', true);
$import->setOption('packagesPath', sfConfig::get('sf_plugins_dir'));
$import->setOption('packagesPrefix', 'Plugin');
$import->setOption('suffix', '.class.php');
$import->setOption('baseClassesDirectory', 'generated');
$import->setOption('baseClassName', 'sfDoctrineRecord');
$import->importSchema(array($tmpPath, $config['yaml_schema_path']), 'yml', $config['models_path']);
$this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('doctrine', 'Generated models successfully'))));
}
示例4: _printResults
protected function _printResults($array)
{
$yaml = Doctrine_Parser::dump($array, 'yml');
$lines = explode("\n", $yaml);
unset($lines[0]);
foreach ($lines as $yamlLine) {
$line = trim($yamlLine);
if ($line) {
$this->notify($yamlLine);
}
}
}
示例5: printResults
protected function printResults($data)
{
$array = $data->toArray(true);
$yaml = Doctrine_Parser::dump($array, 'yml');
$lines = explode("\n", $yaml);
unset($lines[0]);
$lines[1] = $data->getTable()->getOption('name') . ':';
foreach ($lines as $yamlLine) {
$line = trim($yamlLine);
if ($line) {
$this->notify($yamlLine);
}
}
}
示例6: exportSchema
/**
* exportSchema
*
* @param string $schema
* @param string $directory
* @return string $string of data in the specified format
* @return void
*/
public function exportSchema($schema, $format = 'yml', $directory = null, $models = array())
{
$array = $this->buildSchema($directory, $models);
if (is_dir($schema)) {
$schema = $schema . DIRECTORY_SEPARATOR . 'schema.' . $format;
}
return Doctrine_Parser::dump($array, $format, $schema);
}
示例7: exportTo
/**
* Export a Doctrine_Collection to one of the supported Doctrine_Parser formats
*
* @param string $type
* @param string $deep
* @return void
*/
public function exportTo($type, $deep = false)
{
if ($type == 'array') {
return $this->toArray($deep);
} else {
return Doctrine_Parser::dump($this->toArray($deep, true), $type);
}
}
示例8: dumpData
/**
* dumpData
*
* Dump the prepared data to the fixtures files
*
* @param string $array
* @return void
*/
public function dumpData(array $data)
{
$directory = $this->getDirectory();
$format = $this->getFormat();
if ($this->exportIndividualFiles()) {
if (is_array($directory)) {
throw new Doctrine_Data_Exception('You must specify a single path to a folder in order to export individual files.');
} else {
if (!is_dir($directory) && is_file($directory)) {
$directory = dirname($directory);
}
}
foreach ($data as $className => $classData) {
if (!empty($classData)) {
Doctrine_Parser::dump(array($className => $classData), $format, $directory . DIRECTORY_SEPARATOR . $className . '.' . $format);
}
}
} else {
if (is_dir($directory)) {
$directory .= DIRECTORY_SEPARATOR . 'data.' . $format;
}
if (!empty($data)) {
return Doctrine_Parser::dump($data, $format, $directory);
}
}
}
示例9: generateYaml
protected function generateYaml($schemaPath, $directory = null, $models = array(), $modelLoading = null)
{
$currentProjectModels = (array) sfYaml::load($schemaPath);
$export = new Doctrine_Export_Schema();
$newProjectModels = $export->buildSchema($directory, $models, $modelLoading);
$projectModels = array_merge($currentProjectModels, $newProjectModels);
if (is_dir($schemaPath)) {
$schemaPath = $schemaPath . DIRECTORY_SEPARATOR . 'schema.yml';
}
return Doctrine_Parser::dump($projectModels, 'yml', $schemaPath);
}
示例10: getFormatData
public function getFormatData($format)
{
$method = 'get' . ucfirst($format) . 'FormatData';
if (method_exists($this->getContentTypeClassName(), $method)) {
return $this->getRecord()->{$method}();
} else {
if (method_exists($this, $method)) {
$data = $this->{$method}();
} else {
$data = $this->getDefaultFormatData();
}
}
return Doctrine_Parser::dump($this->{$method}(), $format);
}