Returns a package by some of its sub directories

@return Package|NULL
517402
public function findByDirectory(Dir $directoryInPackage) {
    foreach ($this->packages as $package) {
      if ($directoryInPackage->isSubdirectoryOf($package->getRootDirectory())
          || $directoryInPackage->equals($package->getRootDirectory())
         ) {
        return $package;
      }
    }
  }
687833
public static function get_by_package($package_name = 'project') {
		if (!file_exists(Config::$migration_directory)) {
			throw new \Exception('Config::$migration_directory is not set to a valid directory');
		}

		/**
		 * Array with results
		 */
		$migrations = [];

		if ($package_name == 'project') {
			$files = scandir(Config::$migration_directory, SCANDIR_SORT_ASCENDING);

			foreach ($files as $key => $file) {
				if ($file[0] == '.') {
					unset($files[$key]);
					continue;
				}

				if ($file == 'db_version') {
					unset($files[$key]);
					continue;
				}

				if (!preg_match("/^\d{8}_\d{6}_.*$/", $file)) {
					unset($files[$key]);
					continue;
				}


				$parts = explode('_', $file);
				foreach ($parts as $key => $part) {
					$parts[$key] = ucfirst($part);
				}

				$classname = 'Migration_' . str_replace('.php', '', implode('_', $parts));
				include_once Config::$migration_directory . '/' . $file;
				$migrations[] = new $classname();
			}
		} else {

			/**
			 * Make a list of all migrations to be execute
			 */
			$packages = \Skeleton\Core\Skeleton::get_all();

			foreach ($packages as $package) {
				if ($package->name != $package_name) {
					continue;
				}
				if (!file_exists($package->migration_path)) {
					continue;
				}
				$files = scandir($package->migration_path, SCANDIR_SORT_ASCENDING);

				foreach ($files as $key => $file) {
					if ($file[0] == '.') {
						unset($files[$key]);
						continue;
					}

					if ($file == 'db_version') {
						unset($files[$key]);
						continue;
					}

					if (!preg_match("/^\d{8}_\d{6}_.*$/", $file)) {
						unset($files[$key]);
						continue;
					}


					$parts = explode('_', $file);
					foreach ($parts as $key => $part) {
						$parts[$key] = ucfirst($part);
					}

					$namespace_parts = explode('-', $package->name);
					foreach ($namespace_parts as $key => $namespace_part) {
						$namespace_parts[$key] = ucfirst($namespace_part);
					}
					$namespace = implode('\\', $namespace_parts);

					$classname = $namespace . '\Migration_' . str_replace('.php', '', implode('_', $parts));
					include_once $package->migration_path . '/' . $file;
					$migrations[] = new $classname();
				}
			}
		}


		return $migrations;
	}
638225
protected function findAllAssetPackages()
    {
        $packages = array();

        //
        $namespaces = $this->dispatcher->getHints();

        foreach ($namespaces as $name => $hint) {
            $packages[] = $name;
        }

        return $packages;
    }
835240
public function getPackage()
    {
        $inheritedElement = $this->getInheritedElement();
        if ($this->package instanceof PackageDescriptor
            && ! ($this->package->getName() === '\\' && $inheritedElement)) {
            return $this->package;
        }

        if ($inheritedElement instanceof DescriptorAbstract) {
            return $inheritedElement->getPackage();
        }

        return null;
    }
897052
public function getPlainPath() : string
    {
        // Diretório especificado
        $path = $this->getArgument('package_path');
        $pkg_root = ($path[0] == "/") ? rtrim($path, "/") : rtrim(base_path($path), "/");

        // Contém o diretório src?
        $src_path = $pkg_root . DIRECTORY_SEPARATOR . "src";
        if (is_dir($src_path) == true) {
            return $src_path;
        }

        return $pkg_root;
    }
1052250
public function getDirectoryScanner(Project $p = null)
    {
        if ($p === null) {
            $p = $this->getProject();
        }
        if ($this->isReference()) {
            $obj = $this->getRef($p);

            return $obj->getDirectoryScanner($p);
        }

        $this->loadPearPackageScanner($p);

        return $this->pps;
    }
