Example #1
0
        $params['certificate'] = isset($arguments[3]) ? $arguments[3] : null;
        $params['privateKey'] = isset($arguments[4]) ? $arguments[4] : null;
        $params['environment'] = !isset($arguments[2]) ? $cont->environment : null;
    }
    $config = $cont->config;
    $proxySettings = null;
    if ($config('scalr.aws.use_proxy') && in_array($config('scalr.connections.proxy.use_on'), array('both', 'scalr'))) {
        $proxySettings = $config('scalr.connections.proxy');
    }
    $serviceid = 'aws.' . hash('sha256', sprintf("%s|%s|%s|%s|%s", $params['accessKeyId'], $params['secretAccessKey'], $params['region'], !empty($params['certificate']) ? crc32($params['certificate']) : '-', !empty($params['privateKey']) ? crc32($params['privateKey']) : '-'), false);
    if (!$cont->initialized($serviceid)) {
        $cont->setShared($serviceid, function ($cont) use($params, $proxySettings) {
            if (empty($params['secretAccessKey']) || empty($params['accessKeyId'])) {
                throw new \Scalr\Exception\InvalidCloudCredentialsException();
            }
            $aws = new \Scalr\Service\Aws($params['accessKeyId'], $params['secretAccessKey'], $params['region'], $params['certificate'], $params['privateKey']);
            if ($proxySettings !== null) {
                $aws->setProxy($proxySettings['host'], $proxySettings['port'], $proxySettings['user'], $proxySettings['pass'], $proxySettings['type']);
            }
            $observer = new \Scalr\Service\Aws\Plugin\EventObserver($aws);
            $aws->setEventObserver($observer);
            if (isset($params['environment']) && $params['environment'] instanceof \Scalr_Environment) {
                $aws->setEnvironment($params['environment']);
            }
            return $aws;
        });
    }
    return $cont->get($serviceid);
};
$container->setShared('auditLogStorage', function ($cont) {
    $type = 'Mysql';
Example #2
0
File: di.php Project: recipe/scalr
    } elseif (isset($arguments[1]) && $arguments[1] instanceof \Scalr_Environment) {
        $params['region'] = !empty($arguments[0]) ? (string) $arguments[0] : null;
        $env = $arguments[1];
        $traitFetchEnvProperties($env);
    } else {
        $params['region'] = isset($arguments[0]) ? $arguments[0] : ($cont->initialized('dbServer') ? $cont->awsRegion : null);
        $params['accessKeyId'] = isset($arguments[1]) ? $arguments[1] : $cont->awsAccessKeyId;
        $params['secretAccessKey'] = isset($arguments[2]) ? $arguments[2] : $cont->awsSecretAccessKey;
        $params['certificate'] = isset($arguments[3]) ? $arguments[3] : $cont->awsCertificate;
        $params['privateKey'] = isset($arguments[4]) ? $arguments[4] : $cont->awsPrivateKey;
        $params['environment'] = !isset($arguments[2]) ? $cont->environment : null;
    }
    $serviceid = 'aws.' . hash('sha256', sprintf("%s|%s|%s|%s|%s", $params['accessKeyId'], $params['secretAccessKey'], $params['region'], !empty($params['certificate']) ? crc32($params['certificate']) : '-', !empty($params['privateKey']) ? crc32($params['privateKey']) : '-'), false);
    if (!$cont->initialized($serviceid)) {
        $cont->setShared($serviceid, function ($cont) use($params) {
            $aws = new \Scalr\Service\Aws($params['accessKeyId'], $params['secretAccessKey'], $params['region'], $params['certificate'], $params['privateKey']);
            $observer = new \Scalr\Service\Aws\Plugin\EventObserver($aws);
            $aws->setEventObserver($observer);
            if (isset($params['environment']) && $params['environment'] instanceof \Scalr_Environment) {
                $aws->setEnvironment($params['environment']);
            }
            return $aws;
        });
    }
    return $cont->get($serviceid);
};
$container->setShared('auditLogStorage', function ($cont) {
    $dsn = $cont->get('adodb.dsn');
    $type = 'Mysql';
    $storageClass = 'Scalr\\Logger\\' . $type . 'LoggerStorage';
    return new $storageClass(array('dsn' => $dsn));