Commit 32a81f09 authored by Jonathan H. Wage's avatar Jonathan H. Wage

Fixing generate-repositories command so it works again after migration to Symfony console

parent 146b22a1
......@@ -40,12 +40,12 @@ use Symfony\Components\Console\Input\InputArgument,
*/
class GenerateRepositoriesCommand extends Console\Command\Command
{
private static $_template =
protected static $_template =
'<?php
namespace <namespace>;
use \Doctrine\ORM\EntityRepository;
use Doctrine\ORM\EntityRepository;
/**
* <className>
......@@ -103,7 +103,7 @@ EOT
);
}
if ( count($metadatas)) {
if (count($metadatas)) {
$numRepositories = 0;
foreach ($metadatas as $metadata) {
......@@ -112,7 +112,7 @@ EOT
sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName) . PHP_EOL
);
$this->_generateRepositoryClass($metadata, $destPath);
$this->_writeRepositoryClass($metadata, $destPath);
$numRepositories++;
}
......@@ -129,9 +129,23 @@ EOT
}
}
private function _generateRepositoryClass($metadata, $destPath)
protected function _generateRepositoryClass($metadata)
{
$code = $this->_generateRepositoryClass($metadata->customRepositoryClassName);
fullClassName = $metadata->customRepositoryClassName;
$namespace = substr($fullClassName, 0, strrpos($fullClassName, '\\'));
$className = substr($fullClassName, strrpos($fullClassName, '\\') + 1, strlen($fullClassName));
$variables = array(
'<namespace>' => $namespace,
'<className>' => $className
);
$code = str_replace(array_keys($variables), array_values($variables), self::$_template);
return $code;
}
protected function _writeRepositoryClass($metadata, $destPath)
{
$code = $this->_generateRepositoryClass($metadata);
$path = $destPath . DIRECTORY_SEPARATOR
. str_replace('\\', \DIRECTORY_SEPARATOR, $metadata->customRepositoryClassName) . '.php';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment