self::$_singleton = $instance;
}
if (self::$_singleton === NULL) {
- $sys = CRM_Extension_System::singleton();
- $cache = Civi::cache('js_strings');
- self::$_singleton = new CRM_Core_Resources(
- $sys->getMapper(),
- $cache,
- CRM_Core_Config::isUpgradeMode() ? NULL : 'resCacheCode'
- );
+ self::$_singleton = Civi::service('resources');
}
return self::$_singleton;
}
// Expose legacy singletons as services in the container.
$singletons = array(
- 'resources' => 'CRM_Core_Resources',
'httpClient' => 'CRM_Utils_HttpClient',
'cache.default' => 'CRM_Utils_Cache',
'i18n' => 'CRM_Core_I18n',
}
$container->setAlias('cache.short', 'cache.default');
+ $container->setDefinition('resources', new Definition(
+ 'CRM_Core_Resources',
+ [new Reference('service_container')]
+ ))->setFactory(array(new Reference(self::SELF), 'createResources'));
+
$container->setDefinition('prevnext', new Definition(
'CRM_Core_PrevNextCache_Interface',
[new Reference('service_container')]
return $kernel;
}
+ /**
+ * @param ContainerInterface $container
+ * @return \CRM_Core_Resources
+ */
+ public static function createResources($container) {
+ $sys = \CRM_Extension_System::singleton();
+ return new \CRM_Core_Resources(
+ $sys->getMapper(),
+ $container->get('cache.js_strings'),
+ \CRM_Core_Config::isUpgradeMode() ? NULL : 'resCacheCode'
+ );
+ }
+
/**
* @param ContainerInterface $container
* @return \CRM_Core_PrevNextCache_Interface