tad\WPBrowser\Module\Support\UriToIndexMapper::getIndexForUri PHP Метод

getIndexForUri() публичный Метод

public getIndexForUri ( $uri )
    public function getIndexForUri($uri)
    {
        preg_match('~\\/?(.*?\\.php)~', $uri, $matches);
        if (!empty($matches[1])) {
            $uri = '/' . $matches[1];
        }
        if (file_exists($this->root . $uri) && !is_dir($this->root . $uri)) {
            return $this->root . $uri;
        }
        $uri = '/' . trim($uri, '/');
        $indexFile = isset($this->map[$uri]) ? $this->map[$uri] : '/index.php';
        return $this->root . $indexFile;
    }

Usage Example

Пример #1
0
 /**
  * @test
  * it should set index with uri to index map when setting index for uri
  */
 public function it_should_set_index_with_uri_to_index_map_when_setting_index_for_uri()
 {
     $uri = '/foo';
     $this->uriToIndexMapper->setRoot($this->root->url())->shouldBeCalled();
     $this->uriToIndexMapper->getIndexForUri($uri)->willReturn('/some-index.php');
     $sut = $this->make_instance();
     $sut->setRootFolder($this->root->url());
     $sut->setIndexFor($uri);
     $this->assertEquals($this->root->url() . '/some-index.php', $sut->getIndex());
 }
All Usage Examples Of tad\WPBrowser\Module\Support\UriToIndexMapper::getIndexForUri