1. Go to this page and download the library: Download atwx/silverstripe-gate-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
atwx / silverstripe-gate-api example snippets
$site = ManagedSite::getByDomain('example.com');
$site->callApi('query', ['class' => 'ScheduleEntry', 'limit' => 5]);
// or through the service, which has convenience wrappers
SiteApiClient::singleton()->create(
$site,
'ScheduleEntry',
['Title' => 'Welcome', 'Time' => '09:00:00', 'EventDayID' => 5, 'Speakers' => [7, 9]],
['sub' => '[email protected]']
);
class MySitePolicyExtension extends Extension
{
public function updateSiteAccess(bool &$allowed, ManagedSite $site, Member $member, string $scope)
{
$allowed = $allowed && $this->myOwnRule($site, $member, $scope);
}
}