/**
  * @internal
  * @codeCoverageIgnore
  */
 public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = null)
 {
     // Retreive database configuration from config file.
     $config = $container->get('Library\\UserConfig')['database'];
     $config['options']['buffer_results'] = true;
     // Set charset to utf8mb4 for MySQL, utf8 for everything else.
     if (stripos($config['driver'], 'mysql') === false) {
         $config['charset'] = 'utf8';
     } else {
         $config['charset'] = 'utf8mb4';
     }
     $adapter = new \Zend\Db\Adapter\Adapter($config);
     $database = \Nada\Factory::getDatabase($adapter);
     if ($database->isSqlite()) {
         $database->emulatedDatatypes = array('bool', 'date', 'decimal', 'timestamp');
     } elseif ($database->isMySql()) {
         $database->emulatedDatatypes = array('bool');
     }
     $database->setTimezone();
     // Return requested service, store instance of other service first
     if ($requestedName == 'Db') {
         $container->setService('Database\\Nada', $database);
         return $adapter;
     } else {
         $container->setService('Db', $adapter);
         return $database;
     }
 }
 /**
  * Attempt to marshal a translator from configuration.
  *
  * Returns:
  * - an MvcTranslator seeded with a DummyTranslator if "translator"
  *   configuration is available, and evaluates to boolean false.
  * - an MvcTranslator seed with an I18nTranslator if "translator"
  *   configuration is available, and is a non-empty array or a Traversable
  *   instance.
  * - null in all other cases, including absence of a configuration service.
  *
  * @param ContainerInterface $container
  * @return null|MvcTranslator
  */
 private function marshalTranslatorFromConfig(ContainerInterface $container)
 {
     if (!$container->has('config')) {
         return;
     }
     $config = $container->get('config');
     if (!array_key_exists('translator', $config)) {
         return;
     }
     // 'translator' => false
     if ($config['translator'] === false) {
         return new MvcTranslator(new DummyTranslator());
     }
     // Empty translator configuration
     if (is_array($config['translator']) && empty($config['translator'])) {
         return;
     }
     // Unusable translator configuration
     if (!is_array($config['translator']) && !$config['translator'] instanceof Traversable) {
         return;
     }
     // Create translator from configuration
     $i18nTranslator = I18nTranslator::factory($config['translator']);
     // Inject plugins, if present
     if ($container->has('TranslatorPluginManager')) {
         $i18nTranslator->setPluginManager($container->get('TranslatorPluginManager'));
     }
     // Inject into service manager instances
     if ($container instanceof ServiceManager) {
         $container->setService(TranslatorInterface::class, $i18nTranslator);
     }
     return new MvcTranslator($i18nTranslator);
 }