示例#1
0
 /**
  * @param $filename
  * @return Yamlarh
  * @throws \Exception
  */
 protected function getNewYamlarh($filename)
 {
     $yamlarh = new Yamlarh($filename);
     $yamlarh->setAccessibleVariable($this->yamlarh->getAccessibleVariable());
     $yamlarh->setParamaterKey($this->yamlarh->getParamaterKey());
     $yamlarh->setNodes($this->yamlarh->getNodes());
     return $yamlarh;
 }
示例#2
0
 /**
  * Extend from a yml file
  * @param string $file
  */
 public function addExtendFromFile($file)
 {
     if (!is_file($file)) {
         return;
     }
     $yamlarh = new Yamlarh($file);
     if (empty($yamlarh)) {
         return;
     }
     $parsedYml = $yamlarh->parse();
     foreach ($parsedYml as $extendNodeName => $extendNodeNameInfo) {
         $this->addExtendFromArray($extendNodeName, $extendNodeNameInfo);
     }
 }
示例#3
0
 /**
  * @param BeanPropertyListener $beanPropertyListener
  */
 public function setBeanPropertyListener(BeanPropertyListener $beanPropertyListener)
 {
     if ($beanPropertyListener === $this->beanPropertyListener) {
         return;
     }
     $this->beanPropertyListener = $beanPropertyListener;
     $beanPropertiesToInject = [];
     $registers = $this->beanPropertyListener->getRegisters();
     foreach ($registers as $eventName => $className) {
         $propertyName = explode('.', $eventName);
         $propertyName = $propertyName[count($propertyName) - 1];
         $validation = $className::getValidation();
         if ($validation === null) {
             continue;
         }
         $beanPropertiesToInject[$propertyName] = $validation;
     }
     $this->yamlarh->addAccessibleVariable(self::YAMLARHBEANPROPERTY, $beanPropertiesToInject);
 }
示例#4
0
 private function injectYaml($yamls, $beanId)
 {
     $array = array();
     if (!is_array($yamls)) {
         $yamls = array($yamls);
     }
     foreach ($yamls as $key => $yaml) {
         if ($this->isNotFileAbsolute($yaml)) {
             $yaml = $this->pathinfoContext['dirname'] . '/' . $yaml;
         } else {
             $yaml = ROOT . '/' . $yaml;
         }
         try {
             $yamlArh = new Yamlarh($yaml);
             $array[$key] = $yamlArh->parse();
         } catch (Exception $e) {
             throw new IocArtException("Error in bean '" . $beanId . "': " . $e->getMessage());
         }
     }
     return $array;
 }
示例#5
0
 private function parseYaml()
 {
     $this->sphringEventDispatcher->dispatch(SphringEventEnum::SPHRING_START_LOAD_CONTEXT, new EventSphring($this));
     if (empty($this->context)) {
         $this->context = $this->yamlarh->parse();
     }
     $this->sphringEventDispatcher->dispatch(SphringEventEnum::SPHRING_FINISHED_LOAD_CONTEXT, new EventSphring($this));
 }
packages:
    - "arhframe/yamlarh: 1.*"
CONFIG;
// you need melody: https://github.com/sensiolabs/melody
$template = __DIR__ . '/../template/plugin-description.yml';
use Arhframe\Yamlarh\Yamlarh;
use Symfony\Component\Yaml\Yaml;
$output = __DIR__ . '/../../repo-index.yml';
if (is_file($output)) {
    $currentData = Yaml::parse(file_get_contents($output));
    $date = date('Y-m-d', $currentData['plugins']['created']);
} else {
    $date = date('Y-m-d');
}
$date_updated = date('Y-m-d');
$yamlarh = new Yamlarh($template);
$data = $yamlarh->parse();
$binaries =& $data['plugins']['binaries'];
foreach ($binaries as &$binary) {
    $path = pathinfo($binary['url'], PATHINFO_BASENAME);
    $checksum = sha1_file(__DIR__ . '/../../out/' . $path);
    $binary['checksum'] = $checksum;
}
$dataString = Yaml::dump($data, 10, 2);
//sanitize just for repo-index.yml in cloudfoundry community plugin repo
$dataString = str_replace("'", "", $dataString);
$dataString = str_replace("null", "", $dataString);
$dataString = str_replace("\n    -", "", $dataString);
$dataString = str_replace("  platform:", "- platform:", $dataString);
$dataString = str_replace("authors:\n      name:", "authors:\n    - name:", $dataString);
/*******************************/
示例#7
0
 /**
  * @param $file
  * @return array
  */
 public function loadYml($file)
 {
     $yamlArh = new Yamlarh($file);
     return $yamlArh->parse();
 }