Last active
August 29, 2015 13:57
-
-
Save matteosister/9536983 to your computer and use it in GitHub Desktop.
A trait to use the PhpOption in the EntityRepository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Vendor\Repository; | |
use PhpOption\Option; | |
use Doctrine\DBAL\LockMode; | |
trait OptionRepositoryTrait | |
{ | |
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null) | |
{ | |
return Option::fromValue(parent::find($id, $lockMode, $lockVersion)); | |
} | |
public function findAll() | |
{ | |
return Option::fromValue(parent::findAll()); | |
} | |
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |
{ | |
return Option::fromValue(parent::findBy($criteria, $orderBy, $limit, $offset)); | |
} | |
public function findOneBy(array $criteria, array $orderBy = null) | |
{ | |
return Option::fromValue(parent::findOneBy($criteria, $orderBy)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment