Skip to content

Commit

Permalink
Merge 846c5c2 into d253e20
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Jan 16, 2023
2 parents d253e20 + 846c5c2 commit 5a494b8
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 275 deletions.
40 changes: 0 additions & 40 deletions .docs/README.md
Expand Up @@ -11,7 +11,6 @@
- [Attributes](#attributes)
- [Annotations](#annotations)
- [XML](#xml)
- [YAML](#yaml)
- [Helpers](#helpers)
- [Examples](#examples)
- [Other](#other)
Expand Down Expand Up @@ -188,7 +187,6 @@ Additional metadata provider needs to be registered. We provide bridges for thes

- **attributes** (`Nettrine\ORM\DI\OrmAttributesExtension`)
- **annotations** (`Nettrine\ORM\DI\OrmAnnotationsExtension`)
- **yaml** (`Nettrine\ORM\DI\OrmYamlExtension`)
- **xml** (`Nettrine\ORM\DI\OrmXmlExtension`)


Expand Down Expand Up @@ -343,43 +341,6 @@ nettrine.orm.xml:
Using **simple** you will enable [`SimplifiedXmlDriver`](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/xml-mapping.html#simplified-xml-driver).


### YAML

Are you using [YAML mapping](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/yaml-mapping.html) for your entities?

```yaml
# Doctrine.Tests.ORM.Mapping.User.dcm.yml
Doctrine\Tests\ORM\Mapping\User:
type: entity
repositoryClass: Doctrine\Tests\ORM\Mapping\UserRepository
table: cms_users
schema: schema_name
readOnly: true
indexes:
name_index:
columns: [ name ]
id:
id:
type: integer
generator:
strategy: AUTO
```

You will also appreciate ORM => YAML bridge, use `OrmYamlExtension`. This is the default configuration:

```neon
extensions:
nettrine.orm: Nettrine\ORM\DI\OrmExtension
nettrine.orm.yaml: Nettrine\ORM\DI\OrmYamlExtension
nettrine.orm.yaml:
mapping: [
namespace: path
]
fileExtension: .orm.yml
```


### Helpers

**MappingHelper**
Expand All @@ -400,7 +361,6 @@ class CategoryExtension extends CompilerExtension
->addAnnotation('Forum\Modules\Database', __DIR__ . '/../../modules/Forum/Database')
->addXml('Gallery1\Modules\Database', __DIR__ . '/../../modules/Gallery1/Database')
->addXml('Gallery2\Modules\Database', __DIR__ . '/../../modules/Gallery2/Database', $simple = TRUE)
->addYaml('Users\Modules\Database', __DIR__ . '/../../modules/Users/Database');
}

}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/coverage.yml
Expand Up @@ -10,8 +10,6 @@ on:
- cron: "0 8 * * 1"

jobs:
test80:
coverage:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-coverage.yml@v1
with:
php: "8.0"
25 changes: 12 additions & 13 deletions .github/workflows/tests.yml
Expand Up @@ -4,40 +4,39 @@ on:
pull_request:

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

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

jobs:
test81:
test82:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "8.1"
php: "8.2"

test80:
test81:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "8.0"
php: "8.1"

test74:
test80:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "7.4"
php: "8.0"

test73:
test74:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "7.3"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
php: "7.4"

test72:
testlower:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "7.2"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
php: "7.4"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -52,9 +52,8 @@ For details on how to use this package, check out our [documentation](.docs).

| State | Version | Branch | Nette | PHP |
|-------------|-------------|----------|--------|---------|
| dev | `^0.8` | `master` | `3.0+` | `>=7.2` |
| stable | `^0.7` | `master` | `3.0+` | `^7.2` |
| stable | `^0.3` | `master` | `2.4` | `^7.1` |
| dev | `^0.8` | `master` | `3.0+` | `>=7.4` |
| stable | `^0.7` | `master` | `3.0+` | `>=7.4` |

## Development

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Expand Up @@ -12,14 +12,14 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=7.4",
"contributte/di": "^0.5.0",
"symfony/console": "^4.2.5|^5.0.0|^6.0.0",
"symfony/console": "^5.3.0 || ^6.2.0",
"nettrine/annotations": "^0.7.0 || ^0.8.0",
"nettrine/cache": "^0.3.0 || ^0.4.0",
"nettrine/dbal": "^0.7.0 || ^0.8.0",
"doctrine/orm": "^2.6.3",
"doctrine/common":"^2.13.1 || ^3.0.0"
"nettrine/dbal": "^0.8.0 || ^0.9.0",
"doctrine/orm": "^2.14.0",
"doctrine/common":"^3.4.3"
},
"require-dev": {
"mockery/mockery": "^1.3.1",
Expand Down Expand Up @@ -54,7 +54,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.8.x-dev"
"dev-master": "0.9.x-dev"
}
}
}
5 changes: 1 addition & 4 deletions phpstan.neon
Expand Up @@ -6,10 +6,7 @@ includes:

parameters:
level: 9
phpVersion: 70200
phpVersion: 70400

paths:
- src

ignoreErrors:
- '#Fetching class constant .+ of deprecated class Doctrine\\\w+.+#'
18 changes: 0 additions & 18 deletions src/DI/Helpers/MappingHelper.php
Expand Up @@ -10,7 +10,6 @@
use Nettrine\ORM\DI\OrmAttributesExtension;
use Nettrine\ORM\DI\OrmExtension;
use Nettrine\ORM\DI\OrmXmlExtension;
use Nettrine\ORM\DI\OrmYamlExtension;
use Nettrine\ORM\Exception\Logical\InvalidStateException;

class MappingHelper
Expand Down Expand Up @@ -84,23 +83,6 @@ public function addXml(string $namespace, string $path, bool $simple = false): s
return $this;
}

public function addYaml(string $namespace, string $path): self
{
if (!is_dir($path)) {
throw new InvalidStateException(sprintf('Given mapping path "%s" does not exist', $path));
}

/** @var ServiceDefinition $yamlDriver */
$yamlDriver = $this->getService(OrmYamlExtension::DRIVER_TAG, 'YamlDriver');
$yamlDriver->addSetup(new Statement('$service->getLocator()->addNamespacePrefixes([? => ?])', [$path, $namespace]));

/** @var ServiceDefinition $chainDriver */
$chainDriver = $this->getService(OrmExtension::MAPPING_DRIVER_TAG, 'MappingDriverChain');
$chainDriver->addSetup('addDriver', [$yamlDriver, $namespace]);

return $this;
}

private function getService(string $tag, string $name): Definition
{
$builder = $this->extension->getContainerBuilder();
Expand Down
26 changes: 0 additions & 26 deletions src/DI/OrmConsoleExtension.php
Expand Up @@ -3,19 +3,14 @@
namespace Nettrine\ORM\DI;

use Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand;
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;
use Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand;
use Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand;
use Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand;
use Doctrine\ORM\Tools\Console\Command\InfoCommand;
use Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand;
use Doctrine\ORM\Tools\Console\Command\RunDqlCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand;
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Nette\DI\Definitions\ServiceDefinition;
use Nette\DI\Definitions\Statement;
use Nette\DI\ServiceCreationException;
Expand Down Expand Up @@ -48,11 +43,6 @@ public function loadConfiguration(): void

$builder = $this->getContainerBuilder();

// Helpers
$builder->addDefinition($this->prefix('entityManagerHelper'))
->setType(EntityManagerHelper::class)
->setAutowired(false);

// Commands
$builder->addDefinition($this->prefix('schemaToolCreateCommand'))
->setType(CreateCommand::class)
Expand All @@ -66,26 +56,10 @@ public function loadConfiguration(): void
->setType(DropCommand::class)
->addTag('console.command', 'orm:schema-tool:drop')
->setAutowired(false);
$builder->addDefinition($this->prefix('convertMappingCommand'))
->setType(ConvertMappingCommand::class)
->addTag('console.command', 'orm:convert-mapping')
->setAutowired(false);
$builder->addDefinition($this->prefix('ensureProductionSettingsCommand'))
->setType(EnsureProductionSettingsCommand::class)
->addTag('console.command', 'orm:ensure-production-settings')
->setAutowired(false);
$builder->addDefinition($this->prefix('generateEntitiesCommand'))
->setType(GenerateEntitiesCommand::class)
->addTag('console.command', 'orm:generate-entities')
->setAutowired(false);
$builder->addDefinition($this->prefix('generateProxiesCommand'))
->setType(GenerateProxiesCommand::class)
->addTag('console.command', 'orm:generate-proxies')
->setAutowired(false);
$builder->addDefinition($this->prefix('generateRepositoriesCommand'))
->setType(GenerateRepositoriesCommand::class)
->addTag('console.command', 'orm:generate-repositories')
->setAutowired(false);
$builder->addDefinition($this->prefix('infoCommand'))
->setType(InfoCommand::class)
->addTag('console.command', 'orm:info')
Expand Down
59 changes: 0 additions & 59 deletions src/DI/OrmYamlExtension.php

This file was deleted.

29 changes: 0 additions & 29 deletions src/Entity/Attributes/Id.php

This file was deleted.

10 changes: 4 additions & 6 deletions src/EntityManagerDecorator.php
Expand Up @@ -15,13 +15,11 @@ public function __construct(EntityManagerInterface $wrapped)
}

/**
* {@inheritdoc}
*
* @psalm-param class-string<T> $className
* @psalm-return EntityRepository<T>
* @template T
* @template T of object
* @param class-string<T> $className
* @return EntityRepository<T>
*/
public function getRepository($className)
public function getRepository($className): EntityRepository
{
return $this->wrapped->getRepository($className);
}
Expand Down

0 comments on commit 5a494b8

Please sign in to comment.