Skip to content

Commit 7579627

Browse files
authored
Add helper function for creating services (#39)
1 parent ce1b2ef commit 7579627

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Api.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Shopify;
44

5+
use Shopify\Service\AbstractService;
56
use Shopify\Storage\PersistentStorageInterface;
67
use Shopify\Storage\SessionStorage;
78
use Shopify\Helper\OAuthHelper;
@@ -145,6 +146,17 @@ public function getOAuthHelper()
145146
return new OAuthHelper($this, $this->getStorageInterface());
146147
}
147148

149+
/**
150+
* Helper function to create new service instances
151+
*
152+
* @param $serviceClass Fully Qualified Service className
153+
* @return AbstractService
154+
*/
155+
public function createService($serviceClass)
156+
{
157+
return new $serviceClass($this);
158+
}
159+
148160
public function loadApiKeyFromEnv()
149161
{
150162
$this->api_key = getenv(self::SHOPIFY_API_KEY_NAME);

0 commit comments

Comments
 (0)