src/Twig/BlockTitleExtension.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use Twig\Extension\AbstractExtension;
  4. use Twig\TwigFilter;
  5. class BlockTitleExtension extends AbstractExtension
  6. {
  7.     public function getFilters(): array
  8.     {
  9.         return [
  10.             new TwigFilter('block_title', [$this'blocktag']),
  11.         ];
  12.     }
  13.     public function blocktag($url$op  'sec'): String
  14.     {
  15.         $url explode('**'$url);
  16.         $text '';
  17.         if( $op == 'sec' ){
  18.             foreach ($url as $i => $v) {
  19.             if( $i == 0){
  20.                 $text .= $v;
  21.             }else{
  22.                 $text .= "<strong>{$v}</strong>";
  23.             }
  24.             }
  25.         }else{
  26.             foreach ($url as $i => $v) {
  27.             if( $i == 0){
  28.                 $text .= "<strong>{$v}</strong>";
  29.             }else{
  30.                 $text .= $v;
  31.             }
  32.             }
  33.         }
  34.         return $text;
  35.     }
  36. }