AppserverIo\Appserver\Core\Api\AppService::getExtractor PHP Method

getExtractor() public method

Getter for this service's extractor
public getExtractor ( ) : AppserverIo\Appserver\Core\Interfaces\ExtractorInterface | null
return AppserverIo\Appserver\Core\Interfaces\ExtractorInterface | null
    public function getExtractor()
    {
        // we will have a phar extractor by default
        if (!isset($this->extractor)) {
            $configuration = $this->getSystemConfiguration()->getExtractors();
            if (isset($configuration[self::DEFAULT_EXTRACTOR_NAME])) {
                // create a new extractor with the default configuration
                $this->extractor = new PharExtractor($this->getInitialContext(), $configuration[self::DEFAULT_EXTRACTOR_NAME]);
            } else {
                $this->getInitialContext()->getSystemLogger()->warning(sprintf('Did not find configuration for default extractor %s nor was an extractor injected.', self::DEFAULT_EXTRACTOR_NAME));
                $this->extractor = null;
            }
        }
        return $this->extractor;
    }

Usage Example

Example #1
0
 /**
  * Tests if we are able to inject our extractor
  *
  * @return null
  */
 public function testInjectExtractor()
 {
     $this->appService->injectExtractor($this->getMock('\\AppserverIo\\Appserver\\Core\\Interfaces\\ExtractorInterface'));
     $this->assertInstanceOf('\\PHPUnit_Framework_MockObject_MockObject', $this->appService->getExtractor());
 }