Is a theme already registered?

@param $themeId

@return bool
498733
public function themeExists($themeId) {
        // while this seem to be obsolete in most cases
        // it can be useful when the function is called from the outside
        $prefixedId = $this->getPrefixedThemeId($themeId);
        $map = $this->registry->getMap();
        if(empty($map['items']['available'])) {
            return false;
        }
        foreach($map['items']['available'] as $theme) {
            if($theme['id'] === $prefixedId) {
                return true;
            }
        }
        return false;
    }
261832
public function registerTheme(array $themeData)
    {
        $theme = $this->normalizer->denormalize(
            array(
                'id' => $themeData['id'],
                'name' => $themeData['id'],
            ),
            $this->entityCollection->getEntityClass()
        );
        foreach ($themeData['templates'] as $templateTypeId) {
            $theme->getTemplateTypes()->set(
                $templateTypeId,
                $this->templateTypeLoader->retrieve($templateTypeId)
            );
        }
        foreach ($themeData['image_formats'] as $imageFormatId) {
            $theme->getImageFormats()->set(
                $imageFormatId,
                $this->imageFormatLoader->retrieve($imageFormatId)
            );
        }

        $this->entityCollection->set($theme->getId(), $theme);
    }
635369
protected function isCachedById(int $id, int $siteId = null)
    {
        // Resolve siteId
        $siteId = SiteHelper::resolveSiteId($siteId);

        if (!isset($this->cacheById[$siteId])) {
            $this->cacheById[$siteId] = [];
        }

        return array_key_exists($id, $this->cacheById[$siteId]);
    }
616222
protected static function _initializeTheme($registeredTheme)
    {
        list($theme, $themeName) = pluginSplit($registeredTheme);
        $themeNamespace = preg_replace('/\\//', '\\', $theme);
        $themeClass = $themeNamespace . '\\' . $themeName;
        
        try {
            $theme = new $themeClass();
        } catch (Exception $e) {
            throw new Exception(__d('wasabi_core', 'The theme "{0}" could not be instatiated. Check the namespace and file location.', $themeClass));
        }

        return $theme;
    }
280607
protected function getThemeIdFromThemeDetailsProviders()
    {
        $providers = $this->getThemeDetailsProviders();
        foreach ($providers as $provider) {
            if ($provider instanceof ThemeDetailsProviderInterface) {
                $themeId = $provider->getThemeId();
                if (!empty($themeId) && $themeId !== ' ') {
                    if ($this->hasTheme($themeId)) {
                        return $themeId;
                    }

                    \common_Logger::i(
                        'The requested theme ' . $themeId .
                        ' requested by the ' . get_class($provider) . ' provider does not exist!'
                    );
                }
            }
        }

        return '';
    }
1200788
public function add(array $themes) {

        foreach($themes as $themeId => $label) {
            $prefixedId =  $this->getPrefixedThemeId($themeId);
            if($this->themeExists($prefixedId)) {
                continue;
            }
            $this->register($themeId, $label);
        }

        $this->logInfo('Item themes registered: ' . implode(',', array_keys($themes)));
        return true;
    }
478914
protected static function isWordPressThemeDirectory( $directory ) {
		$composer = Composer::getComposerJson( $directory );

		if ( ! $composer ) {
			return false;
		}

		if ( $composer['type'] !== 'wordpress-theme' ) {
			return false;
		}

		return true;
	}
1093997
function registerThemeDirectories() {

		/**
		 * Register additional theme directories.
		 *
		 * Additional theme directories (e.g. those within another plugin, or custom
		 * subdirectories of wp-content) may be registered via this action hook.
		 *
		 * @since 3.8.0
		 */
		do_action( 'pressbooks_register_theme_directory' );

		if ( is_admin() ) {
			if ( Book::isBook() ) {
				add_filter( 'allowed_themes', [ $this, 'allowedBookThemes' ] );
			} elseif ( ! is_network_admin() ) {
				add_filter( 'allowed_themes', [ $this, 'allowedRootThemes' ] );
			}
		}
	}
332473
public function register_path( $dir = null, $persistent = true ) {
		$result = false;

		// Cast parameters to known values.
		$dir = (string) $dir;
		$persistent = (bool) $persistent;

		if ( empty( $dir ) ) {
			$dir = $this->get_default_path();
		}

		$path_fail_reason = $this->validate_path( $dir );
		if ( $path_fail_reason ) {
			return new WP_Error( 'custom_theme_path_invalid', "Custom themes directory is invalid: $path_fail_reason", $dir );
		}

		// Register custom-theme path for "on the fly".
		$result = register_theme_directory( $dir );

		if ( ! $persistent ) {
			return $result;
		}

		// WordPress option is already set.
		if ( get_option( 'stylesheet_root' ) === $dir ) {
			return $result;
		}

		// Update WordPress option if persistence is required.
		//
		// Not returning the result of this operation as it can
		// be confusing - false is returned either on failure or
		// when the option value was the same and wasn't updated.
		update_option( 'stylesheet_root', $dir );
	}
653478
private function isValidWebsiteId($websiteId)
    {
        $websites = $this->storeManager->getWebsites();
        if (array_key_exists($websiteId, $websites)) {
            return true;
        }

        if (is_numeric($websiteId)) {
            // Dont bother checking website codes on numeric input
            return false;
        }
        // @todo hs: build up array of websiteCodes, to prevent wasting time looping
        /** @var Website $website */
        foreach ($websites as $website) {
            if ($website->getCode() == $websiteId) {
                return true;
            }
        }

        return false;
    }
831002
public function load($sOXID)
    {
        $sFilePath = \OxidEsales\Eshop\Core\Registry::getConfig()->getViewsDir() . $sOXID . "/theme.php";
        if (file_exists($sFilePath) && is_readable($sFilePath)) {
            $aTheme = [];
            include $sFilePath;
            $this->_aTheme = $aTheme;
            $this->_aTheme['id'] = $sOXID;
            $this->_aTheme['active'] = ($this->getActiveThemeId() == $sOXID);

            return true;
        }

        return false;
    }
113071
public function update(array $themes) {
        foreach($themes as $themeId => $label) {
            $this->remove($themeId);
            $this->register($themeId, $label);
        }
        $this->logInfo('Item themes updated: ' . implode(',', array_keys($themes)));
        return true;
    }
1084247
public function remove($themeIds) {
        $themeIds = (array)$themeIds;
        foreach($themeIds as $themeId) {
            $prefixedId = $this->getPrefixedThemeId($themeId);
            if(!$this->themeExists($prefixedId)) {
                continue;
            }
            $this->registry->unregisterTheme($prefixedId);
        }
        $this->logInfo('Item themes removed: ' . implode(',', $themeIds));
        return true;
    }
494209
public function isLayoutValid(Site $site, $layoutKey)
    {
        $themesConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());

        if (!empty($themesConfig[$layoutKey])) {
            return true;
        }

        return false;
    }
235588
public function register()
    {
        if (! function_exists('add_theme_support') || empty($this->features)) {
            return;
        }

        foreach ($this->features as $feature => $value) {
            add_theme_support($feature, $value);
        }
    }
975585
protected function registerTheme()
    {
        $this->app->singleton('antares.theme', function ($app) {
            return new ThemeManager($app);
        });

        $this->app->singleton('antares.theme.finder', function ($app) {
            return new Finder($app);
        });
    }
85584
public function getTemplate($target, $themeId, $templateId){
        $theme = $this->getTheme($target, $themeId);
        if(isset($theme['templates']) && isset($theme['templates'][$templateId])){
            return $this->resolveTemplatePath($theme['templates'][$templateId]);
        }
        return null;
    }