Frontend\Modules\Location\Engine\Model::getPathToMapStyles PHP Method

getPathToMapStyles() public static method

Get path to map styles
public static getPathToMapStyles ( boolean $backend = true ) : string
$backend boolean
return string
    public static function getPathToMapStyles($backend = true)
    {
        $path = 'src/Frontend';
        $jsFile = 'Location/Js/LocationMapStyles.js';
        $moveToPath = '../../../../..';
        // User can override the map styles in the frontend
        if (file_exists($path . '/Themes/' . FrontendTheme::getTheme() . '/Modules/' . $jsFile)) {
            if ($backend) {
                return $moveToPath . '/' . $path . '/Themes/' . FrontendTheme::getTheme() . '/Modules/' . $jsFile;
            }
            return '/' . $path . '/Themes/' . FrontendTheme::getTheme() . '/Modules/' . $jsFile;
        }
        if ($backend) {
            return $moveToPath . '/' . $path . '/Modules/' . $jsFile;
        }
        return '/' . $path . '/Modules/' . $jsFile;
    }

Usage Example

Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exists
     if ($this->id !== null && BackendLocationModel::exists($this->id)) {
         $this->header->addJS(FrontendLocationModel::getPathToMapStyles());
         parent::execute();
         // define Google Maps API key
         $apikey = $this->get('fork.settings')->get('Core', 'google_maps_key');
         // check Google Maps API key, otherwise redirect to settings
         if ($apikey === null) {
             $this->redirect(BackendModel::createURLForAction('Index', 'Settings'));
         }
         // add js
         $this->header->addJS('https://maps.googleapis.com/maps/api/js?key=' . $apikey, null, false, true, false);
         $this->loadData();
         $this->loadForm();
         $this->validateForm();
         $this->loadSettingsForm();
         $this->parse();
         $this->display();
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
All Usage Examples Of Frontend\Modules\Location\Engine\Model::getPathToMapStyles