/** * Check channel, add if valid name and not exist * * @param string $chanName * @param \Magento\Framework\Connect\Config $config * @param \Magento\Framework\Connect\Rest $rest * @return bool * @throws \Exception */ public function checkChannel($chanName, $config, $rest = null) { if ($this->isChannel($chanName)) { return true; } $_validator = new \Magento\Framework\Connect\Validator(); if ($this->isChannelName($chanName)) { $uri = $this->chanUrl($chanName); } elseif ($_validator->validateUrl($chanName)) { $uri = $chanName; } elseif ($chanName) { $uri = $config->protocol . '://' . $chanName; } else { throw new \Exception("'{$chanName}' is not existant channel name / valid uri"); } if ($uri && !$this->isChannel($uri)) { if (!isset($rest)) { $rest = new \Magento\Framework\Connect\Rest($config->protocol); } $rest->setChannel($uri); $data = $rest->getChannelInfo(); $data->uri = $uri; $this->addChannel($data->name, $uri); } return $this->isChannel($uri); }