コード例 #1
0
 public function testGetSet()
 {
     $uriContext = new UriContext($this->subjectObject, '/uri/', array('default1' => 'value1'), array('token'), array('conflict'), 'fr');
     // locales
     $this->assertEquals('fr', $uriContext->getLocale());
     /// uri
     $this->assertEquals(null, $uriContext->getUri());
     $uriContext->setUri('/foo/bar');
     $this->assertEquals('/foo/bar', $uriContext->getUri());
     // subject object
     $this->assertEquals($this->subjectObject, $uriContext->getSubjectObject());
     // auto route
     $uriContext->setAutoRoute($this->autoRoute);
     $this->assertEquals($this->autoRoute, $uriContext->getAutoRoute());
     // the translated subject should be initially set as the original subject
     $this->assertSame($this->subjectObject, $uriContext->getTranslatedSubjectObject());
     $transSubject = new \stdClass();
     $uriContext->setTranslatedSubjectObject($transSubject);
     $this->assertSame($transSubject, $uriContext->getTranslatedSubjectObject());
     // uri schema
     $this->assertEquals('/uri/', $uriContext->getUriSchema());
     // token provider configs
     $this->assertEquals(array('token'), $uriContext->getTokenProviderConfigs());
     // conflict resolver configs
     $this->assertEquals(array('conflict'), $uriContext->getConflictResolverConfig());
     // defaults
     $this->assertEquals(array('default1' => 'value1'), $uriContext->getDefaults());
 }
コード例 #2
0
 public function testGetSet()
 {
     $uriContext = new UriContext($this->subjectObject, 'fr');
     // locales
     $this->assertEquals('fr', $uriContext->getLocale());
     /// uri
     $this->assertEquals(null, $uriContext->getUri());
     $uriContext->setUri('/foo/bar');
     $this->assertEquals('/foo/bar', $uriContext->getUri());
     // subject object
     $this->assertEquals($this->subjectObject, $uriContext->getSubjectObject());
     // auto route
     $uriContext->setAutoRoute($this->autoRoute);
     $this->assertEquals($this->autoRoute, $uriContext->getAutoRoute());
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  */
 public function provideValue(UriContext $uriContext, $options)
 {
     return $uriContext->getLocale();
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function generateAutoRouteTag(UriContext $uriContext)
 {
     return $uriContext->getLocale() ?: self::TAG_NO_MULTILANG;
 }