Skip to content

Instantly share code, notes, and snippets.

View tito10047's full-sized avatar

Jozef Môstka tito10047

View GitHub Profile
@tito10047
tito10047 / Order.php
Created September 3, 2024 17:45
EasyAdmin sortable CollectionField
<?php
//App/Entity/Order.php
#[ORM\Entity()]
#[ORM\Table(name: '`order`')]
class Order {
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'order', cascade: ["persist", "remove"], orphanRemoval: true)]
#[ORM\OrderBy(["position" => "ASC"])]
#[Assert\Valid]
private Collection $items;
@tito10047
tito10047 / NotAbandoned.php
Created April 20, 2024 19:09
NotAbandonedValidator
<?php
namespace App\Validator;
use Attribute;
use Symfony\Component\Validator\Constraint;
#[Attribute(Attribute::TARGET_PROPERTY)]
class NotAbandoned extends Constraint {
@tito10047
tito10047 / DuplicateEntityService.php
Created March 20, 2024 19:15
Duplicate Doctrine Entity recursive
<?php
namespace App\Service;
use Doctrine\Common\Collections\Collection;
use Doctrine\Persistence\ManagerRegistry;
class DuplicateEntityService {
/**
@tito10047
tito10047 / preloadStyleImages.js
Last active July 23, 2017 11:10
preload css images
function createStyle(css) {
var head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
@tito10047
tito10047 / jquery-set-class.js
Created July 23, 2017 07:05
jquery set class if not has already
$.fn.setClass = function(classes){
classes = classes.split(" ");
this.each(function () {
for(var i=0;i<classes.length;i++){
if (!$(this).hasClass(classes[i])){
$(this).addClass(classes[i]);
}
}
});
};
<?php
/**
* Created by PhpStorm.
* User: Jozef Môstka
* Date: 12.5.2017
* Time: 10:37
*/
ini_set('max_execution_time', 0);
set_time_limit(0);