Created
November 21, 2016 17:28
-
-
Save avtehnik/4400484757f4e0faac96c4101405b497 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
require_once 'vendor/autoload.php'; | |
$files = scandir(__DIR__ . '/src/AppBundle/Entity/'); | |
foreach ($files as $file) { | |
if (is_file(__DIR__ . '/src/AppBundle/Entity/' . $file)) { | |
require_once __DIR__ . '/src/AppBundle/Entity/' . $file; | |
} | |
} | |
CONST SPACE = ' '; | |
foreach (get_declared_classes() as $name) { | |
if (strpos($name, 'AppBundle\Entity') === 0) { | |
$class = new \ReflectionClass($name); | |
$class->getProperties(); | |
$lines = []; | |
$lines[] = $class->getName() . ':'; | |
$lines[] = SPACE . $class->getShortName() . '{1..2}:'; | |
foreach($class->getProperties() as $property){ | |
$lines[] = SPACE . SPACE . $property->name . ': stest'; | |
} | |
$filename = __DIR__ . '/src/AppBundle/DataFixtures/ORM/Fixtures/' . $class->getShortName() . '.yml'; | |
echo $filename . PHP_EOL; | |
if(!file_exists($filename)){ | |
file_put_contents($filename, implode("\n", $lines)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment