コード例 #1
0
 /**
  * @param string     $id
  * @param Definition $definition
  * @param array      $definitionArray
  */
 private function tryHydrateDefinitionForRestoration($id, Definition $definition, array &$definitionArray)
 {
     if ($this->container->isLoaded($id) && $definition->hasTag('dumpable')) {
         $service = $this->container->get($id);
         if (!$service instanceof DumpableServiceInterface) {
             throw new ServiceNotDumpableException($id, get_class($service));
         }
         $classProxy = $service->getClassProxy() ?: get_class($service);
         if (!in_array(self::RESTORABLE_SERVICE_INTERFACE, class_implements($classProxy))) {
             throw new InvalidServiceProxyException($classProxy);
         }
         if (isset($definitionArray['class'])) {
             if ($classProxy !== $definitionArray['class']) {
                 unset($definitionArray['arguments']);
             }
             $definitionArray['class'] = $classProxy;
         }
         unset($definitionArray['configurator']);
         $definitionArray['calls'] = [];
         $definitionArray['calls'][] = ['restore', ['@service_container', $service->dump()]];
     }
 }