ComponentInstaller\Installer::supports PHP Метод

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

Components are supported by all packages. This checks wheteher or not the entire package is a "component", as well as injects the script to act on components embedded in packages that are not just "component" types.
public supports ( $packageType )
    public function supports($packageType)
    {
        // Components are supported by all package types. We will just act on
        // the root package's scripts if available.
        $rootPackage = isset($this->composer) ? $this->composer->getPackage() : null;
        if (isset($rootPackage)) {
            // Ensure we get the root package rather than its alias.
            while ($rootPackage instanceof AliasPackage) {
                $rootPackage = $rootPackage->getAliasOf();
            }
            // Make sure the root package can override the available scripts.
            if (method_exists($rootPackage, 'setScripts')) {
                $scripts = $rootPackage->getScripts();
                // Act on the "post-autoload-dump" command so that we can act on all
                // the installed packages.
                $scripts['post-autoload-dump']['component-installer'] = 'ComponentInstaller\\Installer::postAutoloadDump';
                $rootPackage->setScripts($scripts);
            }
        }
        // State support for "component" package types.
        return $packageType == 'component';
    }

Usage Example

Пример #1
0
 /**
  * Test the Installer's support() function.
  *
  * @param $type
  *   The type of library.
  * @param $expected
  *   Whether or not the given type is supported by Component Installer.
  *
  * @return void
  *
  * @dataProvider providerComponentSupports
  */
 public function testComponentSupports($type, $expected)
 {
     $installer = new Installer($this->io, $this->composer, 'component');
     $this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type));
 }