AppserverIo\Appserver\Core\Api\DatasourceService::persist PHP Method

persist() public method

Persists the passed datasource.
public persist ( AppserverIo\Configuration\Interfaces\NodeInterface $datasourceNode ) : void
$datasourceNode AppserverIo\Configuration\Interfaces\NodeInterface The datasource to persist
return void
    public function persist(NodeInterface $datasourceNode)
    {
        $systemConfiguration = $this->getSystemConfiguration();
        $systemConfiguration->attachDatasource($datasourceNode);
        $this->setSystemConfiguration($systemConfiguration);
    }

Usage Example

 /**
  * Test if the load() method returns the correct app node.
  *
  * @return null
  */
 public function testLoad()
 {
     $datasourceNode = new DatasourceNode();
     $this->service->persist($datasourceNode);
     $this->assertSame($datasourceNode, $this->service->load($datasourceNode->getPrimaryKey()));
 }