protected function registerContentTypes(Jarves $jarves, ContainerInterface $container) { /** @var ContentRender $jarvesContentRender */ $jarvesContentRender = $container->get('jarves.content.render'); foreach ($jarves->getConfigs() as $bundleConfig) { if ($bundleConfig->getContentTypes()) { foreach ($bundleConfig->getContentTypes() as $contentType) { if ('stopper' === $contentType->getId()) { continue; } if (!$contentType->getService()) { throw new \RuntimeException(sprintf('For content type %s:%s is no service defined', $bundleConfig->getName(), $contentType->getId())); } if (!$container->has($contentType->getService())) { throw new \RuntimeException(sprintf('Service `%s` for content type %s:%s does not exist', $contentType->getService(), $bundleConfig->getName(), $contentType->getId())); } $instance = $container->get($contentType->getService()); if ($instance instanceof ContentTypes\AbstractType) { $jarvesContentRender->addType($contentType->getId(), $container->get($contentType->getService())); } else { throw new \RuntimeException(sprintf('Content type %s:%s with service %s has wrong parent class', $bundleConfig->getName(), $contentType->getId(), $contentType->getService())); } } } } }