Skip to content

Commit

Permalink
Fix documentation directory names for component names with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jkphl committed Apr 16, 2019
1 parent 99362a9 commit 7d13474
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Classes/Component/AbstractComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ abstract class AbstractComponent implements ComponentInterface
* @var int
*/
protected $status = self::STATUS_TBD;
/**
* Basename
*
* @var string
*/
protected $basename = null;
/**
* Name
*
Expand Down Expand Up @@ -282,8 +288,8 @@ protected function determineNameAndVariant()
{
$reflectionClass = new \ReflectionClass($this);
$componentName = preg_replace('/Component$/', '', $reflectionClass->getShortName());
list($name, $variant) = preg_split('/_+/', $componentName, 2);
$this->name = self::expandComponentName($name);
list($this->basename, $variant) = preg_split('/_+/', $componentName, 2);
$this->name = self::expandComponentName($this->basename);
$this->variant = self::expandComponentName($variant);
}

Expand Down Expand Up @@ -331,7 +337,7 @@ protected function addDocumentation()
$validIndexDocuments = [
'index.md',
'readme.md',
strtolower($this->name.'.md')
strtolower($this->basename.'.md')
];
$indexDocument = null;
$documents = [];
Expand Down Expand Up @@ -387,7 +393,7 @@ protected function getDocumentationDirectory($rootRelative = false)
{
$reflectionObject = new \ReflectionObject($this);
$componentFile = $reflectionObject->getFileName();
$docDirectory = dirname($componentFile).DIRECTORY_SEPARATOR.$this->name;
$docDirectory = dirname($componentFile).DIRECTORY_SEPARATOR.$this->basename;

return $rootRelative ? substr($docDirectory, strlen(PATH_site) - 1) : $docDirectory;
}
Expand Down

0 comments on commit 7d13474

Please sign in to comment.