Last active
December 20, 2016 08:22
-
-
Save janit/4323845afd737fafcdead846a17f7b56 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* @Route("/test",name="testroute") | |
* @Template | |
*/ | |
public function testAction(Request $request, Checkout $checkout) | |
{ | |
$repository = $this->get('ezpublish.api.repository'); | |
$contentService = $repository->getContentService(); | |
$locationService = $repository->getLocationService(); | |
$searchService = $repository->getSearchService(); | |
$vars = []; | |
$vars['random'] = rand(1,20000); | |
$vars['location'] = $locationService->loadLocation(55); | |
$vars['content1'] = $contentService->loadContent(84); | |
$vars['content2'] = $contentService->loadContent(1235); | |
$query = new LocationQuery(); | |
$query->filter = new Criterion\LogicalAnd([ | |
new Criterion\Subtree($vars['location']->pathString), | |
new Criterion\ContentTypeIdentifier( 'feature' ) | |
]); | |
$results = $searchService->findLocations($query); | |
$vars['results'] = $results; | |
return $vars; | |
} |
This file contains 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
{{ ez_render_field(content1,'name') }} -- {{ ez_render_field(content2,'name') }} | |
<ul> | |
{% for hit in results.searchHits %} | |
<li><a href="{{ path(hit.valueObject) }}">{{ hit.valueObject.ContentInfo.name }}</a></li> | |
{% endfor %} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment