-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix use of internal seeder within open-source modules
(cherry picked from commit a946827aae2eca67cb34b8491d7d1485d4d75875)
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Crm\UsersModule\Seeders; | ||
|
||
use Crm\ApplicationModule\Seeders\ISeeder; | ||
use Crm\UsersModule\Repositories\AddressTypesRepository; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class AddressTypesTestSeeder implements ISeeder | ||
{ | ||
public const ADDRESS_TYPE = 'crm_test'; | ||
|
||
public function __construct(private AddressTypesRepository $addressTypesRepository) | ||
{ | ||
} | ||
|
||
public function seed(OutputInterface $output) | ||
{ | ||
$types = [ | ||
self::ADDRESS_TYPE => 'Dummy address type for tests', | ||
]; | ||
|
||
foreach ($types as $type => $title) { | ||
if ($this->addressTypesRepository->findBy('type', $type)) { | ||
$output->writeln(" * address type <info>{$type}</info> exists"); | ||
} else { | ||
$this->addressTypesRepository->insert([ | ||
'type' => $type, | ||
'title' => $title, | ||
]); | ||
$output->writeln(" <comment>* address type <info>{$type}</info> created</comment>"); | ||
} | ||
} | ||
} | ||
} |
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