Skip to content

Instantly share code, notes, and snippets.

@cedricziel
Created February 17, 2015 10:43
Show Gist options
  • Save cedricziel/94b27abaab6eae6b2c2e to your computer and use it in GitHub Desktop.
Save cedricziel/94b27abaab6eae6b2c2e to your computer and use it in GitHub Desktop.
External Service Example
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());
}
}
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