private function initializeCache()
 {
     // We have to warm up the extend entities cache in separate process
     // to allow this process continue executing.
     // The problem is we need initialized DI contained for warming up this cache,
     // but in this moment we are exactly doing this for the current process.
     $pb = ProcessBuilder::create()->setTimeout(self::CACHE_GENERATION_TIMEOUT)->add(CommandExecutor::getPhpExecutable())->add($this->kernel->getRootDir() . '/console')->add('oro:entity-extend:cache:warmup')->add('--env')->add($this->kernel->getEnvironment())->add('--cache-dir')->add($this->cacheDir);
     $attempts = 0;
     do {
         if (!CommandExecutor::isCommandRunning('oro:entity-extend:cache:warmup')) {
             // if cache was generated there is no need to generate it again
             if ($attempts > 0) {
                 return;
             }
             $pb->getProcess()->run();
             return;
         } else {
             $attempts++;
             sleep(self::CACHE_CHECKOUT_INTERVAL);
         }
     } while ($attempts < self::CACHE_CHECKOUT_ATTEMPTS);
 }
 /**
  * Finds the PHP executable.
  *
  * @return string
  */
 private function getPhpExecutable()
 {
     if (null === $this->phpExecutable) {
         $this->phpExecutable = CommandExecutor::getPhpExecutable();
     }
     return $this->phpExecutable;
 }