當前位置: 首頁>>代碼示例>>PHP>>正文


PHP yaml_emit函數代碼示例

本文整理匯總了PHP中yaml_emit函數的典型用法代碼示例。如果您正苦於以下問題:PHP yaml_emit函數的具體用法?PHP yaml_emit怎麽用?PHP yaml_emit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了yaml_emit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的yaml_emit函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。