ynloultratech /
graphql-bundle
| 1 | <?php |
||
| 2 | /******************************************************************************* |
||
| 3 | * This file is part of the GraphQL Bundle package. |
||
| 4 | * |
||
| 5 | * (c) YnloUltratech <[email protected]> |
||
| 6 | * |
||
| 7 | * For the full copyright and license information, please view the LICENSE |
||
| 8 | * file that was distributed with this source code. |
||
| 9 | ******************************************************************************/ |
||
| 10 | |||
| 11 | namespace Ynlo\GraphQLBundle\Test\Helper; |
||
| 12 | |||
| 13 | use Doctrine\Bundle\DoctrineBundle\Registry; |
||
| 14 | use Doctrine\Common\Persistence\ObjectRepository; |
||
| 15 | use Doctrine\ORM\EntityRepository; |
||
| 16 | use Symfony\Bundle\FrameworkBundle\Client; |
||
| 17 | use Ynlo\GraphQLBundle\Model\NodeInterface; |
||
| 18 | use Ynlo\GraphQLBundle\Util\IDEncoder; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @method Client getClient() |
||
| 22 | * |
||
| 23 | * @deprecated in favor of Behat tests |
||
| 24 | */ |
||
| 25 | trait DoctrineHelperTrait |
||
| 26 | { |
||
| 27 | public static function getDoctrine(): Registry |
||
| 28 | { |
||
| 29 | return static::getClient()->getKernel()->getContainer()->get('doctrine'); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param string $class |
||
| 34 | * |
||
| 35 | * @return ObjectRepository|EntityRepository |
||
| 36 | */ |
||
| 37 | public static function getRepository(string $class): ObjectRepository |
||
| 38 | { |
||
| 39 | return static::getDoctrine()->getRepository($class); |
||
|
0 ignored issues
–
show
|
|||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Find a database record from global id |
||
| 44 | * |
||
| 45 | * findOneByGlobalId('VXNlcjox') => object |
||
| 46 | * |
||
| 47 | * @param mixed $id |
||
| 48 | * |
||
| 49 | * @return NodeInterface |
||
| 50 | */ |
||
| 51 | public static function findOneByGlobalId($id) |
||
| 52 | { |
||
| 53 | return IDEncoder::decode($id); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |