Last active
December 19, 2015 15:09
-
-
Save castamir/5974238 to your computer and use it in GitHub Desktop.
Nette factories generated by interface
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
factories: | |
messagesManager: | |
factory: Factories\IMessagesManager |
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
<?php | |
namespace Factories; | |
use App\Controls\Messages\MessageControl; | |
interface IMessagesManager | |
{ | |
/** | |
* @return MessageControl | |
*/ | |
function create(); | |
} |
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
<?php | |
namespace App\IntranetModule; | |
use Factories\IMessagesManager; | |
use App\Controls\Messages\MessageControl; | |
class MessagePresenter extends BasePresenter | |
{ | |
/** @var IMessagesManager */ | |
public $messageManager; | |
/** | |
* @param IMessagesManager $messageManager | |
*/ | |
public final function injectMessageManager(IMessagesManager $messageManager) | |
{ | |
$this->messageManager = $messageManager; | |
} | |
/** | |
* @return MessageControl | |
*/ | |
protected function createComponentMessage() | |
{ | |
$control = $this->messageManager->create(); | |
// ... | |
return $control; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment