Skip to content

Instantly share code, notes, and snippets.

Avatar

Roman Schmid bummzack

View GitHub Profile
View Dockerfile
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 \
View FluentQueryPlugin.php
<?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 Sep 18, 2019
Stripe Payments with Stripe Checkout (JS) and SilverStripe 4 + SilverShop
View Shop_Checkout_Config.php
<?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 Nov 6, 2018
Markdown textfield
View Markdown.php
<?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 Oct 4, 2018
Properly remove records from localized table once deleted.
View FluentCascadeDeleteExtension.php
<?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 Mar 29, 2018
Fix build issues when creating release builds with corber (cordova)
View readme.md

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 Mar 27, 2018
Conditional payment method in SilverShop
View CheckoutStep_CustomPaymentMethod.php
<?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 Mar 8, 2018
Filtered files in fluent (SS3)
View FluentFileFilteredExtension.php
<?php
/**
* Allow filtering files per locale
*/
class FluentFileFilteredExtension extends FluentFilteredExtension
{
public function canViewInLocale($locale = null)
{
if ($this->isFolder()) {
@bummzack
bummzack / CustomBillingAddressComponent.php
Created Dec 31, 2017
SilverShop: Optional Billing Address in Single-Page-Checkout
View CustomBillingAddressComponent.php
<?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
@bummzack
bummzack / CheckoutControllerExtension.php
Created Oct 25, 2017
SilverShop checkout address validation
View CheckoutControllerExtension.php
<?php
/**
* Apply this extension to the checkout page controller, eg:
*
* ```
* CheckoutPage_Controller:
* extensions:
* - CheckoutControllerExtension
* ```