Пример #1
0
 /**
  * Creates an array with datasources found in the configuration
  * file with the passed name.
  *
  * @param string $filename      The filename to initialize the datasources from
  * @param string $containerName The name of the container the datasource can be used in
  *
  * @return array
  */
 public function initFromFile($filename, $containerName = '')
 {
     // initialize the configuration and load the data from the passed file
     $configuration = new Configuration();
     $configuration->initFromFile($filename);
     // iterate over the found datasources, append them to the array and return the array
     $datasourceNodes = array();
     foreach ($configuration->getChilds('/datasources/datasource') as $datasourceConfiguration) {
         // Add the information about the container name here
         $datasourceConfiguration->appendData(array('containerName' => $containerName));
         // Instantiate the datasource node using the configuration
         $datasourceNode = $this->newInstance('\\AppserverIo\\Appserver\\Core\\Api\\Node\\DatasourceNode');
         $datasourceNode->initFromConfiguration($datasourceConfiguration);
         $datasourceNodes[$datasourceNode->getPrimaryKey()] = $datasourceNode;
     }
     return $datasourceNodes;
 }
 /**
  * Returns an array with initialized parameters.
  *
  * @return array<\AppserverIo\Appserver\Core\Api\Node\ParamNode> The array with params
  */
 public function getParamNodes()
 {
     $configuration = new Configuration();
     $configuration->initFromFile(__DIR__ . '/_files/params.xml');
     $params = array();
     foreach ($configuration->getChilds('/params/param') as $paramConfiguration) {
         $paramNode = new ParamNode();
         $paramNode->initFromConfiguration($paramConfiguration);
         $params[$paramNode->getName()] = $paramNode;
     }
     return $params;
 }
Пример #3
0
 /**
  * Returns a dummy deployment configuration.
  *
  * @return \AppserverIo\Configuration\Configuration A dummy deployment configuration
  */
 public function getDeploymentConfiguration()
 {
     $configuration = new Configuration();
     $configuration->initFromFile(__DIR__ . '/../../../_files/appserver_container_deployment.xml');
     return $configuration;
 }
Пример #4
0
 /**
  * Tests if the initialization from a configuration instance works as expected.
  *
  * @return void
  */
 public function testInitFromConfiguration()
 {
     // initialize the configuration
     $configuration = new Configuration();
     $configuration->initFromFile(__DIR__ . '/_files/location.xml');
     // initialize the location node
     $this->location->setNodeName('location');
     $this->location->initFromConfiguration($configuration);
     // validate the node
     $this->validate();
 }
Пример #5
0
 /**
  * Merges this configuration element with the data found in the passed configuration file.
  *
  * @param string $file The path to the file we want to merge
  *
  * @return \AppserverIo\Configuration\Interfaces\ConfigurationInterface The configuration created from the passed file
  */
 public function mergeFromFile($file)
 {
     // initialize a new configuration instance
     $configuration = new Configuration();
     $configuration->initFromFile($file);
     // merge the instance with this one
     $this->merge($configuration);
     // return this instance
     return $configuration;
 }
Пример #6
0
 /**
  * Initialise from file
  *
  * @param string $filename The filename as string
  *
  * @return void
  */
 public function initFromFile($filename)
 {
     $configuration = new Configuration();
     $configuration->initFromFile($filename);
     $this->initFromConfiguration($configuration);
 }