Inheritance: extends eZ\Publish\API\Repository\Values\ValueObject
Esempio n. 1
0
 public function reverseMatch($siteAccessName)
 {
     $hostElements = explode('.', $this->request->host);
     $elementNumber = $this->elementNumber - 1;
     if (!isset($hostElements[$elementNumber])) {
         return null;
     }
     $hostElements[$elementNumber] = $siteAccessName;
     $this->request->setHost(implode('.', $hostElements));
     return $this;
 }
 public function testAnalyseLink()
 {
     $siteAccessURI = '/footestbar';
     $semanticURI = '/something/hoho';
     $matcher = new URITextMatcher(array('prefix' => 'foo', 'suffix' => 'bar'));
     $matcher->setRequest(SimplifiedRequest::fromUrl('http://phoenix-rises.fm/footestbar/blabla'));
     $this->assertSame($siteAccessURI . $semanticURI, $matcher->analyseLink($semanticURI));
 }
 public function testAnalyseLink()
 {
     $siteAccessURI = "/footestbar";
     $semanticURI = "/something/hoho";
     $matcher = new URITextMatcher(array("prefix" => "foo", "suffix" => "bar"));
     $matcher->setRequest(SimplifiedRequest::fromUrl("http://phoenix-rises.fm/footestbar/blabla"));
     $this->assertSame($siteAccessURI . $semanticURI, $matcher->analyseLink($semanticURI));
 }
