Skip to content

Instantly share code, notes, and snippets.

@revsbech
Last active August 29, 2015 14:05
Show Gist options
  • Save revsbech/77331f59be2ec56d4dae to your computer and use it in GitHub Desktop.
Save revsbech/77331f59be2ec56d4dae to your computer and use it in GitHub Desktop.
<?php
class Tx_MocBeer_Domain_Model_Consumer {
/**
* @var Tx_MocBeer_Domain_Service_InventoryService
* @inject
*/
protected $inventoryService;
/**
* @param Tx_MocBeer_Domain_Service_InventoryService $service
*/
public function injectInventoryService(Tx_MocBeer_Domain_Service_InventoryService $service) {
$this->inventoryService = $service;
}
/**
* @param Tx_MocBeer_Domain_Model_Beer $beer
* @return void
*/
public function drinkBeer(Tx_MocBeer_Domain_Model_Beer $beer) {
$beer->open();
//@todo: Do actual drinking...
$this->inventoryService->removeBeerFromInventory($beer);
}
}
<?php
class Tx_MocBeer_Domain_Service_InventoryService implements t3lib_Singleton {
/**
* @param Tx_MocBeer_Domain_Model_Beer $beer
*/
public function removeBeerFromInventory(Tx_MocBeer_Domain_Model_Beer $beer) {
$message = date("d/m-Y H:i") . "\t" . $beer->getName() . ' removed from inventory';
file_put_contents(PATH_site . 'typo3temp/moc_beer.log', $message . PHP_EOL, FILE_APPEND);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment