/**
* Creates a new naming context and add's it to the passed manager.
*
* @param \AppserverIo\Psr\Application\ManagerInterface $manager The manager to add the naming context to
*
* @return void
*/
public static function visit(ManagerSettingsAwareInterface $manager)
{
// load the path to the web application
$application = $manager->getApplication();
$webappPath = $application->getWebappPath();
// initialize the variable for the properties
$properties = null;
// load the configuration base directory
if ($baseDirectory = $manager->getManagerSettings()->getBaseDirectory()) {
// look for naming context properties in the manager's base directory
$propertiesFile = DirectoryKeys::realpath(sprintf('%s/%s/%s', $webappPath, $baseDirectory, NamingContextFactory::CONFIGURATION_FILE));
// load the properties from the configuration file
if (file_exists($propertiesFile)) {
$properties = Properties::create()->load($propertiesFile);
}
}
// create the initial context instance
$initialContext = new InitialContext($properties);
$initialContext->injectApplication($application);
// set the initial context in the manager
$manager->injectInitialContext($initialContext);
}