/** * @param Dialog $dialog * @return Dialog */ public function add(Dialog $dialog) { $dialog->setTelegram($this->telegram); // save new dialog $chatId = $dialog->getChat()->getId(); $this->setField($chatId, 'next', $dialog->getNext()); $this->setField($chatId, 'dialog', get_class($dialog)); // @todo It's not safe. Need to define Dialogs registry with check of bindings return $dialog; }