mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-16 20:30:09 -07:00
30 lines
647 B
PHP
30 lines
647 B
PHP
<?php
|
|
|
|
namespace AppBundle\Repository\LDraw;
|
|
|
|
use AppBundle\Entity\LDraw\Alias;
|
|
use AppBundle\Entity\LDraw\Model;
|
|
use AppBundle\Repository\BaseRepository;
|
|
|
|
class AliasRepository extends BaseRepository
|
|
{
|
|
/**
|
|
* Get existing entity or create new.
|
|
*
|
|
* @param $number
|
|
* @param Model $model
|
|
*
|
|
* @return Alias
|
|
*/
|
|
public function getOrCreate($number, $model)
|
|
{
|
|
if (($alias = $this->findOneBy(['number' => $number, 'model' => $model])) == null) {
|
|
$alias = new Alias();
|
|
$alias->setModel($model);
|
|
$alias->setNumber($number);
|
|
}
|
|
|
|
return $alias;
|
|
}
|
|
}
|