Skip to content

Instantly share code, notes, and snippets.

View bummzack's full-sized avatar

Roman Schmid bummzack

View GitHub Profile
@bummzack
bummzack / restful_simpleauth.md
Last active November 20, 2016 19:25
Authentication using Ember simple auth and SilverStripe RESTfulAPI

Authentication using Ember simple auth and SilverStripe RESTful API

The goal of this GIST is to give a short summary of what is needed to perform authentication from an ember.js application using simple-auth and the SilverStripe RESTful API module

Prerequisites

Here's a list of the software that was used:

Frontend

@bummzack
bummzack / gist:5d9507c88398508b87d2
Created May 27, 2015 12:19
Simple frontend form implementation with SortableUploadField
// Data Record Class : DataRecord.php
<?php
class DataRecord extends DataObject
{
private static $db = array(
'Firstname' => 'Varchar(255)',
'Lastname' => 'Varchar(255)'
);
private static $many_many = array(
// Data Record Class : DataRecord.php
<?php
class DataRecord extends DataObject
{
private static $db = array(
'Firstname' => 'Varchar(255)',
'Lastname' => 'Varchar(255)'
);
private static $many_many = array(
@bummzack
bummzack / OwnerCanExtension.php
Last active August 29, 2015 14:24
Extension for member based API access (SilverStripe RESTfulAPI)
<?php
/**
* Extension that adds permissions for object owners
*
* The desired permissions have to be set as extension parameters.
* Allowed permission values are:
* - view
* - edit
* - delete
*
@bummzack
bummzack / silverstripe-gulp.md
Created November 4, 2015 10:28
Live-reload and fast CSS compilation for a SilverStripe website using gulp.js

Live-reload and fast CSS compilation for a SilverStripe website using gulp.js

Steps to success:

  1. Install gulp globally (do this only once): npm install -g gulp
  2. In your project folder, add gulp: npm install --save-dev gulp
  3. Install browser-sync to enable auto-updated and synchronised websites across all your browsers: npm install -g browser-sync
  4. Install libsass for super fast SCSS compilation: npm install --save-dev gulp-sass
  5. Install sourcemaps-plugin if you want them: npm install --save-dev gulp-sourcemaps
  6. Of course you can also add gulp plugins to concatenate and minify your JavaScript and CSS.
@bummzack
bummzack / ControllerExtension.php
Created December 23, 2015 14:47
SilverStripe Controller that sets the default locale on all controllers upon init. Helps resolve translation issues.
class ControllerExtension extends Extension
{
public function onBeforeInit()
{
// Ensure the locale is set properly on all requests (otherwise AJAX requests might return templates rendered
// with wrong locales).
i18n::set_default_locale(Config::inst()->get('i18n', 'default_locale'));
}
}
@bummzack
bummzack / FixedConfirmedPasswordField.php
Created February 2, 2016 09:51
SilverStripe Member signup page.
<?php
/**
* Fix for issue https://github.com/silverstripe/silverstripe-framework/issues/2496
*/
class FixedConfirmedPasswordField extends ConfirmedPasswordField
{
protected $useMemberValidator = false;
public function getUseMemberValidator()
<?php
/**
* A better Member_Validator
*
* Custom validation for the Member object can be achieved through an
* {@link DataExtension} on the BetterMemberValidator object.
*/
class BetterMemberValidator extends RequiredFields
{
<?php
/**
* Fix an issue with Omnipay 2.0 and the shop system.
* The shop assumes that all gateways support the "purchase" method, but that isn't the case.
*/
class FixedPurchaseService extends PurchaseService
{
/**
@bummzack
bummzack / Shop-AJAX-addToCart.md
Last active July 20, 2016 08:47
Explanation how to set up quantity fields for "add to cart" on project-lists.

Setting up JavaScript enabled add-to-cart functionality with quantity-field

Requirements

PHP

The shop-ajax module:

composer require markguinn/silverstripe-shop-ajax