protected function autoConnectToAvailableCacheSystem(
        CacheAdapterAutoManager $cacheAdapterManagerForAutoConnect = null,
        bool $cacheAdapterManagerForAutoConnectOverwrite = false
    ): iAdapter {
        static $AUTO_ADAPTER_STATIC_CACHE = null;

        if (
            \is_object($AUTO_ADAPTER_STATIC_CACHE)
            &&
            $AUTO_ADAPTER_STATIC_CACHE instanceof iAdapter
        ) {
            return $AUTO_ADAPTER_STATIC_CACHE;
        }

        // init
        $adapter = null;

        $cacheAdapterManagerDefault = CacheAdapterAutoManager::getDefaultsForAutoInit();

        if ($cacheAdapterManagerForAutoConnect !== null) {
            if ($cacheAdapterManagerForAutoConnectOverwrite) {
                $cacheAdapterManagerDefault = $cacheAdapterManagerForAutoConnect;
            } else {
                /** @noinspection PhpUnhandledExceptionInspection */
                $cacheAdapterManagerDefault->merge($cacheAdapterManagerForAutoConnect);
            }
        }

        foreach ($cacheAdapterManagerDefault->getAdapters() as $adapterTmp => $callableFunctionTmp) {

            /** @var iAdapter $adapterTest */
            if ($callableFunctionTmp !== null) {
                $adapterTest = new $adapterTmp($callableFunctionTmp);
            } else {
                $adapterTest = new $adapterTmp();
            }

            if ($adapterTest->installed()) {
                $adapter = $adapterTest;

                break;
            }
        }

        // save to static cache
        $AUTO_ADAPTER_STATIC_CACHE = $adapter;

        return $adapter;
    }
protected function autoConnectToAvailableCacheSystem(
        CacheAdapterAutoManager $cacheAdapterManagerForAutoConnect = null,
        bool $cacheAdapterManagerForAutoConnectOverwrite = false
    ): iAdapter {
        static $AUTO_ADAPTER_STATIC_CACHE = null;

        if (
            \is_object($AUTO_ADAPTER_STATIC_CACHE)
            &&
            $AUTO_ADAPTER_STATIC_CACHE instanceof iAdapter
        ) {
            return $AUTO_ADAPTER_STATIC_CACHE;
        }

        // init
        $adapter = null;

        $cacheAdapterManagerDefault = CacheAdapterAutoManager::getDefaultsForAutoInit();

        if ($cacheAdapterManagerForAutoConnect !== null) {
            if ($cacheAdapterManagerForAutoConnectOverwrite) {
                $cacheAdapterManagerDefault = $cacheAdapterManagerForAutoConnect;
            } else {
                /** @noinspection PhpUnhandledExceptionInspection */
                $cacheAdapterManagerDefault->merge($cacheAdapterManagerForAutoConnect);
            }
        }

        foreach ($cacheAdapterManagerDefault->getAdapters() as $adapterTmp => $callableFunctionTmp) {

            /** @var iAdapter $adapterTest */
            if ($callableFunctionTmp !== null) {
                $adapterTest = new $adapterTmp($callableFunctionTmp);
            } else {
                $adapterTest = new $adapterTmp();
            }

            if ($adapterTest->installed()) {
                $adapter = $adapterTest;

                break;
            }
        }

        // save to static cache
        $AUTO_ADAPTER_STATIC_CACHE = $adapter;

        return $adapter;
    }
protected function autoConnectToAvailableCacheSystem ( CacheAdapterAutoManager $ cacheAdapterManagerForAutoConnect = null , bool $ cacheAdapterManagerForAutoConnectOverwrite = false ) : iAdapter { static $ AUTO_ADAPTER_STATIC_CACHE = null ; if ( \ is_object ( $ AUTO_ADAPTER_STATIC_CACHE ) && $ AUTO_ADAPTER_STATIC_CACHE instanceof iAdapter ) { return $ AUTO_ADAPTER_STATIC_CACHE ; } // init $ adapter = null ; $ cacheAdapterManagerDefault = CacheAdapterAutoManager :: getDefaultsForAutoInit ( ) ; if ( $ cacheAdapterManagerForAutoConnect !== null ) { if ( $ cacheAdapterManagerForAutoConnectOverwrite ) { $ cacheAdapterManagerDefault = $ cacheAdapterManagerForAutoConnect ; } else { /** @noinspection PhpUnhandledExceptionInspection */ $ cacheAdapterManagerDefault -> merge ( $ cacheAdapterManagerForAutoConnect ) ; } } foreach ( $ cacheAdapterManagerDefault -> getAdapters ( ) as $ adapterTmp => $ callableFunctionTmp ) { /** @var iAdapter $adapterTest */ if ( $ callableFunctionTmp !== null ) { $ adapterTest = new $ adapterTmp ( $ callableFunctionTmp ) ; } else { $ adapterTest = new $ adapterTmp ( ) ; } if ( $ adapterTest -> installed ( ) ) { $ adapter = $ adapterTest ; break ; } } // save to static cache $ AUTO_ADAPTER_STATIC_CACHE = $ adapter ; return $ adapter ; }
Auto-connect to the available cache-system on the server.

@param CacheAdapterAutoManager $cacheAdapterManagerForAutoConnect          <p>Overwrite some Adapters for the
auto-connect-function.</p>
@param bool                    $cacheAdapterManagerForAutoConnectOverwrite <p>true === Use only Adapters from
your
"CacheAdapterManager".</p>

@return iAdapter
Auto - connect to the available cache - system on the server .