Permalink
Browse files

Simplify the package path guessing.

  • Loading branch information...
taylorotwell committed Oct 29, 2013
1 parent 4f7d5d0 commit 6089525e1293407085c07588f2eb8b2cd8644b01
Showing with 1 addition and 31 deletions.
  1. +1 −31 src/Illuminate/Support/ServiceProvider.php
@@ -105,41 +105,11 @@ public function package($package, $namespace = null, $path = null)
*/
public function guessPackagePath()
{
$reflect = new ReflectionClass($this);
// We want to get the class that is closest to this base class in the chain of
// classes extending it. That should be the original service provider given
// by the package and should allow us to guess the location of resources.
$chain = $this->getClassChain($reflect);
$path = $chain[count($chain) - 2]->getFileName();
$path = with(new ReflectionClass($this))->getFileName();
return realpath(dirname($path).'/../../');
}
/**
* Get a class from the ReflectionClass inheritance chain.
*
* @param ReflectionClass $reflection
* @return array
*/
protected function getClassChain(ReflectionClass $reflect)
{
$classes = array();
// This loop essentially walks the inheritance chain of the classes starting
// at the most "childish" class and walks back up to this class. Once we
// get to the end of the chain we will bail out and return the offset.
while ($reflect !== false)
{
$classes[] = $reflect;
$reflect = $reflect->getParentClass();
}
return $classes;
}
/**
* Determine the namespace for a package.
*

0 comments on commit 6089525

Please sign in to comment.