This repository has been archived by the owner on Jul 6, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move category factory to it's own class
- Loading branch information
1 parent
44a1f43
commit f4bace0
Showing
7 changed files
with
68 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\Example\DataObject; | ||
|
||
use OxidEsales\Eshop\Core\Registry; | ||
use OxidEsales\GraphQL\Example\DataObject\Category; | ||
use TheCodingMachine\GraphQLite\Annotations\Factory; | ||
|
||
class CategoryFactory | ||
{ | ||
/** | ||
* @Factory | ||
*/ | ||
public static function createCategory(?string $id = null, string $name, ?string $parentid = null): Category | ||
{ | ||
if ($id === null) { | ||
$id = Registry::getUtilsObject()->generateUID(); | ||
} | ||
if ($parentid === null) { | ||
$parentid = 'oxrootid'; | ||
} | ||
return new Category( | ||
$id, | ||
$name, | ||
$parentid | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters