Neos\Flow\I18n\Xliff\XliffModel::initializeObject PHP Метод

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

When it's called, XML file is parsed (using parser set in $xmlParser) or cache is loaded, if available.
public initializeObject ( ) : void
Результат void
    public function initializeObject()
    {
        if ($this->cache->has(md5($this->sourcePath))) {
            $this->xmlParsedData = $this->cache->get(md5($this->sourcePath));
        } else {
            $this->xmlParsedData = $this->xmlParser->getParsedData($this->sourcePath);
            $this->cache->set(md5($this->sourcePath), $this->xmlParsedData);
        }
    }

Usage Example

 /**
  * @test
  */
 public function getTargetBySourceLogsSilentlyIfNoTransUnitsArePresent()
 {
     $this->mockXliffParser = $this->createMock(I18n\Xliff\XliffParser::class);
     $this->mockXliffParser->expects($this->once())->method('getParsedData')->will($this->returnValue([]));
     $mockLogger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock();
     $mockLogger->expects($this->once())->method('log')->with($this->stringStartsWith('No trans-unit elements were found'), LOG_DEBUG);
     $this->model->injectParser($this->mockXliffParser);
     $this->inject($this->model, 'i18nLogger', $mockLogger);
     $this->model->initializeObject();
     $this->model->getTargetBySource('foo');
 }