Example #1
0
File: di.php Project: mheydt/scalr
        throw new \BadFunctionCallException('Environment value must be provided!');
    } else {
        if ($arguments[0] instanceof \Scalr_Environment) {
            $env = $arguments[0];
        } else {
            $env = $cont->environment;
        }
        $traitFetchEnvProperties($env);
    }
    $serviceId = 'azure.' . hash('sha256', sprintf("%s|%s|%s", $params['appClientId'], $params['appSecretKey'], $params['tenantName']), false);
    if (!$cont->initialized($serviceId)) {
        $cont->setShared($serviceId, function ($cont) use($params) {
            if (empty($params['appClientId']) || empty($params['appSecretKey'])) {
                throw new \Scalr\Exception\InvalidCloudCredentialsException();
            }
            $azure = new \Scalr\Service\Azure($params['appClientId'], $params['appSecretKey'], $params['tenantName']);
            $azure->setEnvironment($params['environment']);
            return $azure;
        });
    }
    return $cont->get($serviceId);
};
$container->mailer = function ($cont) {
    $mailer = new \Scalr\SimpleMailer();
    if ($cont->config->get('scalr.email.address')) {
        $mailer->setFrom($cont->config->get('scalr.email.address'), $cont->config->get('scalr.email.name'));
    }
    return $mailer;
};
$container->setShared('ldap.config', function ($cont) {
    $my = $cont->config->get('scalr.connections.ldap');
Example #2
0
File: di.php Project: scalr/scalr
            $env = $cont->environment;
        }
        $traitFetchEnvProperties($env);
    }
    $serviceId = 'azure.' . hash('sha256', sprintf("%s|%s|%s", $params['appClientId'], $params['appSecretKey'], $params['tenantName']), false);
    if (!$cont->initialized($serviceId)) {
        $config = $cont->config;
        $proxySettings = null;
        if ($config('scalr.azure.use_proxy') && in_array($config('scalr.connections.proxy.use_on'), ['both', 'scalr'])) {
            $proxySettings = $config('scalr.connections.proxy');
        }
        $cont->setShared($serviceId, function ($cont) use($params, $proxySettings) {
            if (empty($params['appClientId']) || empty($params['appSecretKey'])) {
                throw new \Scalr\Exception\InvalidCloudCredentialsException();
            }
            $azure = new \Scalr\Service\Azure($params['appClientId'], $params['appSecretKey'], $params['tenantName']);
            $azure->setEnvironment($params['environment']);
            if ($proxySettings !== null) {
                $azure->setProxy($proxySettings['host'], $proxySettings['port'], $proxySettings['user'], $proxySettings['pass'], $proxySettings['type'], $proxySettings['authtype']);
            }
            return $azure;
        });
    }
    return $cont->get($serviceId);
};
$container->mailer = function ($cont) {
    $mailer = new \Scalr\SimpleMailer();
    if ($cont->config->get('scalr.email.address')) {
        $mailer->setFrom($cont->config->get('scalr.email.address'), $cont->config->get('scalr.email.name'));
    }
    return $mailer;