Skip to content

Instantly share code, notes, and snippets.

@axelvnk
axelvnk / DocumentFixture.php
Last active September 11, 2020 11:04
Sulu form fixture and use in document fixture
<?php
namespace App\DataFixtures\Document;
use Doctrine\ORM\EntityManagerInterface;
use Sulu\Bundle\FormBundle\Entity\Form;
use Sulu\Component\DocumentManager\DocumentManager;
use Sulu\Bundle\DocumentManagerBundle\DataFixtures\DocumentFixtureInterface;
class HomepageFixture implements DocumentFixtureInterface
@axelvnk
axelvnk / MappedSuperClassSubscriber.php
Created February 21, 2019 12:42
Make classes from your bundles overridable
<?php
namespace Axelvnk\ResourceBundle\EventListener;
use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\ClassMetadata;
@axelvnk
axelvnk / OrSearchFilter.php
Last active June 9, 2024 15:20
Api platform OR search filter
<?php
namespace Axelvkn\AppBundle\Filter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use Doctrine\ORM\QueryBuilder;
class OrSearchFilter extends SearchFilter
@axelvnk
axelvnk / EntityListener.php
Created August 29, 2018 07:26
Entitylistener that dispatches custom events for each entity operation
<?php
namespace Axelvnk\CustomEntityEventBundle\EventListener;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Events;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
@axelvnk
axelvnk / CollectionForm.js
Created August 16, 2018 20:39
Symfony collection form javascript library
/**
* Collection Form plugin
*
* @param element
* @constructor
*/
var CollectionForm = function (element) {
this.$element = $(element);
this.$list = this.$element.find('[data-form-collection="list"]:first');
this.count = this.$list.children().length;
@axelvnk
axelvnk / export.js
Last active September 21, 2021 10:41
Export Mongo query result to CSV
db.getCollection('event').find({whatever_field: 'value'}).forEach(function(u) {
print('"' + u._id + '";"' + u.createdAt.toJSON() + '";');
});