diff --git a/src/Scaffolding/Scaffolders/CRUD/Create.php b/src/Scaffolding/Scaffolders/CRUD/Create.php index c2fc6fbab..9a7923428 100644 --- a/src/Scaffolding/Scaffolders/CRUD/Create.php +++ b/src/Scaffolding/Scaffolders/CRUD/Create.php @@ -41,7 +41,7 @@ public function getName() return $name; } - return 'create' . ucfirst($this->getTypeName()); + return 'create' . ucfirst($this->getResolvedTypeName()); } /** @@ -107,7 +107,7 @@ protected function generateInputType(Manager $manager) */ protected function inputTypeName() { - return $this->getTypeName() . 'CreateInputType'; + return $this->getResolvedTypeName() . 'CreateInputType'; } public function resolve($object, array $args, $context, ResolveInfo $info) diff --git a/src/Scaffolding/Scaffolders/CRUD/Delete.php b/src/Scaffolding/Scaffolders/CRUD/Delete.php index be10dcec4..d99193b9e 100644 --- a/src/Scaffolding/Scaffolders/CRUD/Delete.php +++ b/src/Scaffolding/Scaffolders/CRUD/Delete.php @@ -39,7 +39,7 @@ public function getName() return $name; } - return 'delete' . ucfirst($this->getTypeName()); + return 'delete' . ucfirst($this->getResolvedTypeName()); } /** diff --git a/src/Scaffolding/Scaffolders/CRUD/Read.php b/src/Scaffolding/Scaffolders/CRUD/Read.php index a4e3f846c..a171fa246 100644 --- a/src/Scaffolding/Scaffolders/CRUD/Read.php +++ b/src/Scaffolding/Scaffolders/CRUD/Read.php @@ -45,7 +45,7 @@ public function getName() return $name; } - $typePlural = $this->pluralise($this->getTypeName()); + $typePlural = $this->pluralise($this->getResolvedTypeName()); return 'read' . ucfirst($typePlural); } diff --git a/src/Scaffolding/Scaffolders/CRUD/ReadOne.php b/src/Scaffolding/Scaffolders/CRUD/ReadOne.php index e58133951..d91492447 100644 --- a/src/Scaffolding/Scaffolders/CRUD/ReadOne.php +++ b/src/Scaffolding/Scaffolders/CRUD/ReadOne.php @@ -34,7 +34,7 @@ public function getName() return $name; } - return 'readOne' . ucfirst($this->getTypeName()); + return 'readOne' . ucfirst($this->getResolvedTypeName()); } /** diff --git a/src/Scaffolding/Scaffolders/CRUD/Update.php b/src/Scaffolding/Scaffolders/CRUD/Update.php index 74b62e68f..8c466576f 100644 --- a/src/Scaffolding/Scaffolders/CRUD/Update.php +++ b/src/Scaffolding/Scaffolders/CRUD/Update.php @@ -42,7 +42,7 @@ public function getName() return $name; } - return 'update' . ucfirst($this->getTypeName()); + return 'update' . ucfirst($this->getResolvedTypeName()); } /** @@ -114,7 +114,7 @@ protected function generateInputType(Manager $manager) */ protected function inputTypeName() { - return $this->getTypeName() . 'UpdateInputType'; + return $this->getResolvedTypeName() . 'UpdateInputType'; } /** diff --git a/src/Scaffolding/Scaffolders/DataObjectScaffolder.php b/src/Scaffolding/Scaffolders/DataObjectScaffolder.php index 374c82724..51999556e 100644 --- a/src/Scaffolding/Scaffolders/DataObjectScaffolder.php +++ b/src/Scaffolding/Scaffolders/DataObjectScaffolder.php @@ -82,7 +82,7 @@ public function __construct($dataObjectClass) */ public function getTypeName() { - return $this->typeName(); + return $this->getDataObjectTypeName(); } /** diff --git a/src/Scaffolding/Scaffolders/ListQueryScaffolder.php b/src/Scaffolding/Scaffolders/ListQueryScaffolder.php index 923d0667c..33f2ecb4b 100644 --- a/src/Scaffolding/Scaffolders/ListQueryScaffolder.php +++ b/src/Scaffolding/Scaffolders/ListQueryScaffolder.php @@ -130,7 +130,7 @@ public function applyConfig(array $config) } else { throw new InvalidArgumentException(sprintf( 'sortableFields must be an array (see %s)', - $this->getTypeName() + $this->getResolvedTypeName() )); } } diff --git a/src/Scaffolding/Scaffolders/MutationScaffolder.php b/src/Scaffolding/Scaffolders/MutationScaffolder.php index 09b602492..4cc638881 100644 --- a/src/Scaffolding/Scaffolders/MutationScaffolder.php +++ b/src/Scaffolding/Scaffolders/MutationScaffolder.php @@ -61,9 +61,15 @@ public function scaffold(Manager $manager) ]; } - public function getTypeName() + /** + * If a type name has not been assigned, fallback to the typename that gets generated + * off the dataobject + * + * @return string + */ + protected function getResolvedTypeName() { - return parent::getTypeName() ?: $this->typeName(); + return $this->getTypeName() ?: $this->getDataObjectTypeName(); } /** diff --git a/src/Scaffolding/Scaffolders/QueryScaffolder.php b/src/Scaffolding/Scaffolders/QueryScaffolder.php index fc0af47c4..fa24e8098 100644 --- a/src/Scaffolding/Scaffolders/QueryScaffolder.php +++ b/src/Scaffolding/Scaffolders/QueryScaffolder.php @@ -71,9 +71,15 @@ public function setNested($bool) return $this; } - public function getTypeName() + /** + * If a type name has not been assigned, fallback to the typename that gets generated + * off the dataobject + * + * @return string + */ + protected function getResolvedTypeName() { - return parent::getTypeName() ?: $this->typeName(); + return $this->getTypeName() ?: $this->getDataObjectTypeName(); } /** diff --git a/src/Scaffolding/Traits/DataObjectTypeTrait.php b/src/Scaffolding/Traits/DataObjectTypeTrait.php index 36a78f496..1262a5223 100644 --- a/src/Scaffolding/Traits/DataObjectTypeTrait.php +++ b/src/Scaffolding/Traits/DataObjectTypeTrait.php @@ -33,11 +33,10 @@ public function getDataObjectClass() /** * Type name inferred from the dataobject. - * This should not be called directly, but only by getTypeName() * * @return string */ - protected function typeName() + public function getDataObjectTypeName() { $dataObjectClass = $this->getDataObjectClass(); if (!$dataObjectClass) {