public function getValidPortableElementFromDirectorySource($directory)
    {
        $parserMatched = null;
        $parsers = $this->getDirectoryParsers();
        /** @var PortableElementDirectoryParser $parser */
        foreach ($parsers as $parser) {
            if ($parser->hasValidPortableElement($directory)) {
                $parserMatched = $parser;
            }
        }

        if (is_null($parserMatched)) {
            throw new PortableElementParserException(
                'This zip source is not compatible with any portable element. Manifest and/or engine file are missing '
                . ' or related extensions are not installed.'
            );
        }

        $source = $parserMatched->extract($directory);
        $object = $parserMatched->getModel()->createDataObject($parserMatched->getManifestContent($directory));

        // Validate Portable Element  Model
        try {
            $this->validate($object, $source);
        } catch (PortableElementInvalidModelException $e) {
            \common_Logger::w($e->getMessage());
            return null;
        }

        return $object;
    }
public function getValidPortableElementFromDirectorySource($directory)
    {
        $parserMatched = null;
        $parsers = $this->getDirectoryParsers();
        /** @var PortableElementDirectoryParser $parser */
        foreach ($parsers as $parser) {
            if ($parser->hasValidPortableElement($directory)) {
                $parserMatched = $parser;
            }
        }

        if (is_null($parserMatched)) {
            throw new PortableElementParserException(
                'This zip source is not compatible with any portable element. Manifest and/or engine file are missing '
                . ' or related extensions are not installed.'
            );
        }

        $source = $parserMatched->extract($directory);
        $object = $parserMatched->getModel()->createDataObject($parserMatched->getManifestContent($directory));

        // Validate Portable Element  Model
        try {
            $this->validate($object, $source);
        } catch (PortableElementInvalidModelException $e) {
            \common_Logger::w($e->getMessage());
            return null;
        }

        return $object;
    }
public function getValidPortableElementFromDirectorySource ( $ directory ) { $ parserMatched = null ; $ parsers = $ this -> getDirectoryParsers ( ) ; /** @var PortableElementDirectoryParser $parser */ foreach ( $ parsers as $ parser ) { if ( $ parser -> hasValidPortableElement ( $ directory ) ) { $ parserMatched = $ parser ; } } if ( is_null ( $ parserMatched ) ) { throw new PortableElementParserException ( 'This zip source is not compatible with any portable element. Manifest and/or engine file are missing ' . ' or related extensions are not installed.' ) ; } $ source = $ parserMatched -> extract ( $ directory ) ; $ object = $ parserMatched -> getModel ( ) -> createDataObject ( $ parserMatched -> getManifestContent ( $ directory ) ) ; // Validate Portable Element  Model try { $ this -> validate ( $ object , $ source ) ; } catch ( PortableElementInvalidModelException $ e ) { \ common_Logger :: w ( $ e -> getMessage ( ) ) ; return null ; } return $ object ; }
Extract a valid model from a directory

@param $directory
@return null|PortableElementObject
@throws PortableElementParserException
@throws \common_Exception
Extract a valid model from a directory