| Conditions | 5 |
| Paths | 7 |
| Total Lines | 30 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 44 | public function handleInternal() |
||
| 45 | { |
||
| 46 | $publisherId = (string) $this->input->getArgument('publisher'); |
||
| 47 | $route = (string) $this->input->getOption('route'); |
||
| 48 | $data = ''; |
||
| 49 | |||
| 50 | if (! $this->carrot->container()->publishers()->has($publisherId)) { |
||
| 51 | $this->error(vsprintf('Publisher "%s" not found.', [$publisherId])); |
||
| 52 | return 0; |
||
| 53 | } |
||
| 54 | |||
| 55 | $publisher = $this->carrot->container()->publishers()->get($publisherId); |
||
| 56 | |||
| 57 | while (! feof(STDIN)) { |
||
| 58 | $data .= fread(STDIN, 8192); |
||
| 59 | } |
||
| 60 | |||
| 61 | if (empty($data)) { |
||
| 62 | return 0; |
||
| 63 | } |
||
| 64 | |||
| 65 | $message = MessageBuilder::create()->body($data)->build(); |
||
| 66 | |||
| 67 | if (! empty($route)) { |
||
| 68 | $message->setRoutingKey($route); |
||
| 69 | } |
||
| 70 | |||
| 71 | $publisher->publish($message); |
||
| 72 | |||
| 73 | return 0; |
||
| 74 | } |
||
| 77 |