Skip to content

Instantly share code, notes, and snippets.

View maxime-rainville's full-sized avatar

Maxime Rainville maxime-rainville

View GitHub Profile
Go look under papa's chair.
@maxime-rainville
maxime-rainville / Company.php
Created December 6, 2023 04:45
Test of ViewableData Gridfield
<?php
use SilverStripe\View\ArrayData;
class Company extends ArrayData
{
public function __construct($id=0, $data=[])
{
if (empty($data)) {
@maxime-rainville
maxime-rainville / Folder.yml
Created December 5, 2023 23:34
Example of how to overide asset-admin GraphQL
# app/_graphql/types/Folder.yml
# This will be merged with vendor/silverstripe/asset-admin/_graphql/types/Folder.yml
Folder:
fields:
'children(filter: FileFilterInput)':
type: '[FileInterface]'
plugins:
sorter:
# If we used the array syntax (e.g. [MyFolderTypeResolver, sortChildren]),
@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/"
@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 / 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 / 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 / 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 / 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 / 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