Skip to content

Instantly share code, notes, and snippets.

View maxime-rainville's full-sized avatar

Maxime Rainville maxime-rainville

View GitHub Profile
@maxime-rainville
maxime-rainville / TestObject.php
Created August 13, 2019 21:31
Isolate BlockLink field
<?php
use DNADesign\Elemental\Extensions\ElementalPageExtension;
use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Admin\ModelAdmin;
use SilverStripe\Control\Director;
use SilverStripe\ORM\DataObject;
class TestObject extends DataObject
{
@maxime-rainville
maxime-rainville / .cow.pat.json
Last active May 27, 2020 03:16
4.6.0-beta plan
{
"silverstripe/installer": {
"PriorVersion": null,
"Version": "4.6.0-beta1",
"Changelog": null,
"Items": {
"silverstripe/recipe-cms": {
"PriorVersion": null,
"Version": "4.6.0-beta1",
"Changelog": null,
@maxime-rainville
maxime-rainville / behatrunner
Created June 25, 2020 22:15
Simple script to run behat test for a sivlerstripe project
#!/bin/bash
# This commands runs behat tests. It should be run from your project root.
# You need to specify what behat suite you want to run. e.g.: `behatrunner @asset-admin`.
# Note that the behat test will run in your current desktop session ... you will see chrome
# running and the behat test executed in front of you.
# Prequisites: chromedriver installed. silverstripe/recipe-testing installed in your project.
# Export envrionment variable
export SS_BASE_URL="http://localhost:8080/"
@maxime-rainville
maxime-rainville / ToastsContainer.js
Created September 14, 2020 09:56
Auto create Test Toast on page load
import React, { useEffect } from 'react';
import Toasts from 'components/Toasts/Toasts';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as toastsActions from 'state/toasts/ToastsActions';
// Just here for testing
const types = ['info', 'success', 'warning', 'error'];
// Just here for testing
@maxime-rainville
maxime-rainville / CreateRelated.php
Last active October 22, 2020 21:56
Creating lots of relations to file
<?php
use DNADesign\Elemental\Models\ElementContent;
use SilverStripe\Assets\Image;
use SilverStripe\Dev\BuildTask;
use SilverStripe\ElementalBannerBlock\Block\BannerBlock;
use SilverStripe\ORM\DB;
class CreateRelated extends BuildTask
{
@maxime-rainville
maxime-rainville / behatrunner.bash
Created March 10, 2022 05:11
Script to run behat
#!/bin/bash
# This commands runs behat tests. It should be run from your project root.
# You need to specify what behat suite you want to run. e.g.: `behatrunner @asset-admin`.
# Note that the behat test will run in your current desktop session ... you will see chrome
# running and the behat test executed in front of you.
# Prequisites: chromedriver installed. silverstripe/recipe-testing installed in your project.
# Export envrionment variable
export SS_BASE_URL="http://localhost:8080/"
@maxime-rainville
maxime-rainville / testGraphqQL.js
Created March 22, 2022 23:38
GraphQL Spam script for Silverstirpe CMS
const https = require('https');
const schema='tiny';
const forceClear = false;
// This is meant to immitate an actual browser
// So you need to stick your PHP session ID and your user agent string in here
const sessionid = '';
const useragent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0'
@maxime-rainville
maxime-rainville / PageController.php
Created October 31, 2022 20:58
Example to setup multiple action on a form
<?php
namespace {
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\TextField;
@maxime-rainville
maxime-rainville / schema.json
Created June 13, 2023 01:59
Elemental Form schema
{
"id":"admin\/elemental-area\/schema\/elementForm\/2",
"schema":{
"name":"ElementForm_2",
"id":"Form_ElementForm_2",
"action":"admin\/elemental-area\/ElementForm_2",
"method":"POST",
"attributes":{
"id":"Form_ElementForm_2",
"action":"admin\/elemental-area\/ElementForm_2",
@maxime-rainville
maxime-rainville / behatrunner.bash
Created August 8, 2023 06:09
Simple script for running behat test
#!/bin/bash
# This commands runs behat tests. It should be run from your project root.
# You need to specify what behat suite you want to run. e.g.: `behatrunner @asset-admin`.
# Note that the behat test will run in your current desktop session ... you will see chrome
# running and the behat test executed in front of you.
# Prequisites: chromedriver installed. silverstripe/recipe-testing installed in your project.
# Export envrionment variable
export SS_BASE_URL="http://localhost:8080/"