mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-20 06:00:08 -07:00
32 lines
615 B
PHP
32 lines
615 B
PHP
<?php
|
|
|
|
namespace AppBundle\Repository\LDraw;
|
|
|
|
use AppBundle\Entity\LDraw\Author;
|
|
use AppBundle\Repository\BaseRepository;
|
|
|
|
class AuthorRepository extends BaseRepository
|
|
{
|
|
public function findOneByName($name)
|
|
{
|
|
return $this->findOneBy(['name' => $name]);
|
|
}
|
|
|
|
/**
|
|
* Get existing entity or create new.
|
|
*
|
|
* @param $name
|
|
*
|
|
* @return Author
|
|
*/
|
|
public function getOrCreate($name)
|
|
{
|
|
if (($author = $this->findOneByName($name)) == null) {
|
|
$author = new Author();
|
|
$author->setName($name);
|
|
}
|
|
|
|
return $author;
|
|
}
|
|
}
|