Elastica\Snapshot::getRepository PHP Method

getRepository() public method

Retrieve a repository record by name.
public getRepository ( string $name ) : array
$name string the name of the desired repository
return array
    public function getRepository($name)
    {
        try {
            $response = $this->request($name);
        } catch (ResponseException $e) {
            if ($e->getResponse()->getStatus() == 404) {
                throw new NotFoundException("Repository '" . $name . "' does not exist.");
            }
            throw $e;
        }
        $data = $response->getData();
        return $data[$name];
    }

Usage Example

 /**
  * @group functional
  */
 public function testRegisterRepository()
 {
     $repositoryName = 'testrepo';
     $location = $this->_snapshotPath . 'backup1';
     $response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location));
     $this->assertTrue($response->isOk());
     $response = $this->_snapshot->getRepository($repositoryName);
     $this->assertEquals($location, $response['settings']['location']);
     // attempt to retrieve a repository which does not exist
     $this->setExpectedException('Elastica\\Exception\\NotFoundException');
     $this->_snapshot->getRepository('foobar');
 }
All Usage Examples Of Elastica\Snapshot::getRepository