Skip to content

Instantly share code, notes, and snippets.

@avtehnik
Created November 21, 2016 17:28
Show Gist options
  • Save avtehnik/4400484757f4e0faac96c4101405b497 to your computer and use it in GitHub Desktop.
Save avtehnik/4400484757f4e0faac96c4101405b497 to your computer and use it in GitHub Desktop.
<?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