XBRL-Package.php
public static function getPackage( $taxonomyPackage, $additionalPackageClasses = array() )
	{
		if ( ! is_array( $additionalPackageClasses ) )
		{
			$additionalPackageClasses = array();
		}

		$packageClassesFile = __DIR__ . '/TaxonomyPackageTypes.json';
		$packageClasses = null;
		if ( file_exists( __DIR__ . '/TaxonomyPackageTypes.json' ) )
		{
			// echo file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' );
			$json = json_decode( file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' ), true );
			if ( $json && isset( $json['classNames'] ) )
			{
				$packageClasses = $json['classNames'];
			}
			else
			{
				echo "Unable to load the package classes JSON file" . XBRL::json_last_error_msg() , "\n";
			}
		}

		if ( ! $packageClasses )
		{
			$packageClasses = array( 'XBRL_TaxonomyPackage', 'XBRL_SEC_JSON_Package', 'XBRL_SEC_XML_Package', 'XBRL_SimplePackage' );
		}

		// Any additional package classes should be evaluated first.
		// Additional classes should make sure there is validation so they are not used when they are really not suitable
		$packageClasses = $additionalPackageClasses + $packageClasses;

		foreach ( $packageClasses as $packageClassName )
		{
			/** @var XBRL_Package $package */
			$package = XBRL_Package::fromFile( $taxonomyPackage, $packageClassName );
			if ( ! $package->isPackage() ) continue;

			// Load the XBRL class
			$className = $package->getXBRLClassname();
			class_exists( $className, true );
			return $package;
		}

		if ( ! $found )
		{
			$zip = basename( $taxonomyPackage );
			throw new Exception( "The contents of file '$zip' do not match any of the supported taxonomy package formats" );
		}
	}
public static function getPackage( $taxonomyPackage, $additionalPackageClasses = array() )
	{
		if ( ! is_array( $additionalPackageClasses ) )
		{
			$additionalPackageClasses = array();
		}

		$packageClassesFile = __DIR__ . '/TaxonomyPackageTypes.json';
		$packageClasses = null;
		if ( file_exists( __DIR__ . '/TaxonomyPackageTypes.json' ) )
		{
			// echo file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' );
			$json = json_decode( file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' ), true );
			if ( $json && isset( $json['classNames'] ) )
			{
				$packageClasses = $json['classNames'];
			}
			else
			{
				echo "Unable to load the package classes JSON file" . XBRL::json_last_error_msg() , "\n";
			}
		}

		if ( ! $packageClasses )
		{
			$packageClasses = array( 'XBRL_TaxonomyPackage', 'XBRL_SEC_JSON_Package', 'XBRL_SEC_XML_Package', 'XBRL_SimplePackage' );
		}

		// Any additional package classes should be evaluated first.
		// Additional classes should make sure there is validation so they are not used when they are really not suitable
		$packageClasses = $additionalPackageClasses + $packageClasses;

		foreach ( $packageClasses as $packageClassName )
		{
			/** @var XBRL_Package $package */
			$package = XBRL_Package::fromFile( $taxonomyPackage, $packageClassName );
			if ( ! $package->isPackage() ) continue;

			// Load the XBRL class
			$className = $package->getXBRLClassname();
			class_exists( $className, true );
			return $package;
		}

		if ( ! $found )
		{
			$zip = basename( $taxonomyPackage );
			throw new Exception( "The contents of file '$zip' do not match any of the supported taxonomy package formats" );
		}
	}
public static function getPackage ( $ taxonomyPackage , $ additionalPackageClasses = array ( ) ) { if ( ! is_array ( $ additionalPackageClasses ) ) { $ additionalPackageClasses = array ( ) ; } $ packageClassesFile = __DIR__ . '/TaxonomyPackageTypes.json' ; $ packageClasses = null ; if ( file_exists ( __DIR__ . '/TaxonomyPackageTypes.json' ) ) { // echo file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' );
 $ json = json_decode ( file_get_contents ( __DIR__ . '/TaxonomyPackageTypes.json' ) , true ) ; if ( $ json && isset ( $ json [ 'classNames' ] ) ) { $ packageClasses = $ json [ 'classNames' ] ; } else { echo "Unable to load the package classes JSON file" . XBRL :: json_last_error_msg ( ) , "\n" ; } } if ( ! $ packageClasses ) { $ packageClasses = array ( 'XBRL_TaxonomyPackage' , 'XBRL_SEC_JSON_Package' , 'XBRL_SEC_XML_Package' , 'XBRL_SimplePackage' ) ; } // Any additional package classes should be evaluated first.
 // Additional classes should make sure there is validation so they are not used when they are really not suitable
 $ packageClasses = $ additionalPackageClasses + $ packageClasses ; foreach ( $ packageClasses as $ packageClassName ) { /** @var XBRL_Package $package */ $ package = XBRL_Package :: fromFile ( $ taxonomyPackage , $ packageClassName ) ; if ( ! $ package -> isPackage ( ) ) continue ; // Load the XBRL class
 $ className = $ package -> getXBRLClassname ( ) ; class_exists ( $ className , true ) ; return $ package ; } if ( ! $ found ) { $ zip = basename ( $ taxonomyPackage ) ; throw new Exception ( "The contents of file '$zip' do not match any of the supported taxonomy package formats" ) ; } }
Factory to create a package class instance
@param string $taxonomyPackage
@param array $additionalPackageClasses (optional) A list of other packaging classes that could be valid
@throws Exception
@return XBRL_Package
Factory to create a package class instance