Skip to content

Instantly share code, notes, and snippets.

@dionisos2
dionisos2 / Concept.php
Last active December 14, 2015 22:59 — forked from anonymous/Concept.php
If i remove $this->em->flush($conceptNew); i get: Entity of type Ukratio\TrouveToutBundle\Entity\ConceptConcept has identity through a foreign entity Ukratio\TrouveToutBundle\Entity\Concept, however this entity has no identity itself. You have to call EntityManager#persist() on the related entity and make sure that an identifier was generated be…
<?php
namespace Ukratio\TrouveToutBundle\Entity;
use /*all the uses*/
/**
* Ukratio\TrouveToutBundle\Entity\Concept
*
@dionisos2
dionisos2 / A.php
Last active December 15, 2015 08:39
Problem to build a SQL query with the queryBuilder
<?php
class A
{
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="B", mappedBy="")
* @Assert\Valid(traverse=true)
$builder->add('selected', 'checkbox', array('required' => false,));
@dionisos2
dionisos2 / SetType.php
Last active December 16, 2015 14:39
Form theming problem.
class SetType extends ConceptType
{
public function getName()
{
return 'TrouveTout_Set';
}
}
<?php
namespace Ukratio\TrouveToutBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
<?php
namespace Ukratio\TrouveToutBundle\Form\EventListener;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvents;
use Doctrine\ORM\EntityManager;
<?php
namespace Ukratio\TrouveToutBundle\Form\EventListener;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Validator\ConstraintValidatorFactory;
class Combination:
def __init__(self, elements, len_list):
self.elements = elements
self.len_list = len_list
def __len__(self):
return pow(len(self.elements), self.len_list)
def __iter__(self):
for element in self.elements:
function factorial(num) {
var fact = 1;
for(var i=2; i<=num; i++) {
fact *= i;
}
return fact;
}
function getReps(str) {
var sortedLetters = str.split("").sort();
def P(X):
"""
X is P, if it auto-satisfate itself
"""
return X(X)
def V(X):
"""
X is V, if X is a property
"""