Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by e-spin Berlin.
- *
- * (c) 2019
- *
- * @author Ingolf Steinhardt <info@e-spin.de>
- * @copyright 2019 Ingolf Steinhardt <info@e-spin.de>
- * @license Commercial
- * @filesource
- */
- namespace AppBundle\Helper;
- use MetaModels\Filter\Rules\SimpleQuery;
- use MetaModels\FilterPerimetersearchBundle\FilterRules\Perimetersearch;
- class MmTemplateHelper
- {
- /**
- * @param $id
- *
- * @return mixed
- */
- public function getEventDataById($id)
- {
- // Get MetaModel and retrieve item.
- $modelName = 'mm_events';
- $container = $GLOBALS['container']['metamodels-service-container'];
- $factory = $container->getFactory();
- $model = $factory->getMetaModel($modelName);
- $filter = $model->getEmptyFilter();
- $query = sprintf('SELECT id FROM %s WHERE id = %s', $modelName, $id);
- $filter->addFilterRule(new SimpleQuery($query));
- $items = $model->findByFilter($filter);
- return $items->parseAll('text')[0];
- }
- /**
- * @param $arrCategories
- *
- * @return string
- */
- function getCategoryIcons($arrCategories)
- {
- $icons = [];
- foreach ($arrCategories as $arrCategory) {
- if ($arrCategory['__TAGS_RAW__']['symbol_image']['path']) {
- $icons[] = $arrCategory['__TAGS_RAW__']['symbol_image']['path'];
- }
- }
- return implode(', ', $icons);
- }
- /**
- * @param $address
- *
- * @return array
- */
- function getPoisByAddress($address) {
- if (!$address) {
- return [];
- }
- // Get MetaModel and retrieve item.
- $modelName = 'mm_pois';
- $filterId = 5;
- $filterUrl = ['adresse' => $address];
- $container = $GLOBALS['container']['metamodels-service-container'];
- $factory = $container->getFactory();
- $model = $factory->getMetaModel($modelName);
- $filter = $model->prepareFilter($filterId, $filterUrl);
- $items = $model->findByFilter($filter,'geodistance');
- return $items->parseAll('text');
- }
- function getPoisByGeoCoordinates($geoLat, $geoLong, $distance) {
- if (!$geoLat || !$geoLong) {
- return [];
- }
- // Get MetaModel and retrieve item.
- $modelName = 'mm_pois';
- $latName = 'geo_lat';
- $longName = 'geo_long';
- $container = $GLOBALS['container']['metamodels-service-container'];
- $factory = $container->getFactory();
- $model = $factory->getMetaModel($modelName);
- $attrLat = $model->getAttribute($latName);
- $attrLong = $model->getAttribute($longName);
- $filter = $model->getEmptyFilter();
- $filter->addFilterRule(new Perimetersearch($attrLat, $attrLong, null, $geoLat, $geoLong, $distance));
- $items = $model->findByFilter($filter,'geodistance');
- return $items->parseAll('text');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement