-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationFinder.php
More file actions
38 lines (30 loc) · 975 Bytes
/
ApplicationFinder.php
File metadata and controls
38 lines (30 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Redeye\StormpathBundle;
use Stormpath\DataStore\DataStore;
use Stormpath\Resource\Tenant;
use Stormpath\Resource\Application;
use Redeye\StormpathBundle\Exception\ApplicationNotFoundException;
class ApplicationFinder
{
protected $dataStore;
protected $tenant;
public function __construct(DataStore $dataStore, Tenant $tenant)
{
$this->dataStore = $dataStore;
$this->tenant = $tenant;
}
public function findApplicationWithHref($href)
{
return $this->dataStore->getResource($href, Application::class);
}
public function findApplicationNamed($applicationName)
{
$apps = $this->tenant->getApplications();
$apps->search = array('name' => $applicationName);
if (!$apps->getIterator()->valid()) {
throw new ApplicationNotFoundException($applicationName);
}
$application = $apps->getIterator()->current();
return $application;
}
}