Skip to content

Instantly share code, notes, and snippets.

View sb-relaxt-at's full-sized avatar

Stephan sb-relaxt-at

  • relaxt Webdienstleistungsagentur GmbH
  • Vienna, Austria
View GitHub Profile
<?php
namespace App\Admin;
use App\Entity\FooEntity;
use SilverStripe\Admin\ModelAdmin;
class FooAdmin extends ModelAdmin {
<?php
namespace App\Entity;
use SilverStripe\ORM\DataObject;
class BarEntity extends DataObject {
}
<?php
namespace App\Entity;
use SilverStripe\ORM\DataObject;
class FooEntity extends DataObject {
private static $db = [
@sb-relaxt-at
sb-relaxt-at / TestType.php
Created March 20, 2019 11:28
symfony-docs/issues/11193
<?php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class TestType extends AbstractType {
<?php
/**
* Class FolderUpdateFilesystemExtension fixes issue silverstripe-framework#4993:
* Renaming Folders over more than two nested levels fails
*/
class FolderUpdateFilesystemExtension extends DataExtension {
public function onAfterWrite() {
$this->enhancedUpdateFilesystem();
public function updateFilesystem() {
$filenameBeforeUpdate = $this->Filename;
parent::updateFilesystem();
if($filenameBeforeUpdate != $this->Filename){
// in this case the filename has changed due to a changed parent
// we need to write the change to the db, otherwise the children won't see it
$this->write();
// no need to proceed as this method has already been called again by the write above
@sb-relaxt-at
sb-relaxt-at / Page.php
Last active August 29, 2015 14:26
silverstripe-codecompetition-2015
<?php
// Allows visitors to like each Page once per IP
// Code submitted by relaxt confusion labs
class Page extends SiteTree {
private static $has_many = array(
'Likes' => 'Page_Like'
);
<?php
/**
* This RedirectorPage differs from the regular one in so far, as it only redirects
* on the index action (no action specified) in contrast to the original one,
* which redirects on any immediate suburl
*
* @author Stephan Bauer <sb@relaxt.at>
*/
class BetterRedirectorPage extends RedirectorPage {