diff --git a/core/lib/Drupal/Core/Extension/Extension.php b/core/lib/Drupal/Core/Extension/Extension.php new file mode 100644 index 0000000..76b2f2e --- /dev/null +++ b/core/lib/Drupal/Core/Extension/Extension.php @@ -0,0 +1,54 @@ +uri = $filename; + $this->filename = $this->getFilename(); + // pathinfo('foo.bar', PATHINFO_FILENAME) strips the extension and yields + // 'foo', regardless of what the extension is. SplFileInfo does not have + // a corresponding method for that behavior. + $this->name = pathinfo($this->filename, PATHINFO_FILENAME); + } + + /** + * Returns the name of this extension. + */ + public function getName() { + return $this->name; + } + +} diff --git a/core/lib/Drupal/Core/SystemListing.php b/core/lib/Drupal/Core/SystemListing.php index 7301d82..5bd59b9 100644 --- a/core/lib/Drupal/Core/SystemListing.php +++ b/core/lib/Drupal/Core/SystemListing.php @@ -7,6 +7,8 @@ namespace Drupal\Core; +use Drupal\Core\Extension\Extension; + /** * Returns information about system object files (modules, themes, etc.). * @@ -188,10 +190,7 @@ protected function scanDirectory($dir, $key, $mask, $nomask) { elseif (preg_match($mask, $filename)) { // Always use this match over anything already set in $files with // the same $options['key']. - $file = new \stdClass(); - $file->uri = $uri; - $file->filename = $filename; - $file->name = pathinfo($filename, PATHINFO_FILENAME); + $file = new Extension($uri); $this->processFile($file); $files[$file->$key] = $file; }