setObjectTypeNamespace() public method

The namespaces defined through this setter or through a "namespace" declaration in one of the TypoScripts are used to resolve a fully qualified TypoScript object name while parsing TypoScript code. The alias is the handle by wich the namespace can be referred to. The namespace is, by convention, a package key which must correspond to a namespace used in the prototype definitions for TypoScript object types. The special alias "default" is used as a fallback for resolution of unqualified TypoScript object types.
public setObjectTypeNamespace ( string $alias, string $namespace ) : void
$alias string An alias for the given namespace, for example "neos"
$namespace string The namespace, for example "Neos.Neos"
return void
コード例 #1
0
 /**
  * @test
  */
 public function parserCorrectlyParsesFixture17()
 {
     $fixture = __DIR__ . '/Fixtures/ParserTestTypoScriptFixture17.fusion';
     $sourceCode = file_get_contents($fixture, FILE_TEXT);
     $expectedParseTree = $this->getExpectedParseTreeForFixture16();
     // Check that values were overridden by fixture #17:
     $expectedParseTree['__prototypes']['TYPO3.Foo:Bar2']['baz'] = 'New Value';
     // Set the default namespace to Neos.Neos - that's what Neos does as well in Domain\Service\TypoScriptService:
     $this->parser->setObjectTypeNamespace('default', 'Neos.Neos');
     $text = array('__objectType' => 'Neos.Neos:Text', '__value' => null, '__eelExpression' => null);
     // Make sure that the namespace declaration for "default" is also available when fixture #17b is parsed:
     $expectedParseTree['object'] = $text;
     // Test normal globbing
     $expectedParseTree['globbing1'] = $text;
     $expectedParseTree['globbing2'] = $text;
     // Test recursive globbing
     $expectedParseTree['recursiveGlobbing1'] = $text;
     $expectedParseTree['recursiveGlobbing2'] = $text;
     $expectedParseTree['recursiveGlobbingUpTheTree'] = $text;
     // Test globbing with dots
     $expectedParseTree['globbingWithDots1'] = $text;
     $actualParseTree = $this->parser->parse($sourceCode, $fixture);
     $this->assertEquals($expectedParseTree, $actualParseTree, 'The parse tree was not as expected after parsing fixture 17');
 }
コード例 #2
0
ファイル: TypoScriptService.php プロジェクト: neos/neos
 /**
  * Initializes the parser
  *
  * @return void
  */
 public function initializeObject()
 {
     $this->typoScriptParser->setObjectTypeNamespace('default', 'Neos.Neos');
 }