Skip to content

Instantly share code, notes, and snippets.

View bummzack's full-sized avatar

Roman Schmid bummzack

View GitHub Profile
@bummzack
bummzack / FluentQueryPlugin.php
Last active August 19, 2021 13:13
Fluent query plugin for SilverStripe GraphQL
<?php
namespace Mutoco\GraphQL;
use SilverStripe\GraphQL\Schema\Field\ModelQuery;
use SilverStripe\GraphQL\Schema\Interfaces\ModelQueryPlugin;
use SilverStripe\GraphQL\Schema\Interfaces\SchemaUpdater;
use SilverStripe\GraphQL\Schema\Schema;
use SilverStripe\GraphQL\Schema\Type\Enum;
FROM brettt89/silverstripe-web:7.4-apache
RUN apt-get update && apt-get install -y \
libzip-dev zip unzip git nano
# Install additional extensions
RUN install-php-extensions imagick xdebug
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
<?php
namespace MyProject\GraphQL;
use SilverStripe\GraphQL\Schema\Field\ModelQuery;
use SilverStripe\GraphQL\Schema\Interfaces\ModelQueryPlugin;
use SilverStripe\GraphQL\Schema\Interfaces\SchemaUpdater;
use SilverStripe\GraphQL\Schema\Schema;
use SilverStripe\GraphQL\Schema\Type\Enum;
@bummzack
bummzack / Shop_Checkout_Config.php
Last active September 18, 2019 16:04
Stripe Payments with Stripe Checkout (JS) and SilverStripe 4 + SilverShop
<?php
namespace Bummzack\Shop\Checkout;
use SilverShop\Checkout\CheckoutComponentConfig;
use SilverShop\Checkout\Component\Notes;
use SilverShop\Checkout\Component\Terms;
use SilverShop\Model\Order;
class Config extends CheckoutComponentConfig
@bummzack
bummzack / Markdown.php
Created November 6, 2018 20:40
Markdown textfield
<?php
namespace App\ORM;
use Exception;
use Psr\Container\NotFoundExceptionInterface;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\FieldType\DBVarchar;
class Markdown extends DBVarchar
@bummzack
bummzack / FluentCascadeDeleteExtension.php
Last active October 4, 2018 09:58
Properly remove records from localized table once deleted.
<?php
namespace Bummzack\Extensions;
use SilverStripe\Core\ClassInfo;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Queries\SQLDelete;
use SilverStripe\Versioned\Versioned;
@bummzack
bummzack / readme.md
Last active March 29, 2018 21:29
Fix build issues when creating release builds with corber (cordova)

Memory issues

When building a large app, the default memory of the gradle engine is potentially too low (it's at 2GB per default). The memory can be increased via the build-extras.gradle file (also see: https://cordova.apache.org/docs/en/latest/guide/platforms/android/#setting-gradle-properties).

The problem with this approach is, that the build-extras.gradle resides in the platforms/android directory and will be deleted if you choose to remove/reinstall the platform.

To solve that, create a build hook that copies the file from your project root.

@bummzack
bummzack / CheckoutStep_CustomPaymentMethod.php
Last active March 27, 2018 12:28
Conditional payment method in SilverShop
<?php
use SilverStripe\Omnipay\GatewayInfo;
/**
*/
class CheckoutStep_CustomPaymentMethod extends CheckoutStep_PaymentMethod
{
public static function get_supported_gateways(Order $order = null)
{
@bummzack
bummzack / FluentFileFilteredExtension.php
Created March 8, 2018 08:12
Filtered files in fluent (SS3)
<?php
/**
* Allow filtering files per locale
*/
class FluentFileFilteredExtension extends FluentFilteredExtension
{
public function canViewInLocale($locale = null)
{
if ($this->isFolder()) {
@bummzack
bummzack / CustomBillingAddressComponent.php
Created December 31, 2017 20:07
SilverShop: Optional Billing Address in Single-Page-Checkout
<?php
/**
* Custom billing address component that makes the billing address optional by default.
* When toggling the `SeparateBillingAddress` checkbox, the address becomes mandatory.
*/
class CustomBillingAddressComponent extends BillingAddressCheckoutComponent
{
/**
* No required fields, since this is optional