/** * Extension list. * * @return \Illuminate\Support\Collection * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function getExtensions() { if ($this->extensions->isEmpty()) { if ($this->files->isDirectory($this->getExtensionPath()) && !empty($vendors = $this->files->directories($this->getExtensionPath()))) { collect($vendors)->each(function ($vendor) { if ($this->files->isDirectory($vendor) && !empty($directories = $this->files->directories($vendor))) { collect($directories)->each(function ($directory) { if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) { $package = new Collection(json_decode($this->files->get($file), true)); if (Arr::get($package, 'type') == 'notadd-extension' && ($name = Arr::get($package, 'name'))) { $extension = new Extension($name); $extension->setAuthor(Arr::get($package, 'authors')); $extension->setDescription(Arr::get($package, 'description')); if ($entries = data_get($package, 'autoload.psr-4')) { foreach ($entries as $namespace => $entry) { $extension->setEntry($namespace . 'Extension'); } } $this->extensions->put($directory, $extension); } } }); } }); } } return $this->extensions; }
/** * @return \Notadd\Foundation\Extension\Extension */ public final function getExtension() { $extension = new Extension($this->getExtensionName(), $this->getExtensionPath()); $extension->setRegistrar($this); return $extension; }