Add a target to a site.
@param CNabuSiteTarget $nb_site_target Target to add to site.
@param bool $default If true sets the target as the default target for this site.
@return CNabuSiteTarget Returns the inserted target.
964562
public function addTarget(CNabuSiteTarget $nb_site_target, $default = false)
    {
        $nb_site_target->setSite($this);

        if ($default) {
            $this->setDefaultTarget($nb_site_target);
        }

        return $this->nb_site_target_list->addItem($nb_site_target);
    }
1134079
private function createHostedFile(CNabuSite $nb_site)
    {
        $file = new CApacheHostedFile($this, $this->nb_server, $nb_site);
        $file->create();
        $path = $this->nb_server->getVirtualHostsPath()
                  . DIRECTORY_SEPARATOR
                  . $nb_site->getBasePath()
                  . NABU_VHOST_CONFIG_FOLDER
                  . DIRECTORY_SEPARATOR
                  . $this->nb_server->getKey()
        ;
        if (!is_dir($path)) {
            mkdir($path, 0755, true);
        }
        if (!is_dir($path)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_FOLDER_NOT_FOUND, array($path));
        }
        $filename = $path . DIRECTORY_SEPARATOR . NABU_VHOST_CONFIG_FILENAME;
        $file->exportToFile($filename);
    }
1011260
public function getTarget($nb_site_target)
    {
        $nb_site_target_id = nb_getMixedValue($nb_site_target, 'nb_site_target_id');

        return (is_numeric($nb_site_target_id) || nb_isValidGUID($nb_site_target_id))
               ? $this->nb_site_target_list->getItem($nb_site_target_id)->setSite($this)
               : null
        ;
    }
894818
public function setCustomerId(int $nb_customer_id) : CNabuDataObject
    {
        if ($nb_customer_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_customer_id")
            );
        }
        $this->setValue('nb_customer_id', $nb_customer_id);
        
        return $this;
    }
365156
public function setCommerce(CNabuCommerce $nb_commerce)
    {
        $this->nb_commerce = $nb_commerce;
        $this->transferValue($nb_commerce, NABU_COMMERCE_FIELD_ID);

        return $this;
    }
779005
public function setServerHostId(int $nb_server_host_id) : CNabuDataObject
    {
        if ($nb_server_host_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_server_host_id")
            );
        }
        $this->setValue('nb_server_host_id', $nb_server_host_id);
        
        return $this;
    }
221449
public function setVisible(string $visible = "T") : CNabuDataObject
    {
        if ($visible === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$visible")
            );
        }
        $this->setValue('nb_site_map_visible', $visible);
        
        return $this;
    }
605726
public function setLoginTarget(CNabuDataObject $nb_site_target)
    {
        $this->setLoginTargetUseURI(CNabuSiteTargetLink::USE_URI_TRANSLATED);
        $this->transferValue($nb_site_target, 'nb_site_target_id', 'nb_site_login_target_id');

        return $this;
    }
951849
public function addTarget($targetName, $target)
    {
        if (isset($this->targets[$targetName])) {
            throw new BuildException("Duplicate target: $targetName");
        }
        $this->addOrReplaceTarget($targetName, $target);
    }
534339
public function setSiteTargetId(int $nb_site_target_id) : CNabuDataObject
    {
        if ($nb_site_target_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_target_id")
            );
        }
        $this->setValue('nb_site_target_id', $nb_site_target_id);
        
        return $this;
    }
388158
public function setUseFramework(string $use_framework = "F") : CNabuDataObject
    {
        if ($use_framework === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$use_framework")
            );
        }
        $this->setValue('nb_site_use_framework', $use_framework);
        
        return $this;
    }
944571
public static function navbarCollapseLink($target, $htmlOptions = array())
    {
        self::addCssClass('btn btn-navbar', $htmlOptions);
        $htmlOptions['type'] = 'button';
        $htmlOptions['data-toggle'] = 'collapse';
        $htmlOptions['data-target'] = $target;
        self::addCssClass('navbar-toggle', $htmlOptions);
        $content = self::tag('span', array('class' => 'sr-only'), 'Toggle navigation');
        $content .= '<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>';
        return self::tag('button', $htmlOptions, $content);
    }
