Skip to content

Instantly share code, notes, and snippets.

@fprochazka
Last active August 29, 2015 14:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fprochazka/45227e00fb7c798598f8 to your computer and use it in GitHub Desktop.
Save fprochazka/45227e00fb7c798598f8 to your computer and use it in GitHub Desktop.
/**
* @return ${TYPE_HINT}
*/
public ${STATIC} function ${GET_OR_IS}${NAME}()
{
#if (${STATIC} == "static")
return self::${DS}${FIELD_NAME};
#elseif ($TYPE_HINT.contains("Collection"))
return new \Kdyby\Doctrine\Collections\ReadOnlyCollectionWrapper($this->${FIELD_NAME});
#else
return $this->${FIELD_NAME};
#end
}
<?php
use Doctrine\Common\Collections\ArrayCollection;
class Something
{
/**
* @ORM\ManyToMany(targetEntity="Tag", cascade={"persist"})
* @var Tag[]|ArrayCollection
*/
protected $tags;
public function __construct()
{
$this->tags = new ArrayCollection();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment