lifeboat/silverstripe

Lifeboat PHP SDK - Silverstripe Wrapper

dev-main 2023-04-03 12:55 UTC

This package is auto-updated.

Last update: 2024-05-03 15:10:51 UTC


README

A simple wrapper for Lifeboat PHP SDK

This wrapper provides access to 2 classes which your app can extend from to make it easy to create Lifeboat Apps. It also loads the APP_ID and APP_SECRET directly from your environment variables.

Installation

You can install this module via Composer. Run the command

composer require lifeboat/silverstripe

Configuration

.env

LIFEBOAT_APP_ID='[[Your App ID goes here]]'
LIFEBOAT_APP_SECRET='[[Your App Secret goes here]]'

Alternatively create a .yml config

lifeboat.yml

---
Name: lifeboat_config
After:
  - '#lifeboat_silverstripe_app'
---
Lifeboat\Models\Site:
  APP_ID: "[[YOUR APP ID]]"
  APP_SECRET: "[[YOUR APP SECRET]]"
---

 

Helper Classes

Lifeboat\Models\Site

// Get the current active site object
Lifeboat\Models\Site::curr();

This object will automatically store the user's active site and allows for automatic filtering of the objects so that you only show objects this user has access to.

 

Lifeboat\Controllers\AppController

class YourController extends Lifeboat\Controllers\AppController {}

By extending from the AppController class you'll ensure that anyone that interacts with your app is authenticated and is using the correct site object

 

Lifeboat\Extensions\SiteObject

YourObject:
  extensions:
    - Lifeboat\Extensions\SiteObject

Make sure to add the SiteObject extension to your Data Models. This will add a Site relationship and automatically filter objects based on the currently active site via augmentSQL.