Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next (doctrine 3, multiple connections) #3

Merged
merged 17 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ indent_style = tab
indent_size = tab
tab_width = 4

[{*.json, *.yaml, *.yml, *.md}]
[*.{json,yaml,yml,md}]
indent_style = space
indent_size = 2
indent_size = 2
2 changes: 1 addition & 1 deletion .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

push:
branches: ["*"]
branches: [ "*" ]

schedule:
- cron: "0 8 * * 1"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
pull_request:

push:
branches: ["*"]
branches: [ "*" ]

schedule:
- cron: "0 8 * * 1"

jobs:
coverage:
name: "Phpunit"
name: "Nette Tester"
uses: contributte/.github/.github/workflows/phpunit-coverage.yml@v1
with:
make: "init coverage"
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

push:
branches: ["*"]
branches: [ "*" ]

schedule:
- cron: "0 8 * * 1"
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,15 @@ on:

jobs:
test82:
name: "Phpunit"
name: "Nette Tester"
uses: contributte/.github/.github/workflows/phpunit.yml@v1
with:
php: "8.2"
make: "init tests"

test81:
name: "Phpunit"
name: "Nette Tester"
uses: contributte/.github/.github/workflows/phpunit.yml@v1
with:
php: "8.1"
make: "init tests"

testlower:
name: "Phpunit"
uses: contributte/.github/.github/workflows/phpunit.yml@v1
with:
php: "8.1"
make: "init tests"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
.idea

# Composer
/vendor/*

# Apache
!.htaccess
/vendor

# Nette
/var/m
# Nette config
/var/
/config/local.neon

# Docker
/.data
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ phpstan:

.PHONY: tests
tests:
vendor/bin/phpunit -c phpunit.xml --stderr --testsuite Contributte.Unit
vendor/bin/phpunit -c phpunit.xml --stderr --testsuite Contributte.E2E
vendor/bin/tester -s -p php --colors 1 -C tests

.PHONY: coverage
coverage:
vendor/bin/phpunit -c phpunit.xml --coverage-text --colors=never
vendor/bin/phpunit -c phpunit.xml --coverage-html var/tmp/tests/coverage --colors
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./app tests

.PHONY: dev
dev:
Expand All @@ -58,6 +56,13 @@ dev:
build:
echo "OK"

############################################################
# DOCKER ###################################################
############################################################
.PHONY: docker-up
docker-up:
docker compose up

############################################################
# DEPLOYMENT ###############################################
############################################################
Expand Down
12 changes: 8 additions & 4 deletions app/Domain/Database/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
namespace App\Domain\Database;

use App\Model\Database\Entity\AbstractEntity;
use App\Model\Database\Entity\TId;
use Contributte\Utils\DateTime;
use DateTime;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass="App\Domain\Database\UserRepository")
* @ORM\Table(name="`user`")
*/
class User extends AbstractEntity
{

use TId;

/** @ORM\Column(type="string") */
private string $username;

Expand All @@ -24,6 +22,12 @@ class User extends AbstractEntity
/** @ORM\Column(type="datetime", nullable=true) */
private ?DateTime $updatedAt = null;

public function __construct(string $username)
{
$this->username = $username;
$this->createdAt = new DateTime();
}

public function getUsername(): string
{
return $this->username;
Expand Down
2 changes: 1 addition & 1 deletion app/Domain/Database/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Domain\Database;

use App\Model\Database\Repository\AbstractRepository;
use Nettrine\Extra\Repository\AbstractRepository;

/**
* @extends AbstractRepository<User>
Expand Down
19 changes: 19 additions & 0 deletions app/Model/Database/Entity/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@

namespace App\Model\Database\Entity;

use Doctrine\ORM\Mapping as ORM;

abstract class AbstractEntity
{

/**
* @ORM\Column(type="integer", nullable=FALSE)
* @ORM\Id
* @ORM\GeneratedValue
*/
protected int $id;

public function getId(): int
{
return $this->id;
}

public function __clone()
{
unset($this->id);
}

}
30 changes: 0 additions & 30 deletions app/Model/Database/Entity/TId.php

This file was deleted.

19 changes: 2 additions & 17 deletions app/Model/Database/EntityManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,9 @@

namespace App\Model\Database;

use App\Model\Database\Entity\AbstractEntity;
use App\Model\Database\Repository\AbstractRepository;
use Nettrine\ORM\EntityManagerDecorator as NettrineEntityManagerDecorator;
use Doctrine\ORM\Decorator\EntityManagerDecorator as DoctrineEntityManagerDecorator;

final class EntityManagerDecorator extends NettrineEntityManagerDecorator
final class EntityManagerDecorator extends DoctrineEntityManagerDecorator
{

use TRepositories;

/**
* @template T of AbstractEntity
* @param class-string<T> $entityName
* @return AbstractRepository<T>
* @internal
*/
public function getRepository($entityName): AbstractRepository
{
return $this->wrapped->getRepository($entityName);
}

}
82 changes: 0 additions & 82 deletions app/Model/Database/Repository/AbstractRepository.php

This file was deleted.

24 changes: 0 additions & 24 deletions app/Model/Database/TRepositories.php

This file was deleted.

35 changes: 0 additions & 35 deletions app/Model/Exception/Runtime/EntityNotFoundException.php

This file was deleted.

Loading