Airship\Engine\Continuum::getGadgets PHP Method

getGadgets() public method

Get an array of GadgetUpdater objects
public getGadgets ( ) : array
return array
    public function getGadgets() : array
    {
        $gadgets = [];
        // First, each cabin's gadgets:
        foreach (\glob(ROOT . '/Cabin/*') as $dir) {
            if (!\is_dir($dir)) {
                continue;
            }
            $cabinInfo = \Airship\loadJSON($dir . '/manifest.json');
            if (\is_dir($dir . '/Gadgets')) {
                foreach (\Airship\list_all_files($dir . '/Gadgets/', 'phar') as $file) {
                    $manifest = $this->getPharManifest($file);
                    $name = \preg_replace('#^.+?/([^\\/]+)\\.phar$#', '$1', $file);
                    $gadgets[$name] = new GadgetUpdater($this->hail, $manifest, $this->getSupplier($manifest['supplier']), $file);
                    $gadgets[$name]->setCabin($cabinInfo['supplier'], $cabinInfo['name']);
                }
            }
        }
        //  Then, the universal gadgets:
        foreach (\Airship\list_all_files(ROOT . '/Gadgets/', 'phar') as $file) {
            $manifest = $this->getPharManifest($file);
            $name = \preg_replace('#^.+?/([^\\/]+)\\.phar$#', '$1', $file);
            $orig = '' . $name;
            // Handle name collisions
            while (isset($gadgets[$name])) {
                $i = isset($i) ? ++$i : 2;
                $name = $orig . '-' . $i;
            }
            $gadgets[$name] = new GadgetUpdater($this->hail, $manifest, $this->getSupplier($manifest['supplier']), $file);
        }
        return $gadgets;
    }