Skip to content

Commit a20092c

Browse files
committed
Update from internal 0.10 release
1 parent 4482c01 commit a20092c

File tree

160 files changed

+1008
-528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+1008
-528
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
tests/Resources/app/cache/
66
tests/Resources/app/data/
77
tests/Resources/app/logs/
8-
docker-compose.override.yml
8+
docker-compose.override.yml
9+
/.php_cs.cache

.gitlab-ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
variables:
2+
COMPOSE_PROJECT_NAME: "jsonapibundle${CI_BUILD_ID}"
3+
4+
stages:
5+
- test
6+
- lint
7+
8+
after_script:
9+
- cd tests/Resources/docker/
10+
- echo "Fixing permissions after docker..."
11+
- bin/php chmod -R 0777 ../../../*
12+
- docker-compose down
13+
- echo "All Done!"
14+
15+
ci:
16+
stage: test
17+
tags:
18+
- docker-compose
19+
script:
20+
- cd tests/Resources/docker/
21+
- bin/build.sh
22+
- bin/setup_fixtures.sh
23+
- docker-compose run --no-deps --rm php php vendor/bin/phpunit --debug --colors=never --coverage-text=php://stdout --coverage-html=logs/coverage
24+
- bin/php php ../../../vendor/bin/security-checker security:check ../../../composer.lock
25+
26+
lint:
27+
stage: lint
28+
tags:
29+
- docker-compose
30+
script:
31+
- cd tests/Resources/docker/
32+
- bin/build.sh
33+
- bin/php_cs --dry-run --using-cache=no

.php_cs.dist

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->name('console')
7+
->in([
8+
__DIR__ . '/src',
9+
__DIR__ . '/tests',
10+
])
11+
;
12+
13+
return PhpCsFixer\Config::create()
14+
->setUsingCache(true)
15+
->setRules([
16+
'@PSR2' => true,
17+
'@Symfony' => true,
18+
'@Symfony:risky' => true,
19+
'@DoctrineAnnotation' => true,
20+
'concat_space' => ['spacing' => 'one'],
21+
'array_syntax' => ['syntax' => 'short'],
22+
'list_syntax' => ['syntax' => 'short'],
23+
'no_empty_phpdoc' => false,
24+
'phpdoc_align' => '',
25+
'phpdoc_no_empty_return' => false,
26+
'phpdoc_summary' => false,
27+
'ordered_imports' => [
28+
'sortAlgorithm' => OrderedImportsFixer::SORT_ALPHA,
29+
'importsOrder' => [
30+
OrderedImportsFixer::IMPORT_TYPE_CONST,
31+
OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
32+
OrderedImportsFixer::IMPORT_TYPE_CLASS,
33+
],
34+
],
35+
'class_definition' => ['multiLineExtendsEachSingleLine' => true],
36+
'ternary_to_null_coalescing' => true,
37+
'yoda_style' => true,
38+
'compact_nullable_typehint' => true,
39+
'visibility_required' => true,
40+
])
41+
->setRiskyAllowed(true)
42+
->setFinder($finder)
43+
;

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Json Api CRUD Bundle
22

3+
[![pipeline status](https://gitlab.trikoder.net/trikoder/jsonapibundle/badges/master/pipeline.svg)](https://gitlab.trikoder.net/trikoder/jsonapibundle/commits/master)
4+
[![coverage report](https://gitlab.trikoder.net/trikoder/jsonapibundle/badges/master/coverage.svg)](https://gitlab.trikoder.net/trikoder/jsonapibundle/commits/master)
5+
36
Package to provide out-of-the box support for jsonapi in symfony with as native as possible way.
47

58
# Under development
@@ -51,9 +54,36 @@ This will build whole docker setup, load fixtures and run all test suites.
5154

5255
For development of the package, we are using the same tools as for testing.
5356
Position yourself inside `tests/Resources/docker` and run `bin/start.sh`
54-
PHP cli commands can be run from same directory using `bin/console`.
57+
PHP cli commands can be run from same directory using `bin/console`.
5558
There is also php access script `bin/php [CMD]` (eg. `bin/php bash` to enter bash).
5659

60+
### Coding standards
61+
62+
When contributing to this package, you will need to adhere to our conding standards.
63+
They are following PSR-2 with some additional rules. To check your code during development
64+
you can use provided config for php-cs-fixer. it's in root of the project, file:
65+
66+
`.php_cs.dist`
67+
68+
**Checking your code**
69+
70+
First you need to setup test enviroment (as described in paragraph above).
71+
72+
Then:
73+
74+
Checking code:
75+
76+
```
77+
bin/php_cs --dry-run
78+
```
79+
If you want automatic fix, just ommit ``--dry-run`:
80+
81+
```
82+
bin/php_cs
83+
```
84+
This will check and fix your code.
85+
86+
5787
## Credits
5888

5989
Copyright (C) 2017 Trikoder

UPGRADE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
11
# Upgrade Guide
22

33
This file provides notes on how to upgrade between versions.
4+
5+
6+
# Upgrade from v0.9.*
7+
8+
## Bundle changes
9+
- bundle moves to support symfony 4 with default private services and autowiring
10+
- changes in demo code to reflect `controllers as services` change
11+
12+
## Schema autowiring
13+
!NOTE - change described below will be updated in future version with option to have bundle perform this action automatically by scaning your schemas..
14+
To use any non public services in your schemas, you must redefine `Trikoder\JsonApiBundle\Services\Neomerx\ServiceContainer` and call `set` for each of used service, ie:
15+
```yaml
16+
Trikoder\JsonApiBundle\Services\Neomerx\ServiceContainer:
17+
calls:
18+
- method: set
19+
arguments:
20+
- 'Symfony\Component\Routing\RouterInterface'
21+
- '@router'
22+
```
23+
24+
## Service definitions
25+
All services should use Interface hinting names as described by Symfony documentation on autowiring. https://symfony.com/doc/current/service_container/autowiring.html
26+
Bundle defines aliases for old naming to keep compatibility with existing implementations.
27+
This will be removed in later version.
28+
29+
## Abstract controller
30+
1. No longer inherits `Symfony\Bundle\FrameworkBundle\Controller\Controller` but instead moves to be `Controller as Service`.
31+
2. It defines required setter injection for several services listed below. NOTE - this is subject to change in future versions
32+
`setSchemaClassMapProvider` in abstract controller, and usage of trait `\Trikoder\JsonApiBundle\Controller\Traits\Polyfill\SymfonyAutowiredServicesTrait`

composer.json

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,35 @@
33
"description": "Json API bundle for Symfony",
44
"type": "symfony-bundle",
55
"require": {
6-
"php": ">=7.0.0",
7-
"symfony/framework-bundle": "^3.1",
6+
"php": ">=7.0.0|>=7.1.0",
7+
"symfony/framework-bundle": "^3.1|^4.0",
8+
"symfony/dependency-injection": "^3.1|^4.0",
89
"neomerx/json-api": "^1.0",
9-
"doctrine/orm": "~2.4,<2.5|^2.5",
10-
"doctrine/doctrine-bundle": "~1.6",
11-
"sensio/framework-extra-bundle": "^3.0",
12-
"symfony/form": "^3.1",
13-
"symfony/translation": "^3.3",
14-
"symfony/validator": "^3.3",
10+
"doctrine/orm": "~2.4,<2.5|2.5|^2.6",
11+
"doctrine/doctrine-bundle": "~1.6|^1.8",
12+
"sensio/framework-extra-bundle": "^3.0|^5.1",
13+
"symfony/form": "^3.1|^4.0",
14+
"symfony/translation": "^3.3|^4.0",
15+
"symfony/validator": "^3.3|^4.0",
1516
"symfony/monolog-bundle": "^3.1"
1617
},
1718
"require-dev": {
18-
"sensio/generator-bundle": "^3.0",
19+
"sensio/generator-bundle": "3.0.*|3.1.*|3.2.*|3.3.*",
1920
"phpunit/phpunit": "^5.7",
2021
"phpunit/php-code-coverage": "^4.0",
21-
"symfony/phpunit-bridge": "^3.0",
22+
"symfony/phpunit-bridge": "^3.0|^4.0",
2223
"justinrainbow/json-schema": "^1.6",
2324
"doctrine/doctrine-fixtures-bundle": "^2.3",
2425
"fzaninotto/faker": "^1.5",
2526
"sensiolabs/security-checker": "^4.1",
26-
"symfony/security-bundle": "^3.1",
27-
"symfony/twig-bundle": "^3.3",
27+
"symfony/security-bundle": "^3.1|^4.0",
28+
"symfony/twig-bundle": "^3.3|^4.0",
2829
"doctrine/cache": "^1.6",
29-
"symfony/debug-bundle": "^3.3",
30-
"symfony/web-profiler-bundle": "^3.3",
31-
"symfony/web-server-bundle": "^3.3",
32-
"symfony/browser-kit": "^3.3"
30+
"symfony/debug-bundle": "^3.3|^4.0",
31+
"symfony/web-profiler-bundle": "^3.3|^4.0",
32+
"symfony/web-server-bundle": "^3.3|^4.0",
33+
"symfony/browser-kit": "^3.3|^4.0",
34+
"friendsofphp/php-cs-fixer": "^2.8"
3335
},
3436
"autoload": {
3537
"psr-4": {
@@ -39,7 +41,10 @@
3941
"autoload-dev": {
4042
"psr-4": {
4143
"Trikoder\\JsonApiBundle\\Tests\\": "tests/"
42-
}
44+
},
45+
"files": [
46+
"tests/Resources/app/AppKernel.php"
47+
]
4348
},
4449
"authors": [
4550
{

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
>
1010
<php>
1111
<server name="KERNEL_DIR" value="tests/Resources/app" />
12+
<server name="KERNEL_CLASS" value="\AppKernel" />
1213
</php>
1314
<testsuites>
1415
<testsuite name="Unit">

src/Bridge/Doctrine/DoctrineRepository.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/**
1010
* Class DoctrineRepository
11-
* @package Trikoder\JsonApiBundle\Bridge\Doctrine
1211
*/
1312
class DoctrineRepository implements RepositoryInterface
1413
{
@@ -23,6 +22,7 @@ class DoctrineRepository implements RepositoryInterface
2322

2423
/**
2524
* DoctrineRepository constructor.
25+
*
2626
* @param EntityRepository $entityRepository
2727
* @param EntityManager $entityManager
2828
*/
@@ -33,7 +33,7 @@ public function __construct(EntityRepository $entityRepository, EntityManager $e
3333
}
3434

3535
/**
36-
* @inheritdoc
36+
* {@inheritdoc}
3737
*/
3838
public function getList($filter = [], $sort = [], $limit = null, $offset = null)
3939
{
@@ -47,17 +47,18 @@ public function getList($filter = [], $sort = [], $limit = null, $offset = null)
4747
}
4848

4949
/**
50-
* @inheritdoc
50+
* {@inheritdoc}
5151
*/
5252
public function getOne($id, $filter = [])
5353
{
5454
// TODO - this should check which fields is indentifier
5555
$filter['id'] = $id;
56+
5657
return $this->entityRepository->findOneBy($filter);
5758
}
5859

5960
/**
60-
* @inheritdoc
61+
* {@inheritdoc}
6162
*/
6263
public function save($model)
6364
{

src/Bridge/Doctrine/ObjectListCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ObjectListCollection implements ObjectListCollectionInterface
1919

2020
/**
2121
* ObjectListCollection constructor.
22+
*
2223
* @param array $collection
2324
* @param null $total
2425
*/

src/Bridge/Doctrine/RepositoryFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class RepositoryFactory implements RepositoryFactoryInterface
1515

1616
/**
1717
* RepositoryFactory constructor.
18+
*
1819
* @param EntityManager $entityManager
1920
*/
2021
public function __construct(EntityManager $entityManager)
@@ -24,9 +25,10 @@ public function __construct(EntityManager $entityManager)
2425

2526
/**
2627
* @param string $modelClass
28+
*
2729
* @return RepositoryInterface
2830
*/
29-
public function create(string $modelClass) : RepositoryInterface
31+
public function create(string $modelClass): RepositoryInterface
3032
{
3133
return new DoctrineRepository(
3234
$this->entityManager->getRepository($modelClass),

0 commit comments

Comments
 (0)