Skip to content

Commit

Permalink
Add the getNewQueryBuilder and the getQueryBuilderResult functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Beaujean committed Mar 20, 2015
1 parent e1eb469 commit 7bb17ac
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Generator/RepositoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ public function generateFiles($directory)
$tableNames = $description['tableNames'];

foreach ($tableNames as $tableIndex => $tableName) {
$renderedTemplate = $twig->render($this->topRepositoryTemple, array('tableName' => $tableName, 'bundleName' => $bundleName));
$entityDql = lcfirst($tableName);

$renderedTemplate = $twig->render($this->topRepositoryTemple, array('tableName' => $tableName, 'bundleName' => $bundleName, 'entityDql' => $entityDql));

//parse the columns
foreach ($fieldNames[$tableIndex] as $columnName) {
$parameters = array(
'entity' => $tableName,
'entityDql' => lcfirst($tableName),
'entityDql' => $entityDql,
'column' => ucfirst($columnName),
'columnDql' => $columnName
);
Expand Down
28 changes: 28 additions & 0 deletions Resources/views/Generator/TopRepositoryTemplate.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,31 @@ class {{ tableName }}Repository extends EntityRepository
return self::$parameterIndex;
}
/**
* Get a new query builder
*
* @return integer The index
*/
public function getNewQueryBuilder()
{
$qb = $this->createQueryBuilder('{{ entityDql }}');
return $qb;
}
/**
* Get the result of the query builder
*
* @return unknown The results
*/
public static function getQueryBuilderResult(QueryBuilder $qb)
{
$query = $qb->getQuery();
$results = $query->getResult();
return $results;
}

0 comments on commit 7bb17ac

Please sign in to comment.