Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PSR-11 ContainerInterface (#713) #714

Merged
merged 2 commits into from
Feb 19, 2018
Merged

Add PSR-11 ContainerInterface (#713) #714

merged 2 commits into from
Feb 19, 2018

Conversation

kubk
Copy link

@kubk kubk commented Feb 17, 2018

Related issue: #713

@mpociot
Do I have to add ContainerInterface $container = null to BotManFactory::create method?

public static function create(
array $config,
CacheInterface $cache = null,
Request $request = null,
StorageInterface $storageDriver = null
) {
if (empty($cache)) {

@codecov
Copy link

codecov bot commented Feb 17, 2018

Codecov Report

Merging #714 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #714      +/-   ##
============================================
+ Coverage     83.44%   83.49%   +0.04%     
- Complexity      552      554       +2     
============================================
  Files            46       46              
  Lines          1450     1454       +4     
============================================
+ Hits           1210     1214       +4     
  Misses          240      240
Impacted Files Coverage Δ Complexity Δ
src/BotMan.php 89.15% <100%> (+0.2%) 73 <1> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 021f1e5...a81bdab. Read the comment docs.

@mpociot mpociot merged commit bdc39b2 into botman:master Feb 19, 2018
@mpociot
Copy link
Member

mpociot commented Feb 19, 2018

Thank you - the setter is just fine.
I will also update the BotMan Service Provider for Laravel, to make use of this.

DigicreateJens pushed a commit to DigicreateJens/botman that referenced this pull request Apr 29, 2019
* Add PSR-11 ContainerInterface (botman#713)

* fix cs
sasha-x pushed a commit to botman-fork/botman that referenced this pull request Dec 26, 2019
* Add PSR-11 ContainerInterface (botman#713)

* fix cs
sh41 added a commit to sh41/botman that referenced this pull request Mar 17, 2020
This adds new method to the HandlesConversations trait to allow Conversations to take advantage of the PSR11 interface added in botman#714.

Allows conversations to be initiated like this:
```php
$botman->setContainer($psr11Container);

$botman->hears('Hello', function($bot) {
    $bot->startConversationService(OnboardingConversation::class);
});
```
I did think to modify the HandlesConversations::startConversation function but would have needed to change the signature to allow a string to be passed as the first argument which might cause BC issues. I've added tests for all existing tests that called the HandlesConversations::startConversation function and modified them to use HandlesConversations::startConversationService.

The most interesting tests are `it_can_start_conversations_from_container_services` and `it_can_start_conversations_from_container_services_and_those_conversations_can_call_dependencies` as these show the functionality that I was trying to add.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants