コード例 #1
0
 /**
  * Tests the getData() method with an existing key.
  *
  * @return void
  */
 public function testGetDataAvailable()
 {
     $this->configuration->setData('foo', 'bar');
     $this->assertEquals('bar', $this->configuration->getData('foo'));
 }
コード例 #2
0
 /**
  * Sets the configuration by reflected property.
  *
  * @param \ReflectionProperty                                          $reflectionProperty The reflection property to set
  * @param \AppserverIo\Configuration\Interfaces\ConfigurationInterface $configuration      The configuration instance
  *
  * @return \AppserverIo\Configuration\Interfaces\ConfigurationInterface|void The configuration or nothing
  */
 public function setConfigurationByReflectionProperty(\ReflectionProperty $reflectionProperty, ConfigurationInterface $configuration)
 {
     // load the mapping from the annotation
     $mapping = $this->getPropertyTypeFromDocComment($reflectionProperty);
     // if the mapping OR the property itself is NULL, do nothing
     if ($mapping == null || $this->{$reflectionProperty->getName()} == null) {
         return;
     }
     // load the mappings node type
     $nodeType = $mapping->getNodeType();
     // if we have a node or a node value, export the data
     if (class_exists($nodeType) && $this->isValueClass($nodeType)) {
         return $configuration->setValue($this->{$reflectionProperty->getName()}->getValue());
     } elseif (class_exists($nodeType)) {
         return $configuration->addChild($this->{$reflectionProperty->getName()}->exportToConfiguration());
     }
     // if we have simple data type, export the value
     if (in_array($nodeType, array('integer', 'string', 'double', 'float', 'boolean'))) {
         return $configuration->setData($reflectionProperty->getName(), $this->{$reflectionProperty->getName()});
     }
     // if we have an array, export the array data
     if ($nodeType == 'array' && sizeof($this->{$reflectionProperty->getName()}) > 0) {
         return $this->appendConfigurationChild($reflectionProperty, $configuration, $mapping->getNodeName());
     }
 }