コード例 #1
0
 /**
  * @param ContainerInterface $container
  * @param string             $requestedName
  * @param array|null         $options
  * @return DynamoDbSaveHandler
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('Config');
     if (!isset($config['aws_zf2']['session']['save_handler']['dynamodb'])) {
         throw new ServiceNotCreatedException('ZF2 AWS PHP SDK configuration is missing a "dynamodb" key. ' . 'Have you copied "config/aws_zf2.local.php.dist" into your ' . 'project (without the .dist extension)?');
     }
     /** @var AwsSdk $awsSdk */
     $awsSdk = $container->get(AwsSdk::class);
     $saveHandlerConfig = $config['aws_zf2']['session']['save_handler']['dynamodb'];
     $sessionHandler = SessionHandler::fromClient($awsSdk->createDynamoDb(), $saveHandlerConfig);
     return new DynamoDbSaveHandler($sessionHandler);
 }
コード例 #2
0
 /**
  * Convenience method for instantiating and registering the DynamoDB
  * Session handler with this DynamoDB client object.
  *
  * @param array $config Array of options for the session handler factory
  *
  * @return SessionHandler
  */
 public function registerSessionHandler(array $config = [])
 {
     $handler = SessionHandler::fromClient($this, $config);
     $handler->register();
     return $handler;
 }
コード例 #3
0
 public function __construct($options, $table)
 {
     $this->client = new DynamoDbClient(array_merge(['version' => '2012-08-10'], $options));
     $this->table = $table;
     $this->handler = SessionHandler::fromClient($this->client, ['table_name' => $this->table, 'session_lifetime' => $this->getSessionLifetime()]);
 }
コード例 #4
0
 /**
  * @param \Aws\DynamoDb\DynamoDbClient $client
  * @param $config array
  */
 public function __construct(DynamoDbClient $client, array $config)
 {
     $this->client = $client;
     $config['dynamodb_client'] = $client;
     $this->handler = \Aws\DynamoDb\SessionHandler::fromClient($client, $config);
 }
コード例 #5
0
ファイル: connect.php プロジェクト: apple121/bebras-platform
        $connexionString = "mysql:host=" . $config->db->mysql->host . ";dbname=" . $config->db->mysql->database;
        if ($config->db->mysql->logged) {
            $db = new LoggedPDO($connexionString, $config->db->mysql->user, $config->db->mysql->password, $pdo_options);
        } else {
            $db = new PDO($connexionString, $config->db->mysql->user, $config->db->mysql->password, $pdo_options);
        }
        $db->exec("SET time_zone='" . $offset . "';");
    } catch (Exception $e) {
        die("Erreur : " . $e->getMessage());
    }
    return $db;
}
function connect_dynamoDB($config)
{
    $client = DynamoDbClient::factory(array('credentials' => array('key' => $config->aws->key, 'secret' => $config->aws->secret), 'region' => $config->aws->region, 'version' => '2012-08-10'));
    return $client;
}
if ($config->db->dynamoSessions) {
    require_once dirname(__FILE__) . '/../vendor/autoload.php';
    $dynamoDB = connect_dynamoDB($config);
    // registering the dynamodb session handler performs some useless operations
    // in session!
    if (!isset($noSessions) || !$noSessions) {
        $sessionHandler = SessionHandler::fromClient($dynamoDB, array('table_name' => $config->db->dynamoDBPrefix . 'sessions'));
        $sessionHandler->register();
    }
}
if ($config->db->use != "dynamoDB" || !isset($noSQL) || !$noSQL) {
    // mysql is almost always used
    $db = connect_pdo($config);
}