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

findAllByName() public method

Returns an array with the datasources with the passed name.
public findAllByName ( string $name ) : array
$name string Name of the datasource to return
return array The datasources with the name passed as parameter
    public function findAllByName($name)
    {
        $datasourceNodes = array();
        foreach ($this->findAll() as $datasourceNode) {
            if ($datasourceNode->getName() === $name) {
                $datasourceNodes[$datasourceNode->getPrimaryKey()] = $datasourceNode;
            }
        }
        return $datasourceNodes;
    }

Usage Example

 /**
  * Test if the findAllByName() method returns the correct number of elements.
  *
  * @return null
  */
 public function testFindAllByName()
 {
     $this->assertCount(0, $this->service->findAllByName('api'));
 }