From 2c3d9cde3719a07539fddc24b5d3292f108b8d06 Mon Sep 17 00:00:00 2001 From: Matthew Large Date: Sat, 22 Apr 2017 17:17:41 +0100 Subject: [PATCH 1/2] Adding quick replies into Message Step --- src/Model/Step/AbstractStep.php | 2 +- src/Model/Step/Message.php | 20 +++++++++++++++++--- src/StepFactory.php | 14 ++++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/Model/Step/AbstractStep.php b/src/Model/Step/AbstractStep.php index 69ddb95..d62d3f5 100644 --- a/src/Model/Step/AbstractStep.php +++ b/src/Model/Step/AbstractStep.php @@ -61,4 +61,4 @@ public function getEntities() { return $this->entities; } -} +} \ No newline at end of file diff --git a/src/Model/Step/Message.php b/src/Model/Step/Message.php index 64581ff..c4e6d68 100644 --- a/src/Model/Step/Message.php +++ b/src/Model/Step/Message.php @@ -11,14 +11,20 @@ class Message extends AbstractStep */ private $message; + /** + * @var array + */ + private $quickreplies; + /** * @param string $message * @param float $confidence * @param array $entities + * @param array $quickreplies */ - public function __construct($message, $confidence, array $entities = []) + public function __construct($message, $confidence, array $entities = [], array $quickreplies = []) { - parent::__construct(Step::TYPE_MESSAGE, $confidence, $entities); + parent::__construct(Step::TYPE_MESSAGE, $confidence, $entities, $quickreplies); $this->message = $message; } @@ -29,4 +35,12 @@ public function getMessage() { return $this->message; } -} + + /** + * @return array + */ + public function getQuickReplies() + { + return $this->quickreplies; + } +} \ No newline at end of file diff --git a/src/StepFactory.php b/src/StepFactory.php index 9ed1dae..e4753a0 100644 --- a/src/StepFactory.php +++ b/src/StepFactory.php @@ -39,6 +39,16 @@ private static function getEntitiesFromStepData(array $step = []) return isset($step['entities']) ? $step['entities'] : []; } + /** + * @param array $step + * + * @return array + */ + private static function getQuickRepliesFromStepData(array $step = []) + { + return isset($step['quickreplies']) ? $step['quickreplies'] : []; + } + /** * @param array $step * @@ -66,7 +76,7 @@ public static function createMergeStep(array $step) */ public static function createMessageStep(array $step) { - return new Message($step['msg'], $step['confidence'], self::getEntitiesFromStepData($step)); + return new Message($step['msg'], $step['confidence'], self::getEntitiesFromStepData($step), self::getQuickRepliesFromStepData($step)); } /** @@ -78,4 +88,4 @@ public static function createStopStep(array $step) { return new Stop($step['confidence']); } -} +} \ No newline at end of file From 89a1b63197f8b0e1f0c9e2c0499d497753c2e268 Mon Sep 17 00:00:00 2001 From: Matthew Large Date: Sat, 22 Apr 2017 17:23:37 +0100 Subject: [PATCH 2/2] Adding quick replies into Message Step --- src/Model/Step/AbstractStep.php | 2 +- src/Model/Step/Message.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Model/Step/AbstractStep.php b/src/Model/Step/AbstractStep.php index d62d3f5..69ddb95 100644 --- a/src/Model/Step/AbstractStep.php +++ b/src/Model/Step/AbstractStep.php @@ -61,4 +61,4 @@ public function getEntities() { return $this->entities; } -} \ No newline at end of file +} diff --git a/src/Model/Step/Message.php b/src/Model/Step/Message.php index c4e6d68..ad83a46 100644 --- a/src/Model/Step/Message.php +++ b/src/Model/Step/Message.php @@ -26,6 +26,7 @@ public function __construct($message, $confidence, array $entities = [], array $ { parent::__construct(Step::TYPE_MESSAGE, $confidence, $entities, $quickreplies); $this->message = $message; + $this->quickreplies = $quickreplies; } /**