Add the parent domain to the sub-domain if the sub-domain if it is not fully qualified.

@param string $subdomain
@param string $parent

@return string
344191
private static function fullyQualify(string $subdomain, string $parent): string
    {
        if ('@' === $subdomain) {
            return $parent;
        }

        if ('.' !== substr($subdomain, -1, 1)) {
            return $subdomain.'.'.$parent;
        }

        return $subdomain;
    }
133546
public function addDomain($data)
    {
        if ($data instanceof Domain) {
            $domain = $data; // alias
            $domain->setDatabase($this);
            $this->domainMap[$domain->getName()] = $domain;

            return $domain;
        } else {
            $domain = new Domain();
            $domain->setDatabase($this);
            $domain->loadFromXML($data);

            return $this->addDomain($domain); // call self w/ different param
        }
    }
87806
public static function create(Domain $domain, $prefix)
    {
        $domain->invokePost('SUBDOMAIN', 'create', ['subdomain' => $prefix]);
        return new self($prefix, $domain);
    }
1248495
public function domain($domain = null)
    {
        if (is_null($domain)) {
            return $this->getDomain();
        }

        $this->action['domain'] = $domain;

        return $this;
    }
527383
public function withSubDomains(array $subDomains)
    {
        $uri = clone $this;
        $uri->subDomain = reset($subDomains);
        $uri->subDomains = $subDomains;

        return $uri;
    }
88005
private function getRootDomain($domain)
    {
        $domainParts = explode('.', $domain);
        $count       = count($domainParts);

        return $count > 1
            ? $domainParts[$count - 2].'.'.$domainParts[$count - 1]
            : $domainParts[0];
    }
958363
def subdomain?(*jids)
      !jids.flatten.index do |jid|
        !component?(jid) && !pubsub?(jid)
      end
    end
712278
function(start) {
		"use strict";

		var parent = this;
		return this.triggerEvent("afterLoadPreviousDomain", function() {
			var subDomain = parent.getSubDomain(start);
			return [subDomain.shift(), subDomain.pop()];
		});
	}
1252124
public function addDomain(Domain $domain)
    {
        if ($this->domains->contains($domain)) {
            return $this;
        }

        $this->domains[] = $domain;

        return $this;
    }
1068454
public function setChildOf(Tree $parent)
    {
        if ($parent->type->name !== 'category') {
            throw new DomainException("Content can be assigned only to category parent");
        }
        return parent::setChildOf($parent);
    }
775895
public function setDomain(?string $domain) : void
    {
        $this->domain = (($domain === null) ? null : strtolower($domain));
    }
145594
private function setParent(&$parent)
    {
        if (! is_null($parent)) {
            $this->parent = $parent;

            $this->parent->elements->add($this);
        }

        return $this;
    }
12224
protected function isFromDomain($url, $domain)
    {
        if (!$domain) {
            return true;
        }

        $parsedUrl = parse_url($url);
        // if domain or subdomain
        if (
            isset($parsedUrl['host'])
            && (
                $parsedUrl['host'] == $domain
                || fnmatch('*.' . $domain, $parsedUrl['host'])
            )
        ) {
            return true;
        }

        return false;
    }
1137162
public function addParent(NodeInterface $parent, bool $setParentsChild = true): NodeInterface
    {
        if (!$this->supportsParent($parent)) {
            throw ParentTypeNotSupportedException::create($this, $parent);
        }

        $this->_parents[$parent->getId()] = $parent;

        if ($setParentsChild) {
            $parent->addChild($this, false);
        }

        $this->notifySubscribers(
            self::EVENT_ADD_PARENT,
            ['oldParents' => $this->_parents, 'newParent' => $parent, 'child' => $this]
        );

        return $this;
    }
52289
protected function getSubdomain( $subdomainId = null )
    {
        static $subdomains = array();
        $siteInfo = $this->getSiteInfo();

        if ( empty( $subdomainId ) || $siteInfo->getSubdomainId() == $subdomainId )
        {
            return $siteInfo->getSubdomain();
        }

        if ( ! isset( $subdomains[$subdomainId] ) )
        {
            /* @var $model \Grid\Core\Model\Uri\Model */
            $service    = $this->getServiceLocator();
            $model      = $service->get( 'Grid\Core\Model\SubDomain\Model' );
            $subdomain  = $model->find( $subdomainId );

            if ( empty( $subdomain ) )
            {
                $subdomains[$subdomainId] = '';
            }
            else
            {
                $subdomains[$subdomainId] = $subdomain->subdomain;
            }
        }

        return $subdomains[$subdomainId];
    }
1133704
public function add($parentId = null)
    {
        /** @var Page $page */
        $page = $this->Pages->newEntity();

        ThemeManager::theme(Wasabi::setting('Cms.Theme.id'));

        if ($this->request->is('post') && !empty($this->request->data)) {
            $this->request->data['parent_id'] = $parentId;

            /** @var Connection $conn */
            $conn = $this->Pages->connection();
            $conn->begin();
            $this->Pages->behaviors()->unload('Translate');
            $page = $this->Pages->newEntity([
                'name' => $this->request->data('name'),
                'parent_id' => $this->request->data('parent_id'),
                'layout' => $this->request->data('layout')
            ]);

            if ($this->Pages->save($page, ['associated' => false])) {
                $this->Pages->behaviors()->load('Translate', PagesTable::$translateOptions);

                $page = $this->Pages->patchEntity($page, $this->request->data);
                if ($this->Pages->save($page)) {
                    $conn->commit();
                    $this->Flash->success(__d('wasabi_cms', 'The page <strong>{0}</strong> has been created.', $page->name));
                    $this->redirect(['action' => 'index']);
                    return;
                } else {
                    $conn->rollback();
                    $this->Flash->error($this->formErrorMessage);
                }
            } else {
                $conn->rollback();
                $this->Flash->error($this->formErrorMessage);
            }
        } else {
            $page->layout = 'Default';
            $page->current = [
                (new Content())->set('content', json_encode($page->getLayout()->content()))
            ];
            $page->display_page_title_suffix = true;
        }

        if ($page->meta_robots_index === null) {
            $page->meta_robots_index = (bool)Configure::read('Settings.Cms.SEO.meta-robots-index');
        }

        if ($page->meta_robots_follow === null) {
            $page->meta_robots_follow = (bool)Configure::read('Settings.Cms.SEO.meta-robots-follow');
        }

        $this->set([
            'page' => $page,
            'layouts' => ThemeManager::theme()->getLayoutsForSelect(),
            'availableModules' => ModuleManager::getAvailableModules(),
            'attributes' => $page->getLayout()->attributes(),
            'changeAttributesUrl' => Router::url([
                'plugin' => 'Wasabi/Cms',
                'controller' => 'Pages',
                'action' => 'attributes'
            ])
        ]);
    }
494357
public function domain($domain, $protocol = null) {

		if(false === is_string($domain)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($domain)), E_USER_ERROR);
		}

		//Check if identifier exists
		if(false === Router :: routeExists($this -> identifier, $domain)) {
			return trigger_error(sprintf('Identifier "%s" with domain "%s" does not exists', $this -> identifier, $domain), E_USER_ERROR);	
		}

		if(null !== $protocol && false === is_string($protocol)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($protocol)), E_USER_ERROR);
		}

		if(null === $protocol) {
			$protocol = Request :: getScheme();
		}

		$this -> domain = sprintf('%s://%s', $protocol, $domain);

		return $this;
	}