Neos\Fusion\Core\Parser::setObjectTypeNamespace PHP Метод

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

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"
Результат void
    public function setObjectTypeNamespace($alias, $namespace)
    {
        if (!is_string($alias)) {
            throw new Fusion\Exception('The alias of a namespace must be valid string!', 1180600696);
        }
        if (!is_string($namespace)) {
            throw new Fusion\Exception('The namespace must be of type string!', 1180600697);
        }
        $this->objectTypeNamespaces[$alias] = $namespace;
    }

Usage Example

 /**
  * @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');
 }
All Usage Examples Of Neos\Fusion\Core\Parser::setObjectTypeNamespace