本文整理汇总了PHP中yaml_emit函数的典型用法代码示例。如果您正苦于以下问题:PHP yaml_emit函数的具体用法?PHP yaml_emit怎么用?PHP yaml_emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yaml_emit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: emitFile
public static function emitFile($data, $file)
{
if (file_exists($file) and !is_writable($file)) {
throw new pakeException('Not enough rights to overwrite "' . $file . '"');
}
$dir = dirname($file);
pake_mkdirs($dir);
if (!is_writable($dir)) {
throw new pakeException('Not enough rights to create file in "' . $dir . '"');
}
if (extension_loaded('yaml')) {
// not yet implemented:
// yaml_emit_file($file, $data);
// so using this instead:
if (false === file_put_contents($file, yaml_emit($data))) {
throw new pakeException("Couldn't create file");
}
} else {
sfYaml::setSpecVersion('1.1');
// more compatible
$dumper = new sfYamlDumper();
if (false === file_put_contents($file, $dumper->dump($data, 1))) {
throw new pakeException("Couldn't create file");
}
}
pake_echo_action('file+', $file);
}
开发者ID:piotras,项目名称:pake,代码行数:27,代码来源:pakeYaml.class.php
示例2: serialize
public function serialize()
{
if (!$this->object instanceof \Serializable) {
throw new \Exception('Object is not an instance of Serializable.');
}
return \yaml_emit($this->object->serialize());
}
开发者ID:kidaa,项目名称:evedata,代码行数:7,代码来源:YamlModel.php
示例3: encode
/**
* @param mixed $data
* @param string $format
* @param array $context
*
* @return string
*/
public function encode($data, $format, array $context = array())
{
if ($this->native) {
return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
}
return $this->encoder->dump($data);
}
开发者ID:mihai-stancu,项目名称:serializer,代码行数:14,代码来源:YamlEncoder.php
示例4: do_serialize
/**
* @see sys/app/driver/serializer/ArraySerializer#do_serialize()
*/
public function do_serialize()
{
$result = parent::do_serialize();
$syck = yaml_emit($result);
$syck = preg_replace('#"([^"]+)":#m', '$1:', $syck);
return $syck;
}
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:10,代码来源:yaml_serializer.php
示例5: _sendContent
/**
* Sends a content string to the client.
*
* If the content is a callable, it is invoked. The callable should either
* return a string or output content directly and have no return value.
*
* @param array|string $content String to send as response body or callable
* which returns/outputs content.
* @return void
*/
protected function _sendContent($content)
{
if (is_array($content)) {
$content = yaml_emit($content);
}
parent::_sendContent($content);
}
开发者ID:coretyson,项目名称:coretyson,代码行数:17,代码来源:YamlResponse.php
示例6: __invoke
public function __invoke($data)
{
set_error_handler($this->generateErrorHandler($data));
$parsed = yaml_emit($data);
restore_error_handler();
return $parsed;
}
开发者ID:europaphp,项目名称:europaphp,代码行数:7,代码来源:Yml.php
示例7: to
/**
* {@inheritdoc}
*/
public function to(array $data, $comments = null)
{
if ($comments) {
return $comments . PHP_EOL . yaml_emit($data);
}
return yaml_emit($data);
}
开发者ID:mcuadros,项目名称:cli-array-editor,代码行数:10,代码来源:YAML.php
示例8: exec
public function exec()
{
try {
$mod_cnf = yaml_parse_file(__DIR__ . '/../../../../conf/module.yml');
if (false === $mod_cnf) {
throw new \err\ComErr('could not read module config file', 'please check ' . __DIR__ . '/../../../../conf/module.yml');
}
for ($loop = 0; $loop < count($mod_cnf); $loop++) {
/* check for the module name(*chkmod) 'select' value is 'true' */
if (true === $mod_cnf[$loop]['select'] && 0 === strcmp($this->parm, $mod_cnf[$loop]['name'])) {
/* nothing to do */
/* it is already selected if chkmod and specified module name is same */
return;
}
$mod_cnf[$loop]['select'] = false;
if (0 === strcmp($this->parm, $mod_cnf[$loop]['name'])) {
/* switching 'select' value(true) from module config */
$mod_cnf[$loop]['select'] = true;
}
}
/* edit module config from (spac dir)/conf/module.yml */
if (false === copy(__DIR__ . '/../../../../conf/module.yml', __DIR__ . '/../../../../conf/module.yml_')) {
throw new \err\ComErr('could not create backup of module config', 'please check ' . __DIR__ . '/../../../../conf');
}
if (false === file_put_contents(__DIR__ . '/../../../../conf/module.yml', yaml_emit($mod_cnf))) {
throw new \err\ComErr('could not edit module config file', 'please check ' . __DIR__ . '/../../../../conf/module.yml');
}
unlink(__DIR__ . '/../../../../conf/module.yml_');
echo 'switched generater module ' . $this->parm . PHP_EOL;
} catch (\Exception $e) {
throw $e;
}
}
开发者ID:simpart,项目名称:trut,代码行数:33,代码来源:ModSelect.php
示例9: buildFile
function buildFile()
{
$updated_date = strtotime($_POST['date']) > time() ? $_POST['date'] : date("Y-m-d");
$content = array('rss' => false, 'layout' => 'update', 'published' => $_POST['published'] == 'true' ? true : false, 'title' => $_POST['title'], 'date' => $_POST['date'], 'article' => array('written_on' => $_POST['date'], 'updated_on' => $updated_date), 'authors' => array($_POST['author']), 'collection' => 'updates', 'type' => $_POST['type'], 'category' => $_POST['product'] == 'none' || $_POST['product'] == 'chrome' ? 'generic' : 'tools');
$content['product'] = $_POST['product'];
if ($_POST['tags']) {
$content['tags'] = preg_split("/[\\s,]+/", $_POST['tags']);
}
if ($_POST['description']) {
$content['description'] = $_POST['description'];
}
if ($_POST['featured-image']) {
$content['featured-image'] = $_POST['featured-image'];
}
if ($_POST['source_name']) {
$content['source_name'] = $_POST['source_name'];
}
if ($_POST['source_url']) {
$content['source_url'] = $_POST['source_url'];
}
$content['permalink'] = '/updates/' . str_replace('-', '/', $_POST['date']) . '/' . slugify($_POST['title']) . '.html';
$file = yaml_emit($content, YAML_UTF8_ENCODING);
// we need to replace the weird ... block at bottom with a valid front matter ---
$file = str_replace('...', '---', $file);
// additionally, Jekyll doesn't like dates as string, so fix
$file = str_replace('"' . $_POST['date'] . '"', $_POST['date'], $file);
$file = str_replace('"' . $updated_date . '"', $updated_date, $file);
return $file . $_POST['content'];
}
开发者ID:devbeta,项目名称:WebFundamentals,代码行数:29,代码来源:functions.php
示例10: write
public function write()
{
$output = PKWK_YAMLCONFIG_HEAD . yaml_emit($this->getArrayCopy()) . PKWK_YAMLCONFIG_TAIL;
$source = get_source($this->page, TRUE, TRUE);
$source = $source != FALSE && preg_match(PKWK_YAMLCONFIG_PATTERN, $source) ? preg_replace(PKWK_YAMLCONFIG_PATTERN, $output, $source) : $output;
page_write($this->page, $source);
return $source;
}
开发者ID:TakeAsh,项目名称:php-TakeAsh-PKWK-Mod,代码行数:8,代码来源:yamlconfig.php
示例11: run
/**
* write yaml to file
*
* @param string $path
* @param mixed $data
*/
function run($path, $data)
{
if (extension_loaded('yaml')) {
$this->logAction('yaml', $path);
Helper::put($path, yaml_emit($data));
} else {
$this->getLogger()->error('yaml extension not found.');
}
}
开发者ID:ravenscroftj,项目名称:GenPHP,代码行数:15,代码来源:WriteYamlOperation.php
示例12: toString
/**
* Write a config object to a YAML string.
*
* @param ObjectConfig $config
* @return string|false Returns a YAML encoded string on success. False on failure.
*/
public function toString()
{
$result = false;
if (function_exists('yaml_emit')) {
$data = $this->toArray();
$result = yaml_emit($data, \YAML_UTF8_ENCODING);
}
return $result;
}
开发者ID:janssit,项目名称:www.rvproductions.be,代码行数:15,代码来源:yaml.php
示例13: onEnable
public function onEnable()
{
@mkdir($this->getDataFolder());
if (!file_exists($this->getDataFolder() . "config.yml")) {
file_put_contents($this->getDataFolder() . "config.yml", yaml_emit(array()));
}
$this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML, ["Rules1" => "No right to Spam chatting!", "Rules2" => "No right to use mod", "Rules3" => "No right to contact admin to Give / Item", "Rules4" => "No right to Grief other players", "Rules5" => "No right to be rude in chat"]);
$this->getLogger()->info(TextFormat::GREEN . "-SimpleRules Enabled!");
}
开发者ID:AndreyNazarchuk,项目名称:Collection-Plugins-PocketMine-Prax,代码行数:9,代码来源:SimpleRules.php
示例14: actionMSDS
public function actionMSDS($args)
{
$cas_no = $args[0];
$msds = a('chemical/msds', ['cas_no' => $cas_no]);
if (!$msds->id) {
die("MSDS not found for {$cas_no}!\n");
}
echo yaml_emit($msds->getData()['_extra'], YAML_UTF8_ENCODING);
}
开发者ID:labmai,项目名称:chem-db,代码行数:9,代码来源:ChemDB.php
示例15: actionInfo
public function actionInfo($args)
{
$path = $args[0] ?: APP_ID;
$info = \Gini\Core::moduleInfo($path);
if ($info) {
$info = (array) $info;
unset($info['path']);
echo yaml_emit($info);
}
}
开发者ID:HuangStomach,项目名称:gini,代码行数:10,代码来源:App.php
示例16: encode
public static function encode($data)
{
if (!$data) {
return null;
}
$yaml = yaml_emit($data, YAML_UTF8_ENCODING, YAML_ANY_BREAK, ['mongo\\type\\DateTime' => 'self::bsonUnserialize', 'mongo\\type\\Timestamp' => 'self::bsonUnserialize', 'MongoDB\\BSON\\ObjectID' => 'self::bsonUnserialize', 'MongoDB\\BSON\\Binary' => 'self::bsonUnserialize', 'MongoDB\\BSON\\Javascript' => 'self::bsonUnserialize', 'MongoDB\\BSON\\Regex' => 'self::bsonUnserialize', 'MongoDB\\BSON\\MaxKey' => 'self::bsonUnserialize', 'MongoDB\\BSON\\MinKey' => 'self::bsonUnserialize']);
$yaml = preg_replace('/^---/', '', $yaml);
$yaml = preg_replace('/\\n\\.\\.\\.$/', '', $yaml);
return $yaml;
}
开发者ID:tany,项目名称:php-note,代码行数:10,代码来源:Yaml.php
示例17: actionList
public function actionList($args)
{
$cron = (array) \Gini\Config::get('cron');
foreach ($cron as &$job) {
if (!isset($job['schedule']) && $job['interval']) {
$job['schedule'] = $job['interval'];
unset($job['interval']);
}
}
echo yaml_emit($cron, YAML_UTF8_ENCODING);
}
开发者ID:iamfat,项目名称:gini,代码行数:11,代码来源:Cron.php
示例18: encode
/**
* {@inheritdoc}
*/
public static function encode($data)
{
static $init;
if (!isset($init)) {
ini_set('yaml.output_indent', 2);
// Do not break lines at 80 characters.
ini_set('yaml.output_width', -1);
$init = TRUE;
}
return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:14,代码来源:YamlPecl.php
示例19: saveStatus
/**
* @param $player
* @param $message
*/
public function saveStatus($player, $message)
{
@mkdir($this->getDataFolder());
file_put_contents($this->getDataFolder() . "WhatsUp/" . $player->getName() . ".yml", yaml_emit(["Status" => implode(" ", $message)]));
if (!empty($message)) {
$player->sendMessage(TXT::GREEN . "Successfully saved status as '" . implode(" ", $message) . "'.");
} else {
return;
}
return;
}
开发者ID:Artide,项目名称:PM-1.5-Plugins,代码行数:15,代码来源:WU.php
示例20: test_serialization
public function test_serialization()
{
$path = realpath(dirname(__FILE__)) . '/../../configuration/defaults.yml';
$data = yaml_parse(file_get_contents($path));
$serialized = yaml_emit($data);
$serialized2 = $this->_core->configuration->serialize($data);
if ($serialized === $serialized2) {
$this->assertTrue(true);
} else {
$this->assertTrue(false);
}
}
开发者ID:piotras,项目名称:midgardmvc_core,代码行数:12,代码来源:configuration.php
注:本文中的yaml_emit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论