1003599
protected function getInstalledPackages()
    {
        if ($this->installedPackages === null) {
            $installedPackages = [];
            $packageService = $this->application->make(PackageService::class);
            foreach ($packageService->getInstalledHandles() as $packageHandle) {
                $installedPackages[$packageHandle] = $packageService->getClass($packageHandle);
            }
            $this->installedPackages = $installedPackages;
        }

        return $this->installedPackages;
    }
1068505
public function getAll()
    {
        if (!$this->loadRepositories()) {
            return Repository::STATUS_NO_REPOSITORIES;
        }

        $modules = $this->getModulesFromRepository();

        // Is a higher version of an already installed package available?
        foreach ($modules as $key => $module) {
            $version = $this->packageService->getVersion($module->name);

            if (!$version) {
                // Not installed at all.
                unset($modules[$key]);
            } elseif (version_compare($version, $module->version, '<')) {
                // Older version installed.
                $modules[$key]->hasUpdate = true;
                $modules[$key]->versionInstalled = $version;
            } else {
                $modules[$key]->hasUpdate = false;
                $modules[$key]->versionInstalled = $version;
            }
        }

        return $modules;
    }
754490
protected function getPackagePath($slug = null)
    {
        if (! is_null($slug)) {
            return $this->packages->getPackagePath($slug);
        }

        return $this->packages->getPackagesPath();
    }
1071577
protected static function getRootPackage() {
    $file = new JsonFile('composer.json');

    // Split the current working directory into an array, accounting for leading
    // and trailing directory separators.
    $dir = explode(DIRECTORY_SEPARATOR, trim(getcwd(), DIRECTORY_SEPARATOR));

    do {
      if ($file->exists()) {
        $info = $file->read();

        if (isset($info['require']['goalgorilla/open_social'])) {
          return $file;
        }
      }
      chdir('..');
      array_pop($dir);
    }
    while ($dir);

    throw new \RuntimeException('Could not locate the root package.');
  }
1265588
public function findAll()
    {
        $repos = array();
        foreach ($this->repository->findAll() as $repo) {
            $this->loadPackagistInfos($repo);
            $repos[] = $repo;
        }

        return $repos;
    }
502328
public function getPackage($backwards = 4)
    {
        if (!$this->package) {
            // Get package name or guess it.
            $name = $this->config['package.name'] ?: MvcHelper::guessPackage(get_called_class(), $backwards);

            // Get package object
            if ($name) {
                $this->package = PackageHelper::getPackage($name);
            }

            // If package not found, use NullPackage instead.
            if (!$this->package) {
                $this->package = new NullPackage();

                $this->package->setName($name);
            }
        }

        return $this->package;
    }
893197
public function getSubs()
    {
        
        $r = self::getDbConnection()->query('
        	SELECT A.*, B.level 
        	FROM dir_data A, dir_structure B, dir_structure C
        	WHERE A.id=B.data_id and C.data_id='.$this->id.' and B.lft BETWEEN C.lft and C.rght');
        	
		$result = [];
			
        while ($f = $r->fetch()) {
            $c = Catalog::fetch($f);
            $result[] = $c->prototype->id;
        }
                    
        return $result;
    }
295795
public function getDirectory()
    {
        $dir = clone $this;
        $dir->path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($this->path));
        if (!$dir->path) $dir->path = '/';

        return $dir;
    }
137424
protected function getPackagePath()
    {
        $reflection = new ReflectionObject($this);
        $fileName = $reflection->getFileName();
        $packagePath = dirname(dirname(dirname(dirname(dirname(dirname($fileName))))));
        return $packagePath;
    }
220890
public static function getRemotePackages()
	{
		$remoteRepos = self::_getRemoteRepositories();
		$remotePackages = array();
		foreach ($remoteRepos as $repo)
		{
			if (method_exists($repo, "getRepoConfig"))
			{
				$config = $repo->getRepoConfig();
				if (is_array($config) && isset($config['type']) && $config['type'] != 'composer')
				{
					$packages = $repo->getPackages();
					foreach ($packages as $package)
					{
						$remotePackages[$package->getName()] = $package;
					}
				}
			}
		}
		return $remotePackages;
	}
483668
public function getPackages(string $name = null): array
    {
        if (isset($this->packages[$name])) {
            return $this->packages[$name];
        }

        return $this->packages;
    }