-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from buggregator/hotfix/default-project
Adds default project on buggregator startup.
- Loading branch information
Showing
23 changed files
with
253 additions
and
184 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
app/database/Migrations/20240728.115465_1_1_default_create_default_project.php
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Migrations; | ||
|
||
use Cycle\Migrations\Migration; | ||
use Cycle\ORM\EntityManagerInterface; | ||
use Modules\Projects\Domain\Project; | ||
use Modules\Projects\Domain\ProjectRepositoryInterface; | ||
use Modules\Projects\Domain\ValueObject\Key; | ||
use Spiral\Core\ContainerScope; | ||
|
||
class OrmDefaultD93e77c9f5556975e93bfbc969442732 extends Migration | ||
{ | ||
protected const DATABASE = 'default'; | ||
|
||
public function up(): void | ||
{ | ||
$this->getEntityManager() | ||
->persist(new Project(Key::create(Project::DEFAULT_KEY), 'Default project')) | ||
->run(); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
$defaultProject = $this->getRepository()->findOne(['key' => Project::DEFAULT_KEY]); | ||
if ($defaultProject !== null) { | ||
$this->getEntityManager()->delete($defaultProject)->run(); | ||
} | ||
} | ||
|
||
private function getEntityManager(): EntityManagerInterface | ||
{ | ||
return ContainerScope::getContainer()->get(EntityManagerInterface::class); | ||
} | ||
|
||
private function getRepository(): ProjectRepositoryInterface | ||
{ | ||
return ContainerScope::getContainer()->get(ProjectRepositoryInterface::class); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Modules\Projects\Domain; | ||
|
||
use Modules\Projects\Domain\ValueObject\Key; | ||
|
||
interface ProjectInterface | ||
{ | ||
public function getKey(): Key; | ||
public function getName(): string; | ||
} |
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
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
Oops, something went wrong.