Skip to content

Commit

Permalink
Fixed a minor error and added one test
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Jul 19, 2015
1 parent 7ed6b74 commit 55db338
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/EasyAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ private function processEntityTemplates(array $backendConfiguration)
}

// 1st level priority: app/Resources/views/easy_admin/<entityName>/<templateName>.html.twig
if (file_exists($applicationTemplatesDir.'/easy_admin/'.$entityName.'/'.$templateName.'.html.twig')) {
if (file_exists($templatesDir.'/easy_admin/'.$entityName.'/'.$templateName.'.html.twig')) {
$templatePath = 'easy_admin/'.$entityName.'/'.$templateName.'.html.twig';
// 2nd level priority: app/Resources/views/easy_admin/<templateName>.html.twig
} elseif (file_exists($applicationTemplatesDir.'/easy_admin/'.$templateName.'.html.twig')) {
} elseif (file_exists($templatesDir.'/easy_admin/'.$templateName.'.html.twig')) {
$templatePath = 'easy_admin/'.$templateName.'.html.twig';
} else {
throw new \RuntimeException(sprintf('The "%s" field of the "%s" entity uses a custom template called "%s" which doesn\'t exist in "app/resources/views/easy_admin/" directory.', $fieldName, $entityName, $templateName));
Expand Down
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/EasyAdminExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ public function testOverriddenTemplateNamesAreLimited()
$this->parseConfigurationFile(__DIR__.'/fixtures/exceptions/overridden_template_names_are_limited.yml');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage The "id" field of the "TestEntity" entity uses a custom template called "this_template_does_not_exist" which doesn't exist in "app/resources/views/easy_admin/" directory.
*/
public function testCustomFieldTemplateDoesNotExist()
{
$this->parseConfigurationFile(__DIR__.'/fixtures/exceptions/custom_field_template_does_not_exist.yml');
}

/**
* Tests the template overriding mechanism when a given entity defines
* its own custom templates in app/Resources/views/easy_admin/<entityName>/<templateName>.html.twig files
Expand Down

0 comments on commit 55db338

Please sign in to comment.