/**
  * Return's the singleton instance and creates a new one if necessary.
  *
  * @return \AppserverIo\Properties\PropertiesUtil The singleton instance
  */
 public static function singleton()
 {
     // query whether or not we've already an instance created
     if (PropertiesUtil::$instance == null) {
         PropertiesUtil::$instance = new PropertiesUtil();
     }
     // return the singleton instance
     return PropertiesUtil::$instance;
 }
示例#2
0
 /**
  * Recursively replace variables in the string properties of this node with
  * the values found in the passed properties instance.
  *
  * @param \AppserverIo\Properties\PropertiesInterface $properties The properties with the values to replace
  * @param string                                      $pattern    The pattern that declares the variables
  *
  * @return void
  */
 public function replaceProperties(PropertiesInterface $properties, $pattern = PropertyStreamFilterParams::PATTERN)
 {
     // create a reflection object of the node instance
     $reflectionObject = new \ReflectionObject($this);
     // load the properties utility to replace the propertis in the members
     $propertiesUtil = PropertiesUtil::singleton();
     // ONLY use PROTECTED properties, NOT PRIVATE, else UUID's will be overwritten!!
     foreach ($reflectionObject->getProperties(\ReflectionProperty::IS_PROTECTED) as $reflectionProperty) {
         // replace the properties in all string properties
         if (is_string($this->{$reflectionProperty->getName()})) {
             $this->{$reflectionProperty->getName()} = $propertiesUtil->replacePropertiesInString($properties, $this->{$reflectionProperty->getName()}, $pattern);
         }
         // recursively invoke the method on the sibeling nodes
         if (is_array($this->{$reflectionProperty->getName()})) {
             foreach ($this->{$reflectionProperty->getName()} as $node) {
                 if ($node instanceof NodeInterface) {
                     $node->replaceProperties($properties, $pattern);
                 }
             }
         }
         // recursively invoke the method on the sibeling nodes
         if ($this->{$reflectionProperty->getName()} instanceof NodeInterface) {
             $this->{$reflectionProperty->getName()}->replaceProperties($properties, $pattern);
         }
         // recursively invoke the method on the sibeling nodes
         if ($this->{$reflectionProperty->getName()} instanceof ValueInterface) {
             $this->{$reflectionProperty->getName()}->replaceProperties($properties, $pattern);
         }
     }
 }
示例#3
0
 /**
  * Replace the variables in the node's value with the values found in the
  * passed properties instance.
  *
  * @param \AppserverIo\Properties\PropertiesInterface $properties The properties with the values to replace
  * @param string                                      $pattern    The pattern that declares the variables
  *
  * @return void
  */
 public function replaceProperties(PropertiesInterface $properties, $pattern = PropertyStreamFilterParams::PATTERN)
 {
     // query whether or not the node value is a string
     if (is_string($this->value)) {
         // load the properties utility and replace the properties in the node value
         $this->value = PropertiesUtil::singleton()->replacePropertiesInString($properties, $this->value, $pattern);
     }
 }