Example #1
0
 /**
  * @param $blockHtml
  * @return mixed
  */
 public function replaceLinkTags($blockHtml)
 {
     $callback = function ($matches) {
         $id = trim(trim($matches[1], '"'), "'");
         if (is_numeric($id)) {
             $menuItemTranslation = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItemTranslation')->findOneById($id);
             if ($menuItemTranslation) {
                 return ' href="' . $this->route->buildFullUrl($menuItemTranslation->menuItem, true) . '"';
             }
         }
         return $matches[0];
     };
     return preg_replace_callback('#\\s*(?i)href\\s*=\\s*(\\"([^"]*\\")|\'[^\']*\'|([^\'">\\s]+))#si', $callback, $blockHtml);
 }