Esempio n. 4
0
 /**
  * Returns matcher object corresponding to $siteAccessName or null if non applicable.
  *
  * Limitation: If the element number is > 1, we cannot predict how URI segments are expected to be built.
  * So we expect "_" will be reversed to "/"
  * e.g. foo_bar => foo/bar with elementNumber == 2
  * Hence if number of elements is different than the element number, we report as non matched.
  *
  * @param string $siteAccessName
  *
  * @return \eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement|null
  */
 public function reverseMatch($siteAccessName)
 {
     $elements = $this->elementNumber > 1 ? explode('_', $siteAccessName) : array($siteAccessName);
     if (count($elements) !== $this->elementNumber) {
         return null;
     }
     $pathinfo = '/' . implode('/', $elements) . '/' . ltrim($this->request->pathinfo, '/');
     $this->request->setPathinfo($pathinfo);
     return $this;
 }
 public function matchProvider()
 {
     return array(array(SimplifiedRequest::fromUrl('http://example.com'), 'default_sa'), array(SimplifiedRequest::fromUrl('https://example.com'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com/'), 'default_sa'), array(SimplifiedRequest::fromUrl('https://example.com/'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com//'), 'default_sa'), array(SimplifiedRequest::fromUrl('https://example.com//'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com:8080/'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com/first_siteaccess/'), 'first_siteaccess'), array(SimplifiedRequest::fromUrl('http://example.com/?first_siteaccess'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com/?first_sa'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com/first_salt'), 'first_salt'), array(SimplifiedRequest::fromUrl('http://example.com/first_sa.foo'), 'first_sa.foo'), array(SimplifiedRequest::fromUrl('http://example.com/test'), 'test'), array(SimplifiedRequest::fromUrl('http://example.com/test/foo/'), 'test'), array(SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/'), 'test'), array(SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/first_sa'), 'test'), array(SimplifiedRequest::fromUrl('http://example.com/default_sa'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com/first_sa'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://example.com/first_sa/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://example.com//first_sa//'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com///first_sa///test'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com//first_sa//foo/bar'), 'default_sa'), array(SimplifiedRequest::fromUrl('http://example.com/first_sa/foo'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://example.com:82/first_sa/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://third_siteaccess/first_sa/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://first_sa/'), 'first_sa'), array(SimplifiedRequest::fromUrl('https://first_sa/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://first_sa:81/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://first_siteaccess/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://first_siteaccess:82/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://first_siteaccess:83/'), 'first_sa'), array(SimplifiedRequest::fromUrl('http://first_siteaccess/foo/'), 'foo'), array(SimplifiedRequest::fromUrl('http://first_siteaccess:82/foo/'), 'foo'), array(SimplifiedRequest::fromUrl('http://first_siteaccess:83/foo/'), 'foo'), array(SimplifiedRequest::fromUrl('http://example.com/second_sa'), 'second_sa'), array(SimplifiedRequest::fromUrl('http://example.com/second_sa/'), 'second_sa'), array(SimplifiedRequest::fromUrl('http://example.com/second_sa?param1=foo'), 'second_sa'), array(SimplifiedRequest::fromUrl('http://example.com/second_sa/foo/'), 'second_sa'), array(SimplifiedRequest::fromUrl('http://example.com:82/second_sa/'), 'second_sa'), array(SimplifiedRequest::fromUrl('http://example.com:83/second_sa/'), 'second_sa'), array(SimplifiedRequest::fromUrl('http://first_siteaccess:82/second_sa/'), 'second_sa'), array(SimplifiedRequest::fromUrl('http://first_siteaccess:83/second_sa/'), 'second_sa'));
 }
 public function matchProvider()
 {
     return array(array(SimplifiedRequest::fromUrl('http://fr.ezpublish.dev/eng'), 'fr_eng'), array(SimplifiedRequest::fromUrl('http://ezpublish.dev/eng'), 'fr_eng'), array(SimplifiedRequest::fromUrl('http://fr.ezpublish.dev/fre'), 'fr_eng'), array(SimplifiedRequest::fromUrl('http://fr.ezpublish.dev/'), 'fr_eng'), array(SimplifiedRequest::fromUrl('http://us.ezpublish.dev/eng'), 'fr_eng'), array(SimplifiedRequest::fromUrl('http://us.ezpublish.dev/foo'), false), array(SimplifiedRequest::fromUrl('http://us.ezpublish.dev/fre'), 'fr_jp'), array(SimplifiedRequest::fromUrl('http://jp.ezpublish.dev/foo'), 'fr_jp'), array(SimplifiedRequest::fromUrl('http://ezpublish.dev/fr'), false));
 }
 public function matchProvider()
 {
     return array(array(SimplifiedRequest::fromUrl("http://example.com"), "default_sa"), array(SimplifiedRequest::fromUrl("https://example.com"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/"), "default_sa"), array(SimplifiedRequest::fromUrl("https://example.com/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com//"), "default_sa"), array(SimplifiedRequest::fromUrl("https://example.com//"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com:8080/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_siteaccess/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/?first_siteaccess"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/?first_sa"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_salt"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa.foo"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test/foo/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test/foo/bar/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test/foo/bar/first_sa"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/default_sa"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa//"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com//first_sa//"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa///test"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa/foo"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa/foo/bar"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com:82/first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://third_siteaccess/first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("https://first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_sa:81/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:82/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:83/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess/foo/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:82/foo/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:83/foo/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa?param1=foo"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa/foo/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com:82/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com:83/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:82/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:83/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com:81/"), "third_sa"), array(SimplifiedRequest::fromUrl("https://example.com:81/"), "third_sa"), array(SimplifiedRequest::fromUrl("http://example.com:81/foo"), "third_sa"), array(SimplifiedRequest::fromUrl("http://example.com:81/foo/bar"), "third_sa"), array(SimplifiedRequest::fromUrl("http://example.com:82/"), "fourth_sa"), array(SimplifiedRequest::fromUrl("https://example.com:82/"), "fourth_sa"), array(SimplifiedRequest::fromUrl("https://example.com:82/foo"), "fourth_sa"), array(SimplifiedRequest::fromUrl('http://fr.ezpublish.dev/eng'), 'fr_eng'), array(SimplifiedRequest::fromUrl('http://us.ezpublish.dev/fre'), 'fr_us'));
 }
 /**
  * @param string $url
  * @param \eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest $expectedRequest
  *
  * @dataProvider fromUrlProvider
  * @covers \eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest::fromUrl
  */
 public function testFromUrl($url, $expectedRequest)
 {
     self::assertEquals($expectedRequest, SimplifiedRequest::fromUrl($url));
 }
 public function matchProvider()
 {
     return array(array(SimplifiedRequest::fromUrl("http://example.com"), "default_sa"), array(SimplifiedRequest::fromUrl("https://example.com"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/"), "default_sa"), array(SimplifiedRequest::fromUrl("https://example.com/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com//"), "default_sa"), array(SimplifiedRequest::fromUrl("https://example.com//"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com:8080/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_siteaccess/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/?first_siteaccess"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/?first_sa"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_salt"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa.foo"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test/foo/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test/foo/bar/"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/test/foo/bar/first_sa"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/default_sa"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com//first_sa//"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com///first_sa///test"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com//first_sa//foo/bar"), "default_sa"), array(SimplifiedRequest::fromUrl("http://example.com/first_sa/foo"), "first_sa"), array(SimplifiedRequest::fromUrl("http://example.com:82/first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://third_siteaccess/first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("https://first_sa/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_sa:81/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:82/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:83/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess/foo/"), "first_sa"), array(SimplifiedRequest::fromUrl("http://www.example.com/"), "example"), array(SimplifiedRequest::fromUrl("https://www.example.com/"), "example"), array(SimplifiedRequest::fromUrl("http://www.example.com:81/"), "example"), array(SimplifiedRequest::fromUrl("http://www.example.com/"), "example"), array(SimplifiedRequest::fromUrl("http://www.example.com:82/"), "example"), array(SimplifiedRequest::fromUrl("https://www.example.com:83/"), "example"), array(SimplifiedRequest::fromUrl("http://www.example.com/foo/"), "example"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa?param1=foo"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com/second_sa/foo/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com:82/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://example.com:83/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:82/second_sa/"), "second_sa"), array(SimplifiedRequest::fromUrl("http://first_siteaccess:83/second_sa/"), "second_sa"));
 }
Esempio n. 10
0
    public function matchProvider()
    {
        return array(
            array( SimplifiedRequest::fromUrl( "http://example.com" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "https://example.com" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "https://example.com/" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com//" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "https://example.com//" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com:8080/" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/first_siteaccess/" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/?first_siteaccess" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/?first_sa" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/first_salt" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/first_sa.foo" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/test" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/test/foo/" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/test/foo/bar/" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/test/foo/bar/first_sa" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/default_sa" ), "default_sa" ),

            array( SimplifiedRequest::fromUrl( "http://example.com/first_sa" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/first_sa/" ), "first_sa" ),
            // Double slashes shouldn't be considered as one
            array( SimplifiedRequest::fromUrl( "http://example.com//first_sa//" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com///first_sa///test" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com//first_sa//foo/bar" ), "default_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/first_sa/foo" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com:82/first_sa/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://third_siteaccess/first_sa/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_sa/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "https://first_sa/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_sa:81/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:82/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:83/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess/foo/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:82/foo/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:83/foo/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess/foobar/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess//foobar/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess//footestbar/" ), "first_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess/footestbar/" ), "test" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess/footestbar/foobazbar/" ), "test" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:82/footestbar/" ), "test" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:83/footestbar/" ), "test" ),

            array( SimplifiedRequest::fromUrl( "http://example.com/second_sa" ), "second_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/second_sa/" ), "second_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/second_sa?param1=foo" ), "second_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com/second_sa/foo/" ), "second_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com:82/second_sa/" ), "second_sa" ),
            array( SimplifiedRequest::fromUrl( "http://example.com:83/second_sa/" ), "second_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:82/second_sa/" ), "second_sa" ),
            array( SimplifiedRequest::fromUrl( "http://first_siteaccess:83/second_sa/" ), "second_sa" ),
        );
    }
 public function reverseMatchProvider()
 {
     return array(array('foo', 1, SimplifiedRequest::fromUrl('http://bar.example.com/'), 'foo.example.com'), array('ezdemo_site', 1, SimplifiedRequest::fromUrl('http://ezflow_site.ez.no/'), 'ezdemo_site.ez.no'), array('metalfrance', 2, SimplifiedRequest::fromUrl('http://www.lolart.net/'), 'www.metalfrance.net'), array('fm', 3, SimplifiedRequest::fromUrl('http://www.phoenix-rises.fr/'), 'www.phoenix-rises.fm'));
 }