Created
February 17, 2015 10:43
-
-
Save cedricziel/94b27abaab6eae6b2c2e to your computer and use it in GitHub Desktop.
External Service Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooController extends ActionController { | |
/** | |
* @var \Vnd\Ext\Service\ItemService | |
* @inject | |
*/ | |
protected $itemService; | |
pubflic function fooAction() { | |
// Simple here, dont forget proper exception handling | |
$this->view->assign('items', $this->itemService->getProcessedItems()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ItemService implements SingletonInterface { | |
/** | |
* @var \Vnd\Ext\Domain\Repository\ItemRepository | |
* @inject | |
*/ | |
protected $itemRepository = NULL; | |
/** | |
* @var \Vnd\Ext\Service\ItemWebservice | |
* @inject | |
*/ | |
protected $itemWebService = NULL; | |
public function initializeObject() { | |
// prepare your webservervice or whatever | |
} | |
public function getProcessedItems() { | |
$items = $this->itemRepository->findByParamter('..'); | |
// process items with your webservice | |
$processedItems = array(); | |
foreach ($items as $item) { | |
processedItems[] = $ths->itemWebService->checkAvailability($item); | |
} | |
return $processedItems; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment