Inject the container if it uses the ManageContainerTrait

@param ContainerInterface $container
@param $entry
@return mixed
331080
public static function inject(ContainerInterface $container, $entry)
    {
        if (! is_object($entry)) {
            return $entry;
        }

        if (! static::classUses($entry, ManageContainerTrait::class)
            && ! $entry instanceof ManageContainerInterface) {
            return $entry;
        }

        // set the container
        return $entry->setAppContainer($container);
    }
819383
public function install(ContainerInterface $container)
    {
        // david factory
        $container['david'] = function(){
            $component = new Person('David Smith',24,179.2,function($target){ return 'throws '.$target.'.'; });
            $component->smile();
            return $component;
        };
        $container->slot('david')->lock()->mustBeTypeOf('object')->mustBeInstanceOf('\Sample\PersonInterface');
        // david's car factory
        $container['david\'s car'] = function(ContainerInterface $c){
            $component = new Car($c['string.my_model_name'],$c['integer.car_seats_sedan'],true,$c['david'],$c['toyota']);
            $component->moveTo($c['tokyo'],true);
            $component->serial_number = 123456;
            return $component;
        };
        $container->slot('david\'s car')->mustBeTypeOf('object');
    }
1066607
public function register(Container $container)
    {
        /**
         * @param  Container $container A container instance.
         * @return LoggerConfig
         */
        $container['logger/config'] = function (Container $container) {
            $appConfig    = isset($container['config']) ? $container['config'] : [];
            $loggerConfig = isset($appConfig['logger']) ? $appConfig['logger'] : null;
            return new LoggerConfig($loggerConfig);
        };

        /**
         * @return FactoryInterface
         */
        $container['logger/processor/factory'] = function () {
            return new Factory([
                'map' => [
                    'memory-usage' => MemoryUsageProcessor::class,
                    'uid'          => UidProcessor::class
                ]
            ]);
        };

        /**
         * @param  Container $container A container instance.
         * @return StreamHandler|null
         */
        $container['logger/handler/stream'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.stream'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new StreamHandler($handlerConfig['stream'], $level);
        };

        /**
         * @param  Container $container A container instance.
         * @return BrowserConsoleHandler|null
         */
        $container['logger/handler/browser-console'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.console'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new BrowserConsoleHandler($level);
        };

        /**
         * @param  Container $container A container instance.
         * @return Container Collection of defined record handlers, in a service container.
         */
        $container['logger/handlers'] = function (Container $container) {
            $loggerConfig   = $container['logger/config'];
            $handlersConfig = $loggerConfig['handlers'];
            $handlerFactory = $container['logger/handler/factory'];

            $handlers = new Container();
            foreach ($handlersConfig as $handler) {
                $handlers[$handler['type']] = function () use ($handler, $handlerFactory) {
                    $type    = $handler['type'];
                    $handler = $handlerFactory->create($type);
                    return $handler;
                };
            }

            return $handlers;
        };

        /**
         * Fulfills the PSR-3 dependency with a Monolog logger.
         *
         * @param  Container $container A container instance.
         * @return LoggerInterface
         */
        $container['logger'] = function (Container $container) {
            $loggerConfig = $container['logger/config'];

            if ($loggerConfig['active'] !== true) {
                return new NullLogger();
            }

            $logger = new Logger($loggerConfig['channel']);

            $memProcessor = new MemoryUsageProcessor();
            $logger->pushProcessor($memProcessor);

            $uidProcessor = new UidProcessor();
            $logger->pushProcessor($uidProcessor);

            $consoleHandler = $container['logger/handler/browser-console'];
            if ($consoleHandler) {
                $logger->pushHandler($consoleHandler);
            }

            $streamHandler = $container['logger/handler/stream'];
            if ($streamHandler) {
                $logger->pushHandler($streamHandler);
            }

            return $logger;
        };
    }
1301942
public function add($id, $entry, array $args = [])
    {
        $this->container[$id] = new Service($entry, $args);

        return $this;
    }
1056027
public static function get(ContainerInterface $container) {
    $storage_type = $container
      ->get('config.factory')
      ->get('acm.commerce_users')
      ->get('storage_type');

    switch ($storage_type) {
      case 'database_store':
        $storage = $container
          ->get('acm.database_session_store')
          ->get('acm');
        break;

      default:
        $storage = $container
          ->get('acm.php_session_store');
        break;
    }

    return $storage;
  }
643925
public function create($id, ContainerInterface $container)
    {
        if (isset($this->registeredList['services'][$id])) {
            $data = $this->createService($id, $container);
        } elseif (isset($this->registeredList['params'][$id])) {
            $data = $this->registeredList['params'][$id];
        } else {
            $data = null;
        }

        return $data;
    }
574351
private static function errorHandler(ContainerInterface $container): ErrorHandlerInterface
    {
        if (!$container->has(ErrorHandlerInterface::class)) {
            return new ErrorHandler();
        }

        return $container->get(ErrorHandlerInterface::class);
    }
297236
public function createRepositoryFactory(ContainerInterface $container)
    {
        if (empty($this->configFile)) {
            $this->configFile = $container->get('ConfigDirectory') . '/config/database.ini';
        }

        $config = parse_ini_file($this->configFile, true);

        $configuration = new Configuration;

        // Add logger
        $logger = new DebugStack;
        $configuration->setSQLLogger($logger);

        $connection = DriverManager::getConnection(
            [
                'url'     => $config['databaseUrl'],
                'charset' => 'utf8',
            ],
            $configuration
        );
        $transactor = new DoctrineTransactor($connection);

        $repositoryFactory = new RepositoryFactory($config, $connection, $transactor);

        if ($container->has('dispatcher')) {
            $repositoryFactory->setDispatcher($container->get('dispatcher'));
        }

        return $repositoryFactory;
    }
581692
protected function getContainer(ServiceLocatorInterface $serviceLocator)
    {
        if ($this->container !== null) {
            return $this->container;
        }

        $this->container = $serviceLocator->get(static::CONTAINER_NAME);

        if ($this->container instanceof ContainerInterface) {
            return $this->container;
        }

        throw new RuntimeException(sprintf(
            'Container "%s" is not a valid DI\\ContainerInterface, "%s" found',
            'DI\\Container',
            is_object($this->container) ? get_class($this->container) : gettype($this->container)
        ));
    }
658205
public function setAsChildContainerOf(DelegateInterface $parentContainer) : DelegateInterface
    {
        $this->setParentContainer($parentContainer);
        $parentContainer->addChildContainer($this);
        return $this;
    }
1140559
public function provideServiceLayerDependencies(Container $container)
    {
        $container = parent::provideServiceLayerDependencies($container);

        $container = $this->addStoreClient($container);

        return $container;
    }
929852
public final function register(CacheInterface $container): ServiceInterface
   {
       foreach ($this->service as $key => &$value) {
           $container->set($key, $value);
       }
       return $this;
   }
149778
protected function registerAssetsManager(Container $container)
    {
        $container['assets/config'] = function (Container $container) {
            $config = $container['view/config']->get('assets');

            return new AssetsConfig($config);
        };

        $container['assets/builder'] = function () {
            return new AssetsBuilder();
        };

        /**
         * @param Container $container Pimple DI container.
         * @return AssetManager
         */
        $container['assets'] = function (Container $container) {
            $assetsBuilder = $container['assets/builder'];
            $assetsConfig = $container['assets/config'];

            return $assetsBuilder($assetsConfig);
        };
    }
1347395
protected function parseRootEntries(ContainerInterface $container)
    {
        if (\is_array($root = $this->getFromDca('list/sorting/root'))) {
            $entries = $container->getBasicDefinition()->getRootEntries();

            $container->getBasicDefinition()->setRootEntries(\array_merge($entries, $root));
        }
    }
897054
public function setContainer(\Interne\SeanceBundle\Entity\Container $container = null)
    {
        $this->container = $container;

        return $this;
    }
746205
protected function call($method, $id)
    {
        if (!$this->container) {
            throw new ContainerException('Container not injected');
        }
        if (\method_exists($this->container, $method)) {
            return $this->container->$method($id);
        }
        throw new ContainerException('Container method not found: ' . $method);
    }
43933
public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
        $this->eventDispatcher = $this->container->get('event_dispatcher');
    }