Перенес файлы в отдельную библиотек.

Предполагается ставить отдельно
master v0.0.1
Rinsvent 3 years ago
commit bb04ded0ad
  1. 7
      .gitignore
  2. 18
      .gitlab-ci.yml
  3. 33
      Makefile
  4. 3
      Readme.md
  5. 9
      bin/docker/ci.sh
  6. 8
      bin/docker/prepare-ci.sh
  7. 16
      codeception.yml
  8. 33
      composer.json
  9. 6343
      composer.lock
  10. 15
      docker-compose-ci.yml
  11. 16
      docker-compose.yml
  12. 10
      src/Data2DTODoctrineEntityBundle.php
  13. 17
      src/DependencyInjection/RequestExtension.php
  14. 12
      src/Resources/config/services.yaml
  15. 16
      src/Service/Entity.php
  16. 30
      src/Service/EntityTransformer.php
  17. 0
      tests/_data/.gitkeep
  18. 2
      tests/_output/.gitignore
  19. 0
      tests/_support/.gitkeep
  20. 10
      tests/_support/Helper/Unit.php
  21. 27
      tests/_support/UnitTester.php
  22. 2
      tests/_support/_generated/.gitignore
  23. 10
      tests/unit.suite.yml

7
.gitignore vendored

@ -0,0 +1,7 @@
.idea
/var/
/vendor/
###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

@ -0,0 +1,18 @@
image: dh.rinsvent.ru/ci
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
services:
- docker:dind
before_script:
- bash bin/docker/prepare-ci.sh
build:
stage: build
script:
- docker login --username ${REGISTRY_USERNAME} --password ${REGISTRY_PASSWORD} dh.rinsvent.ru
- bash bin/docker/ci.sh

@ -0,0 +1,33 @@
auth:
docker exec -it -u1000:1000 data2dtodoctrineentitybundle_php bash
auth-root:
docker exec -it data2dtodoctrineentitybundle_php bash
test:
bin/codecept run $p
coverage:
bin/codecept run --coverage --coverage-html=/app/var/temp.html
# make out container
coverage-open:
google-chrome var/temp.html/index.html
#docker
start:
docker-compose up -d
stop:
docker-compose down
pull:
docker-compose pull
restart: stop start
restart-php:
docker-compose restart backend-php-fpm
down-clear:
docker-compose down -v --remove-orphans
init: down-clear pull start
#prepare
prepare-environment:
bash bin/docker/prepare.sh

@ -0,0 +1,3 @@
Data2dto bundle
=

@ -0,0 +1,9 @@
#!/bin/bash
docker-compose -f ./docker-compose-ci.yml up -d
echo 'composer installing'
docker exec -i data2dtodoctrineentitybundle_php composer install -q
echo 'composer installed !!'
docker exec -i data2dtodoctrineentitybundle_php vendor/bin/codecept run --coverage

@ -0,0 +1,8 @@
#!/bin/bash
FULL_PROJECT_NETWORK=$(docker network ls | grep full-project)
if [ -z "$FULL_PROJECT_NETWORK" ]
then
docker network create full-project --subnet=192.168.221.0/25
fi

@ -0,0 +1,16 @@
namespace: Rinsvent\Data2DTODoctrineEntityBundle\Tests
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
enabled: true
include:
- src/*

@ -0,0 +1,33 @@
{
"name": "rinsvent/data2dto-doctrine-entity-bundle",
"description": "Doctrine entity bridge for data2dto bundle",
"license": "MIT",
"require": {
"php": "^8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"rinsvent/data2dto": "^0.0",
"rinsvent/data2dto-bundle": "^0.0",
"symfony/http-kernel": "^5.3",
"symfony/config": "^5.3",
"symfony/dependency-injection": "^5.3",
"doctrine/orm": "^2"
},
"require-dev": {
"codeception/codeception": "^4.1",
"codeception/module-phpbrowser": "^1.0.0",
"codeception/module-asserts": "^1.0.0"
},
"autoload": {
"psr-4": {
"tests\\": "tests/",
"Rinsvent\\Data2DTODoctrineEntityBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Rinsvent\\Data2DTODoctrineEntityBundle\\Tests\\": "tests/"
}
}
}

6343
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,15 @@
version: '3.3'
services:
data2dtodoctrineentitybundle_php:
image: dh.rinsvent.ru/php8dev
container_name: data2dtodoctrineentitybundle_php
volumes:
- ./:/app
environment:
USE_COMPOSER_SCRIPTS: 0
networks:
default:
external:
name: full-project

@ -0,0 +1,16 @@
version: '3.3'
services:
data2dtodoctrineentitybundle_php:
image: dh.rinsvent.ru/php8dev
container_name: data2dtodoctrineentitybundle_php
volumes:
- ./:/app
environment:
USE_COMPOSER_SCRIPTS: 1
PHP_IDE_CONFIG: "serverName=data2dtodoctrineentitybundle_php"
networks:
default:
external:
name: full-project

@ -0,0 +1,10 @@
<?php
namespace Rinsvent\Data2DTODoctrineEntityBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class Data2DTODoctrineEntityBundle extends Bundle
{
}

@ -0,0 +1,17 @@
<?php
namespace Rinsvent\Data2DTODoctrineEntityBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
class RequestExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
}
}

@ -0,0 +1,12 @@
services:
_defaults:
autoconfigure: true
public: false
autowire: true
Rinsvent\Data2DTODoctrineEntityBundle\Service\:
resource: '../../../src/Service'
_instanceof:
Rinsvent\Data2DTOBundle\Service\AbstractTransformer:
tags: [ 'rinsvent.transformer' ]

@ -0,0 +1,16 @@
<?php
namespace Rinsvent\Data2DTODoctrineEntityBundle\Service\Transformer;
use Rinsvent\Data2DTO\Transformer\Meta;
#[\Attribute]
class Entity extends Meta
{
public const TYPE = 'service';
public function __construct(
public string $class,
public string $primaryType = 'id',
) {}
}

@ -0,0 +1,30 @@
<?php
namespace Rinsvent\Data2DTODoctrineEntityBundle\Service\Transformer;
use Doctrine\ORM\EntityManagerInterface;
use Rinsvent\Data2DTO\Transformer\Meta;
use Rinsvent\Data2DTOBundle\Service\AbstractTransformer;
class EntityTransformer extends AbstractTransformer
{
public function __construct(
protected EntityManagerInterface $em
) {}
/**
* @param $data
* @param Entity $meta
*/
public function transform(&$data, Meta $meta): void
{
if ($meta->primaryType === 'id' && !is_int($data)) {
return;
}
if ($meta->primaryType === 'uuid' && !is_string($data)) {
return;
}
$repository = $this->em->getRepository($meta->class);
$data = $repository->find($data);
}
}

@ -0,0 +1,2 @@
*
!.gitignore

@ -0,0 +1,10 @@
<?php
namespace Rinsvent\Data2DTODoctrineEntityBundle\Tests\Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Unit extends \Codeception\Module
{
}

@ -0,0 +1,27 @@
<?php
namespace Rinsvent\Data2DTODoctrineEntityBundle\Tests;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}

@ -0,0 +1,2 @@
*
!.gitignore

@ -0,0 +1,10 @@
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.
actor: UnitTester
modules:
enabled:
- Asserts
- \Rinsvent\Data2DTODoctrineEntityBundle\Tests\Helper\Unit
step_decorators: ~
Loading…
Cancel
Save