Gateway Class

The Gateway directly interacts with the persistence layer (databases, files) to grab and return data. It takes a request form a Repository, figures out how to grab the needed info, and then returns that info to the Repository.

Creating a Gateway

Normally you shouldn't be creating Gateways yourself. If you refer to the Repository documentation and use the recommended Repository creation method of utilizing the RepositoryFactory class, then it will create a Gateway for you and handle passing it off to the Repository.

If for some reason you do need to create your own Gateway object and you're using Cora's default Gateway, then do so like this:

$db = \Cora\Database::getDb('name_of_db_connection_to_use');
$gateway = new Gateway($db);

Optionally you can include a couple extra arguments in the form of setting the table to use and the unique identifying field of records in that table if it's something other than 'id':

$db = \Cora\Database::getDb('name_of_db_connection_to_use');
$gateway = new Gateway($db, 'users', 'email');