コード例 #1
0
 public function getOrCreateValue($section, $key)
 {
     $value = $this->getValues()->filter(function (ConfigValue $item) use($key, $section) {
         return $item->getName() == $key && $item->getSection() == $section;
     });
     if ($value->first() === false) {
         $value = new ConfigValue();
         $value->setConfig($this)->setName($key)->setSection($section);
     } else {
         $value = $value->first();
     }
     return $value;
 }
コード例 #2
0
ファイル: Config.php プロジェクト: xamin123/platform
 /**
  * Return value object related to this config found by given criteria, or creates new one otherwise
  *
  * @param string $section
  * @param string $name
  *
  * @return ConfigValue
  */
 public function getOrCreateValue($section, $name)
 {
     $values = $this->getValues()->filter(function (ConfigValue $item) use($name, $section) {
         return $item->getName() == $name && $item->getSection() == $section;
     });
     /** @var ArrayCollection $values */
     if ($values->first() === false) {
         $value = new ConfigValue();
         $value->setConfig($this);
         $value->setName($name);
         $value->setSection($section);
     } else {
         $value = $values->first();
     }
     return $value;
 }
 /**
  * {@inheritDoc}
  */
 public function setConfig($config)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setConfig', array($config));
     return parent::setConfig($config);
 }