Skip to content

Commit 6e45783

Browse files
committed
mongo removed xml php config
1 parent 55f53db commit 6e45783

File tree

13 files changed

+109
-68
lines changed

13 files changed

+109
-68
lines changed

src/Laravel/Eloquent/Serializer/EloquentNameConverter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function __construct(private readonly NameConverterInterface $nameConvert
2828
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
2929
{
3030
try {
31-
return $this->nameConverter->normalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
31+
return $this->nameConverter->normalize($propertyName, $class, $format, $context);
3232
} catch (UnexpectedPropertyException $e) {
33-
return $this->nameConverter->denormalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
33+
return $this->nameConverter->denormalize($propertyName, $class, $format, $context);
3434
}
3535
}
3636

@@ -40,9 +40,9 @@ public function normalize(string $propertyName, ?string $class = null, ?string $
4040
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
4141
{
4242
try {
43-
return $this->nameConverter->denormalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
43+
return $this->nameConverter->denormalize($propertyName, $class, $format, $context);
4444
} catch (UnexpectedPropertyException $e) {
45-
return $this->nameConverter->normalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
45+
return $this->nameConverter->normalize($propertyName, $class, $format, $context);
4646
}
4747
}
4848
}

src/Laravel/Eloquent/Serializer/Mapping/Loader/RelationMetadataLoader.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
6666
$attribute = $a->newInstance();
6767

6868
match (true) {
69-
$attribute instanceof Groups => array_map([$attributeMetadata, 'addGroup'], $attribute->getGroups()),
70-
$attribute instanceof MaxDepth => $attributeMetadata->setMaxDepth($attribute->getMaxDepth()),
71-
$attribute instanceof SerializedName => $attributeMetadata->setSerializedName($attribute->getSerializedName()),
72-
$attribute instanceof SerializedPath => $attributeMetadata->setSerializedPath($attribute->getSerializedPath()),
69+
$attribute instanceof Groups => array_map([$attributeMetadata, 'addGroup'], $attribute->groups),
70+
$attribute instanceof MaxDepth => $attributeMetadata->setMaxDepth($attribute->maxDepth),
71+
$attribute instanceof SerializedName => $attributeMetadata->setSerializedName($attribute->serializedName),
72+
$attribute instanceof SerializedPath => $attributeMetadata->setSerializedPath($attribute->serializedPath),
7373
$attribute instanceof Ignore => $attributeMetadata->setIgnore(true),
7474
$attribute instanceof Context => $this->setAttributeContextsForGroups($attribute, $attributeMetadata),
7575
default => null,
@@ -82,10 +82,11 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
8282

8383
private function setAttributeContextsForGroups(Context $annotation, AttributeMetadataInterface $attributeMetadata): void
8484
{
85-
$context = $annotation->getContext();
86-
$groups = $annotation->getGroups();
87-
$normalizationContext = $annotation->getNormalizationContext();
88-
$denormalizationContext = $annotation->getDenormalizationContext();
85+
$context = $annotation->context;
86+
$groups = $annotation->groups;
87+
$normalizationContext = $annotation->normalizationContext;
88+
$denormalizationContext = $annotation->denormalizationContext;
89+
8990
if ($normalizationContext || $context) {
9091
$attributeMetadata->setNormalizationContextForGroups($normalizationContext ?: $context, $groups);
9192
}

src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public function testConvertLegacyTypesToType(?Type $type, ?array $legacyTypes):
4444
*/
4545
public static function convertLegacyTypesToTypeDataProvider(): iterable
4646
{
47+
if (!class_exists(LegacyType::class)) {
48+
return [];
49+
}
50+
4751
yield [null, null];
4852
yield [Type::null(), [new LegacyType('null')]];
4953
// yield [Type::void(), [new LegacyType('void')]];
@@ -78,6 +82,10 @@ public function testConvertTypeToLegacyTypes(?array $legacyTypes, ?Type $type):
7882
*/
7983
public static function convertTypeToLegacyTypesDataProvider(): iterable
8084
{
85+
if (!class_exists(LegacyType::class)) {
86+
return [];
87+
}
88+
8189
yield [null, null];
8290
yield [null, Type::mixed()];
8391
yield [null, Type::never()];
@@ -105,11 +113,4 @@ public static function convertTypeToLegacyTypesDataProvider(): iterable
105113
];
106114
yield [[new LegacyType('object', false, \Stringable::class), new LegacyType('object', false, \Traversable::class)], Type::intersection(Type::object(\Traversable::class), Type::object(\Stringable::class))];
107115
}
108-
109-
protected function setUp(): void
110-
{
111-
if (!class_exists(LegacyType::class)) {
112-
$this->markTestSkipped();
113-
}
114-
}
115116
}

tests/Fixtures/app/config/reference.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the API Platform project.
5-
*
6-
* (c) Kévin Dunglas <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
12-
declare(strict_types=1);
13-
143
// This file is auto-generated and is for apps only. Bundles SHOULD NOT rely on its content.
154

165
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
@@ -464,8 +453,8 @@
464453
* platform_service?: scalar|null, // Deprecated: The "platform_service" configuration key is deprecated since doctrine-bundle 2.9. DBAL 4 will not support setting a custom platform via connection params anymore.
465454
* auto_commit?: bool,
466455
* schema_filter?: scalar|null,
467-
* logging?: bool, // Default: true
468-
* profiling?: bool, // Default: true
456+
* logging?: bool, // Default: false
457+
* profiling?: bool, // Default: false
469458
* profiling_collect_backtrace?: bool, // Enables collecting backtraces when profiling is enabled // Default: false
470459
* profiling_collect_schema_errors?: bool, // Enables collecting schema errors when profiling is enabled // Default: true
471460
* disable_type_comments?: bool,
@@ -604,7 +593,7 @@
604593
* pool?: scalar|null,
605594
* },
606595
* region_lock_lifetime?: scalar|null, // Default: 60
607-
* log_enabled?: bool, // Default: true
596+
* log_enabled?: bool, // Default: false
608597
* region_lifetime?: scalar|null, // Default: 3600
609598
* enabled?: bool, // Default: true
610599
* factory?: scalar|null,
@@ -997,7 +986,7 @@
997986
* http_method_override?: bool, // Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. // Default: false
998987
* allowed_http_method_override?: list<string>|null,
999988
* trust_x_sendfile_type_header?: scalar|null, // Set true to enable support for xsendfile in binary file responses. // Default: "%env(bool:default::SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER)%"
1000-
* ide?: scalar|null, // Default: "%env(default::SYMFONY_IDE)%"
989+
* ide?: scalar|null, // Default: null
1001990
* test?: bool,
1002991
* default_locale?: scalar|null, // Default: "en"
1003992
* set_locale_from_accept_language?: bool, // Whether to use the Accept-Language HTTP header to set the Request locale (only when the "_locale" request attribute is not passed). // Default: false
@@ -1154,7 +1143,7 @@
11541143
* paths?: array<string, scalar|null>,
11551144
* excluded_patterns?: list<scalar|null>,
11561145
* exclude_dotfiles?: bool, // If true, any files starting with "." will be excluded from the asset mapper. // Default: true
1157-
* server?: bool, // If true, a "dev server" will return the assets from the public directory (true in "debug" mode only by default). // Default: true
1146+
* server?: bool, // If true, a "dev server" will return the assets from the public directory (true in "debug" mode only by default). // Default: false
11581147
* public_prefix?: scalar|null, // The public path where the assets will be written to (and served from when "server" is true). // Default: "/assets/"
11591148
* missing_import_mode?: "strict"|"warn"|"ignore", // Behavior if an asset cannot be found when imported from JavaScript or CSS files - e.g. "import './non-existent.js'". "strict" means an exception is thrown, "warn" means a warning is logged, "ignore" means the import is left as-is. // Default: "warn"
11601149
* extensions?: array<string, scalar|null>,
@@ -1274,7 +1263,7 @@
12741263
* },
12751264
* php_errors?: array{ // PHP errors handling configuration
12761265
* log?: mixed, // Use the application logger instead of the PHP logger for logging PHP errors. // Default: true
1277-
* throw?: bool, // Throw PHP errors as \ErrorException instances. // Default: true
1266+
* throw?: bool, // Throw PHP errors as \ErrorException instances. // Default: false
12781267
* },
12791268
* exceptions?: array<string, array{ // Default: []
12801269
* log_level?: scalar|null, // The level of log message. Null to let Symfony decide. // Default: null
@@ -1337,7 +1326,7 @@
13371326
* scheduler?: bool|array{ // Scheduler configuration
13381327
* enabled?: bool, // Default: false
13391328
* },
1340-
* disallow_search_engine_index?: bool, // Enabled by default when debug is enabled. // Default: true
1329+
* disallow_search_engine_index?: bool, // Enabled by default when debug is enabled. // Default: false
13411330
* http_client?: bool|array{ // HTTP Client configuration
13421331
* enabled?: bool, // Default: true
13431332
* max_host_connections?: int, // The maximum number of connections to a single host.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
_main:
2-
resource: routing_test.yml
2+
resource: routing_test.php
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
15+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
16+
17+
return function (RoutingConfigurator $routes) {
18+
$routes->import('routing_common.yml');
19+
$routes->import('@TestBundle/Controller/MongoDbOdm', 'attribute');
20+
21+
if (class_exists(WebProfilerBundle::class)) {
22+
// 2. Resolve the actual directory of the bundle
23+
$reflection = new ReflectionClass(WebProfilerBundle::class);
24+
$bundleDir = dirname($reflection->getFileName());
25+
26+
// 3. Check if the PHP config exists on the filesystem
27+
$usePhp = file_exists($bundleDir.'/Resources/config/routing/wdt.php');
28+
$ext = $usePhp ? 'php' : 'xml';
29+
30+
// 4. Import dynamically based on the extension found
31+
$routes->import("@WebProfilerBundle/Resources/config/routing/wdt.$ext")
32+
->prefix('/_wdt');
33+
34+
$routes->import("@WebProfilerBundle/Resources/config/routing/profiler.$ext")
35+
->prefix('/_profiler');
36+
}
37+
};
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
_main:
2-
resource: routing_common.yml
3-
4-
controller:
5-
resource: '@TestBundle/Controller/MongoDbOdm'
6-
type: attribute
7-
8-
web_profiler_wdt:
9-
resource: '@WebProfilerBundle/Resources/config/routing/wdt.php'
10-
prefix: /_wdt
11-
12-
web_profiler_profiler:
13-
resource: '@WebProfilerBundle/Resources/config/routing/profiler.php'
14-
prefix: /_profiler
2+
resource: routing_mongodb.php
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
_main:
2-
resource: routing_test.yml
2+
resource: routing_test.php
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
_main:
2-
resource: routing_test.yml
2+
resource: routing_test.php
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
_main:
2-
resource: routing_test.yml
2+
resource: routing_test.php

0 commit comments

Comments
 (0)