Creates the bundle cache warmer definition.

@param   string  $warmerName
@return  Definition
430473
private function createBundleCacheWarmer($warmerName)
    {
        $definition = new Definition(
            Utility::getBundleClass('CacheWarmer\MetadataWarmer'),
            [new Reference($warmerName)]
        );
        $definition->setPublic(false);
        $definition->addTag('kernel.cache_warmer');
        return $definition;
    }
1040423
private function warmUpCacheFromFile($filename)
    {
        if (preg_match('#\.php$#', $filename) == false) {
            throw new \InvalidArgumentException('The cache filename must ends with the extension ".php".');
        }

        if (file_exists($filename) == false) {
            $this->hasPendingChasges = true;

            return;
        }

        $fileContent = include_once($filename);

        if (is_array($fileContent) == false) {
            throw new \InvalidArgumentException('Cache file invalid format.');
        }

        foreach ($fileContent as $filename => $hash) {
            $this->write($filename, $hash);
        }

        $this->isInitialized = true;
    }
53638
public function wrapWith($wrapperName, $driveStyle = NULL) {
    $this->wrapper = $wrapperName;

    $this->prefix = $this->wrapper.'://'.$this->getOSPrefix(self::UNIX, $driveStyle ?: self::WINDOWS_DRIVE_WINDOWS_STYLE);

    return $this;
  }
90602
protected function createCacheItem(/*# string */ $key)/*# : CacheItemExtendedInterface */
    {
        if (is_callable($this->item_factory)) {
            $func = $this->item_factory;
            $item = $func($key, $this);
        } else {
            $item = new CacheItem($key, $this);
        }

        return $item;
    }
605837
public function open($filename)
    {
        $this->filename = $filename;
        return $this->zipArchive->open($filename, ZIPARCHIVE::CREATE);
    }
375043
public function createPackageName($projectName)
    {
        if (!empty($_SERVER['USERNAME'])) {
            $packageName = $_SERVER['USERNAME'].'/'.$projectName;
        } elseif (true === extension_loaded('posix') && $user = posix_getpwuid(posix_getuid())) {
            $packageName = $user['name'].'/'.$projectName;
        } elseif (get_current_user()) {
            $packageName = get_current_user().'/'.$projectName;
        } else {
            // package names must be in the format foo/bar
            $packageName = $projectName.'/'.$projectName;
        }

        return $this->fixPackageName($packageName);
    }
1082410
protected function getBundleByName($bundleName)
    {
        /** @var Kernel $kernel */
        $kernel = $this->getApplication()->getKernel();

        $bundles = $kernel->getBundle($bundleName, false);

        return $bundles[count($bundles) - 1];
    }
81566
public function create(string $className)
    {
        if (array_key_exists($className, $this->cache)) {
            return $this->cache[$className];
        }

        if (!class_exists($className)) {
            throw new RuntimeException("Mapper not found. Attempted to load '{$className}'.");
        }

        $instance = new $className($this->connection, $this->table);
        $this->cache[$className] = $instance;

        return $instance;
    }
775669
private function createLibmemcachedCache():Libmemcached
    {
        /** @var IConfig $config */
        $config = $this->di->getShared('config');
        /** @var IApp $app */
        $app = $this->di->getShared('app');
        $lifetime = (int)$config->get($this->getName() . '.lifetime', 3600);
        $servers = $config->get($this->getName() . '.servers');
        $frontCache = new FrontData([
            "lifetime" => $lifetime
        ]);
        return $cache = new Libmemcached(
            $frontCache,
            [
                "servers" => $servers,
                "client" => [
                    \Memcached::OPT_HASH => \Memcached::HASH_MD5,
                    \Memcached::OPT_PREFIX_KEY => $app->getAppId()
                ]
            ]
        );
    }
1250638
public function createCacheBustedUrl(string $fileName, string $content): string
    {
        // For url we need to cache it
        $cacheFile = $this->createPublicCacheFile($fileName, $content);
        $name = pathinfo($cacheFile, PATHINFO_BASENAME);
        $dir = pathinfo($cacheFile, PATHINFO_DIRNAME);
        $dirs = explode('/', $dir);

        // Folder: cache/ab
        $cacheDirs = array_slice($dirs, count($dirs) - 2);

        // Folder: cache/ab/filename.ext
        return implode('/', $cacheDirs) . '/' . $name;
    }
962788
public function setHostname(string $hostname)
    {
        $this->hostname = $hostname;

        $this->raw = array_merge($this->raw, ['Hostname' => $hostname]);

        return $this;
    }
176989
private function createRegionCache($name)
    {
        $cacheAdapter = clone $this->cache;

        if (! $cacheAdapter instanceof CacheProvider) {
            return $cacheAdapter;
        }

        $namespace = $cacheAdapter->getNamespace();

        if ($namespace !== '') {
            $namespace .= ':';
        }

        $cacheAdapter->setNamespace($namespace . $name);

        return $cacheAdapter;
    }
657596
public function setSiteName($siteName)
    {
        $this->meta()->setSiteName($siteName);
        $this->openGraph()->setSiteName($siteName);

        return $this;
    }
1305049
protected function createSwooleServer(string $protocolName, array $config = []): self
    {
        switch ($protocolName) {
            // HTTP Server
            case Protocol::HTTP:
                $server = SwHttpServer::class;
                break;

            // WebSocket Server
            case Protocol::WEBSOCKET:
                $server = SwWebSocketServer::class;
                break;

            // TCP/UDP Server
            default:
                $server = SwServer::class;
                break;
        }

        // {{ 创建 Server
        $swoole = new $server(
            $config['host'],
            $config['port'],
            SWOOLE_PROCESS,
            SWOOLE_SOCK_TCP
        );

        $swoole->set($config['swoole']);
        unset($server);

        $this->swoole = $this->bindSwooleEvents($swoole, $protocolName);
        unset($swoole);
        // }}

        return $this;
    }
806691
private function createTplId($tplname)
    {
        list($name, $type) = Utils::parseResourceName($tplname);
        if ($type !== 'file') {
            $name = md5($name);
        }
        $temp = $this->sdopx->getTemplateJoined() . '_' . $name;
        $temp = strtolower(str_replace(['.', ':', ';', '|', '/', ' ', '\\'], '_', $temp));
        if (isset($temp[32])) {
            $temp = md5($temp) . strtolower(str_replace(['.', ':', ';', '|', '/', ' ', '\\'], '_', $name));
        }
        return $type . '_' . trim($temp, '_');
    }
842391
public static function get(CacheItemPoolInterface $pool, array $config)
    {
        if ($config['use_tagging']) {
            $pool = new FixedTaggingCachePool(TaggablePSR6PoolAdapter::makeTaggable($pool), ['validation']);
        }

        if (!empty($config['prefix'])) {
            $pool = new PrefixedCachePool($pool, $config['prefix']);
        }

        return new SymfonyValidatorBridge($pool);
    }
605278
protected function isBundleAvailable($bundleName)
    {
        $allBundles = array_keys($this->assistant->getKernel()->getBundles());

        return in_array($bundleName, $allBundles);
    }