Exemple #1
0
 static function getInstance()
 {
     if (!isset(self::$instance)) {
         if (class_exists('RedCat\\Strategy\\Di')) {
             self::$instance = \RedCat\Strategy\Di::getInstance()->get(__CLASS__);
         } else {
             self::$instance = new self();
         }
     }
     return self::$instance;
 }
Exemple #2
0
 function load()
 {
     $this->remapAttr('domains');
     $this->attr('domains', eval('return ' . $this->domains . ';'));
     if ($this->attr('no-cache')) {
         $href = "<?php echo \\RedCat\\Strategy\\Di::getInstance()->get('RedCat\\Route\\Url')->getCanonical(" . var_export($this->attr('domains'), true) . ',' . ($this->attr('http-substitution') ? 'true' : 'false') . ',' . ($this->attr('static') ? 'true' : 'false') . ');?>';
     } else {
         $url = Di::getInstance()->get('RedCat\\Route\\Url');
         $canonical = $url->getCanonical($this->attr('domains'), !!$this->attr('http-substitution'), $this->attr('static'));
         $canonical2 = $url->getCanonical($this->attr('domains'), '%s', $this->attr('static'));
         if ($this->attr('http-substitution')) {
             $href = '<?php echo http_response_code()===200?' . var_export($canonical, true) . ':sprintf(' . var_export($canonical2, true) . ',http_response_code());?>';
         } else {
             $href = $canonical;
         }
     }
     $this->write('<link rel="canonical" href="' . $href . '">');
 }