Last active
October 10, 2019 07:38
-
-
Save imiroslavov/ce554ae19308a3c7aa03aa5eecb698f6 to your computer and use it in GitHub Desktop.
Repository generator
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 App\Repository; | |
use App\Entity\_Test_; | |
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | |
use Symfony\Bridge\Doctrine\RegistryInterface; | |
/** | |
* Class _Test_Repository | |
* | |
* @method _Test_|null find($id, $lockMode = null, $lockVersion = null) | |
* @method _Test_|null findOneBy(array $criteria, array $orderBy = null) | |
* @method _Test_[] findAll() | |
* @method _Test_[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |
*/ | |
class _Test_Repository extends ServiceEntityRepository | |
{ | |
/** | |
* _Test_Repository constructor. | |
* | |
* @param RegistryInterface $registry | |
*/ | |
public function __construct(RegistryInterface $registry) | |
{ | |
parent::__construct($registry, _Test_::class); | |
} | |
} |
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 | |
$files = scandir(__DIR__.'/Entity'); | |
$template = file_get_contents(__DIR__.'/_Test_Repository.php'); | |
foreach ($files as $file) { | |
if (!strpos($file, '.php')) { | |
continue; | |
} | |
$class = strstr($file, '.php', true); | |
$file =__DIR__.'/Repository/'.$class.'Repository.php'; | |
file_put_contents($file, str_replace('_Test_', $class, $template)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment