/** * Creates a channel if it does not exist and returns it. * If channel exists it is just returned. * * @param string $channelName * * @return WiseChatChannel */ public function createAndGetChannel($channelName) { $channel = $this->channelsDAO->getByName($channelName); if ($channel === null) { $channel = new WiseChatChannel(); $channel->setName($channelName); $this->channelsDAO->save($channel); } return $channel; }
/** * Renders shortcode: [wise-chat-channel-stats] * * @param array $attributes * @return string */ public function getRenderedChannelStatsShortcode($attributes) { if (!is_array($attributes)) { $attributes = array(); } $attributes['channel'] = $this->service->getValidChatChannelName(array_key_exists('channel', $attributes) ? $attributes['channel'] : ''); $channel = $this->channelsDAO->getByName($attributes['channel']); if ($channel !== null) { $this->options->replaceOptions($attributes); $this->messagesService->startUpMaintenance($channel); return $this->renderer->getRenderedChannelStats($channel); } else { return 'ERROR: channel does not exist'; } }