621078
private function identifyRequest($target = false)
    {
        $retval = false;

        $this->locateURI();

        $nb_engine = CNabuEngine::getEngine();

        if ($target) {
            $temp_target = CNabuSiteTarget::findByURL($this->nb_site, $this->page_uri);
            if ($temp_target instanceof CNabuSiteTarget && $temp_target->isValueNumeric('nb_language_id')) {
                $nb_language = new CNabuLanguage($temp_target);
                if ($nb_language->isFetched()) {
                    $this->nb_language = $nb_language;
                } else {
                    $this->nb_language = $this->nb_site->getDefaultLanguage();
                }
            }

            if (!($target instanceof CNabuSiteTarget) &&
                is_numeric($nb_site_target_id = nb_getMixedValue($target, 'nb_site_target_id'))
            ) {
                $target = new CNabuSiteTarget($nb_site_target_id);
                if ($target->isFetched()) {
                    $this->nb_site_target = $target;
                }
            } else {
                $this->nb_site_target = $target;
            }
            if ($this->nb_site_target instanceof CNabuSiteTarget &&
                $this->nb_language === null && $this->nb_site_target->isValueNumeric('nb_language_id')) {
                $this->nb_language = new CNabuLanguage($this->nb_site_target->getValue('nb_language_id'));
                if ($this->nb_language->isNew()) {
                    $this->nb_language = null;
                }
            }
            if ($this->nb_language === null) {
                $this->nb_language = $this->nb_site->getDefaultLanguage();
            }
            if ($this->nb_site_target !== null &&
                $this->nb_language !== null &&
                $this->nb_site_target->hasTranslation($this->nb_language)
            ) {
                $this->nb_response->setHTTPResponseCode(200);
                $nb_engine->traceLog('Page Status', 'Found');

                $retval = true;
            }
        } elseif ($this->findTargetByURL($this->page_uri)) {
            $nb_engine->traceLog("Page ID", $this->nb_site_target->getId());

            if ($this->nb_language === null) {
                throw new ENabuCoreException(ENabuCoreException::ERROR_LANGUAGE_NOT_FOUND_FOR_PAGE_URI);
            }
            $nb_engine->traceLog("Page language", $this->nb_language->getISO6391());
            $nb_engine->traceLog('Page Status', 'Found');

            $retval = true;
        }

        if (!($this->nb_site_target instanceof CNabuSiteTarget) || !$retval) {
            $nb_engine->traceLog('Page Status', 'Not found');
            $link = $this->nb_site->getPageNotFoundTargetLink();
            if ($link->isLinkable()) {
                if ($link->isTranslatedTarget()) {
                    $this->nb_language = $this->nb_site->getDefaultLanguage();
                    if ($this->nb_language instanceof CNabuLanguage &&
                        ($nb_site_target = $link->getTranslatedObject()) instanceof CNabuSiteTarget &&
                        ($nb_site_target->getTranslation($this->nb_language) instanceof CNabuSiteTargetLanguage)
                    ) {
                        $this->nb_site_target = $nb_site_target;
                        $retval = true;
                    }
                }
            }

            if ($this->nb_response->getHTTPResponseCode() === 0) {
                $this->nb_response->setHTTPResponseCode(404);
            }
        }

        return $retval;
    }
861928
@Override
    public T addAsWebResource(Asset resource, String target) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource should be specified");
        Validate.notNull(target, "Target should be specified");

        return addAsWebResource(resource, new BasicPath(target));
    }
647064
public function setDefaultErrorCode(int $default_error_code = 301) : CNabuDataObject
    {
        if ($default_error_code === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$default_error_code")
            );
        }
        $this->setValue('nb_site_default_error_code', $default_error_code);
        
        return $this;
    }
1366416
public function setPublicBasePathEnabled(string $public_base_path_enabled = "F") : CNabuDataObject
    {
        if ($public_base_path_enabled === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$public_base_path_enabled")
            );
        }
        $this->setValue('nb_site_public_base_path_enabled', $public_base_path_enabled);
        
        return $this;
    }
892826
protected function createNewSiteDir($default_site_dir, $new_site_dir) {
    $result = $this->taskCopyDir([
      $default_site_dir => $new_site_dir,
    ])
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();
    if (!$result->wasSuccessful()) {
      throw new BltException("Unable to create $new_site_dir.");
    }
  }