Skip to content

Instantly share code, notes, and snippets.

View bogdaniel's full-sized avatar

Bogdan Olteanu bogdaniel

  • Freelancer
  • Romania
View GitHub Profile
@bogdaniel
bogdaniel / 0.README.md
Created January 27, 2019 20:42
symfony from collection field add remove mit

Add/Remove items in a collection field

Configuration

  • Add the files
    • layout.html.twig
    • collection-field.html.twig
    • symfony-form.js

@bogdaniel
bogdaniel / Timestampable.php
Created January 27, 2019 20:04 — forked from muzfr7/Timestampable.php
Timestampable Trait for doctrine entities to use in order to not to repeat them in individual entities.
<?php
namespace AppBundle\Entity\Traits;
use Doctrine\ORM\Mapping as ORM;
/**
* Adds created at and updated at timestamps to entities.
* Entities using this must have HasLifecycleCallbacks annotation.
*
@bogdaniel
bogdaniel / Item.php
Created January 27, 2019 14:24 — forked from alexsegura/Item.php
Archivable pattern in Doctrine
<?php
use Doctrine\ORM\Mapping as ORM,
Doctrine\ORM\Event\LifecycleEventArgs;
/**
* @ORM\Table(name="item")
* @ORM\HasLifecycleCallbacks
*/
class Item
@bogdaniel
bogdaniel / DisconnectedMetadataFactory.php
Created November 7, 2017 07:10 — forked from janvennemann/DisconnectedMetadataFactory.php
Changes for DoctrineBundle PSR-4 support
<?php
class DisconnectedMetadataFactory
{
//...
/**
* Get a base path for a class
*
* @param string $name class name
* @param string $namespace class namespace
User Entity:
/**
* Array collection of users of group.
*
* @var ArrayCollection|User[]
*
* @JMS\Groups({
* "Users",
* "UserGroup.users",
* })
@bogdaniel
bogdaniel / haiku
Created December 2, 2016 22:48 — forked from friggeri/haiku
random heroku-like name generator
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
javascript:(function() {
var adjectives = [
"Autumn", "Hidden", "Bitter", "Misty", "Silent", "Empty", "Dry", "Dark", "Summer", "Icy",
"Delicate", "Quiet", "White", "Cool", "Spring", "Winter", "Patient", "Twilight", "Dawn",
"Crimson", "Wispy", "Weathered", "Blue", "Billowing", "Broken", "Cold", "Damp", "Falling",
"Frosty", "Green", "Long", "Late", "Lingering", "Bold", "Little", "Morning", "Muddy", "Old",
"Red", "Rough", "Still", "Small", "Sparkling", "Wandering", "Withered", "Wild", "Black",
"Young", "Holy", "Solitary", "Fragrant", "Aged", "Snowy", "Proud", "Floral", "Restless",
"Divine", "Polished", "Ancient", "Purple", "Lively", "Nameless"];
var nouns = [
@bogdaniel
bogdaniel / ContractController.php
Created October 29, 2016 10:59 — forked from webdevilopers/ContractController.php
Inject Entity and Repository into Service with Symfony2
<?php
use Plusquam\Bundle\ContractBundle\Service\Invoice;
class ContractAdminController extends Controller
{
/**
* Invoice action
*
* @return Response
<?php
class Controller
{
/**
* @Route("/submit", name="submit")
* @Method("POST")
*/
public function submitAction(Request $request)
{
$person = new Person();
@bogdaniel
bogdaniel / User.php
Created October 3, 2016 19:31 — forked from Ocramius/User.php
Doctrine 2 ManyToMany - the correct way
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User