private function registerChannelRelationships()
    {
        if (!count($this->channelRelationships)) {
            return;
        }

        foreach($this->channelRelationships as $moduleEntity => $channelRelationships) {
            foreach ($channelRelationships as $bundleIdentifier => $modules) {
                $bundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
                    ->findOneByName($bundleIdentifier);

                foreach ($modules as $moduleIdentifier => $moduleChannels) {
                    $module = $this->em->getRepository('CampaignChainCoreBundle:'.$moduleEntity)
                        ->findOneBy(
                            [
                                'bundle' => $bundle,
                                'identifier' => $moduleIdentifier,
                            ]
                        );

                    foreach ($moduleChannels as $channelURI) {
                        $channelURISplit = explode('/', $channelURI);
                        $channelBundleIdentifier = $channelURISplit[0] . '/' . $channelURISplit[1];
                        $channelModuleIdentifier = $channelURISplit[2];
                        /** @var Bundle $channelBundle */
                        $channelBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
                            ->findOneByName($channelBundleIdentifier);
                        /** @var ChannelModule $channelModule */
                        $channelModule = $this->em->getRepository('CampaignChainCoreBundle:ChannelModule')
                            ->findOneBy(
                                [
                                    'bundle' => $channelBundle,
                                    'identifier' => $channelModuleIdentifier,
                                ]
                            );

                        if (!$channelModule) {
                            throw new \Exception(
                                'The channel URI "'.$channelURI.'" provided in campaignchain.yml of bundle "'.$bundle->getName()
                                .'" for its module "'.$moduleIdentifier.'" does not match an existing channel module.'
                            );
                        }

                        /*
                         * If an updated bundle, then do nothing for an existing
                         * Activity/Channel relationship.
                         *
                         * TODO: Check if existing relationship has been removed
                         * from campaignchain.yml and throw error.
                         */
                        if ($this->bundleConfigService->isRegisteredBundle($bundle) == self::STATUS_REGISTERED_OLDER) {
                            $method = 'findRegisteredModulesBy'.$moduleEntity;
                            $registeredModules = $this->em->getRepository('CampaignChainCoreBundle:ChannelModule')
                                ->$method($module);

                            if (count($registeredModules) && $registeredModules[0]->getIdentifier() == $channelModule->getIdentifier()
                            ) {
                                continue;
                            }
                        }

                        // Map activity and channel.
                        $module->addChannelModule($channelModule);
                        $this->em->persist($module);
                    }
                }
            }
        }

        $this->em->flush();
    }