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

load() public method

Returns the datasource with the passed UUID.
See also: AppserverIo\Appserver\Core\Api\ServiceInterface::load()
public load ( string $uuid ) : DatasourceNode
$uuid string UUID of the datasource to return
return AppserverIo\Appserver\Core\Api\Node\DatasourceNode The datasource with the UUID passed as parameter
    public function load($uuid)
    {
        foreach ($this->findAll() as $datasourceNode) {
            if ($datasourceNode->getPrimaryKey() == $uuid) {
                return $datasourceNode;
            }
        }
    }

Usage Example

 /**
  * Test if the load() method returns the NULL for an invalid primary key.
  *
  * @return null
  */
 public function testLoadWithInvalidPrimaryKey()
 {
     $this->assertNull($this->service->load('invalidPrimaryKey'));
 }