Skip to content

Commit

Permalink
Merge branch 'symfony:2.x' into docs/live-components
Browse files Browse the repository at this point in the history
  • Loading branch information
Nayte91 authored Oct 14, 2024
2 parents 190d051 + 4df0129 commit ed408c2
Show file tree
Hide file tree
Showing 61 changed files with 245 additions and 1,015 deletions.
23 changes: 0 additions & 23 deletions .commit

This file was deleted.

47 changes: 0 additions & 47 deletions .notes

This file was deleted.

3 changes: 1 addition & 2 deletions src/Autocomplete/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/http-foundation": "^6.3|^7.0",
"symfony/http-kernel": "^6.3|^7.0",
"symfony/property-access": "^6.3|^7.0",
"symfony/string": "^6.3|^7.0"
"symfony/property-access": "^6.3|^7.0"
},
"require-dev": {
"doctrine/collections": "^1.6.8|^2.0",
Expand Down
4 changes: 0 additions & 4 deletions src/Autocomplete/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage in a Form (without Ajax)
------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/Autocomplete/src/AutocompleteBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class AutocompleteBundle extends Bundle
{
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new AutocompleteFormTypePass());
}
Expand Down
3 changes: 3 additions & 0 deletions src/Autocomplete/src/AutocompleterRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function getAutocompleter(string $alias): ?EntityAutocompleterInterface
return $this->autocompletersLocator->has($alias) ? $this->autocompletersLocator->get($alias) : null;
}

/**
* @return list<string>
*/
public function getAutocompleterNames(): array
{
return array_keys($this->autocompletersLocator->getProvidedServices());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
final class AutocompleteExtension extends Extension implements PrependExtensionInterface
{
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
$bundles = $container->getParameter('kernel.bundles');

Expand All @@ -61,7 +61,7 @@ public function prepend(ContainerBuilder $container)
}
}

public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$this->registerBasicServices($container);
if (ContainerBuilder::willBeAvailable('symfony/form', Form::class, ['symfony/framework-bundle'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class AutocompleteFormTypePass implements CompilerPassInterface
/** @var string Tag applied to EntityAutocompleterInterface classes */
public const ENTITY_AUTOCOMPLETER_TAG = 'ux.entity_autocompleter';

public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$this->processEntityAutocompleteFieldTag($container);
$this->processEntityAutocompleterTag($container);
}

private function processEntityAutocompleteFieldTag(ContainerBuilder $container)
private function processEntityAutocompleteFieldTag(ContainerBuilder $container): void
{
foreach ($container->findTaggedServiceIds(self::ENTITY_AUTOCOMPLETE_FIELD_TAG, true) as $serviceId => $tag) {
$serviceDefinition = $container->getDefinition($serviceId);
Expand Down Expand Up @@ -68,7 +68,7 @@ private function getAlias(string $serviceId, Definition $serviceDefinition, arra
return $attribute->getAlias() ?: AsEntityAutocompleteField::shortName($class);
}

private function processEntityAutocompleterTag(ContainerBuilder $container)
private function processEntityAutocompleterTag(ContainerBuilder $container): void
{
$servicesMap = [];
foreach ($container->findTaggedServiceIds(self::ENTITY_AUTOCOMPLETER_TAG, true) as $serviceId => $tag) {
Expand Down
18 changes: 14 additions & 4 deletions src/Autocomplete/src/Form/AsEntityAutocompleteField.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\UX\Autocomplete\Form;

use Symfony\Component\String\UnicodeString;

/**
* All form types that want to expose autocomplete functionality should have this.
*
Expand All @@ -37,13 +35,25 @@ public function getRoute(): string
return $this->route;
}

/**
* @internal
*
* @param class-string $class
*/
public static function shortName(string $class): string
{
$string = new UnicodeString($class);
if ($pos = (int) strrpos($class, '\\')) {
$class = substr($class, $pos + 1);
}

return $string->afterLast('\\')->snake()->toString();
return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $class));
}

/**
* @internal
*
* @param class-string $class
*/
public static function getInstance(string $class): ?self
{
$reflectionClass = new \ReflectionClass($class);
Expand Down
8 changes: 4 additions & 4 deletions src/Autocomplete/src/Maker/MakeAutocompleteField.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function getCommandDescription(): string
return 'Generates an Ajax-autocomplete form field class for symfony/ux-autocomplete.';
}

public function configureCommand(Command $command, InputConfiguration $inputConfig)
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(<<<EOF
Expand All @@ -66,12 +66,12 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
;
}

public function configureDependencies(DependencyBuilder $dependencies)
public function configureDependencies(DependencyBuilder $dependencies): void
{
$dependencies->addClassDependency(FormInterface::class, 'symfony/form');
}

public function interact(InputInterface $input, ConsoleStyle $io, Command $command)
public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
{
if (null === $this->doctrineHelper) {
throw new \LogicException('Somehow the DoctrineHelper service is missing from MakerBundle.');
Expand All @@ -94,7 +94,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
);
}

public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
{
if (null === $this->doctrineHelper) {
throw new \LogicException('Somehow the DoctrineHelper service is missing from MakerBundle.');
Expand Down
42 changes: 42 additions & 0 deletions src/Autocomplete/tests/Unit/Form/AsEntityAutocompleteFieldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\UX\Autocomplete\Tests\Unit\Form;

use PHPUnit\Framework\TestCase;
use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField;
use Symfony\UX\Autocomplete\Tests\Fixtures\Form\ProductType;

class AsEntityAutocompleteFieldTest extends TestCase
{
/**
* @dataProvider provideClassNames
*/
public function testShortName(string $shortName, string $className): void
{
$this->assertEquals($shortName, AsEntityAutocompleteField::shortName($className));
}

/**
* @return iterable<{string, string}>
*/
public static function provideClassNames(): iterable
{
yield from [
['as_entity_autocomplete_field', AsEntityAutocompleteField::class],
['product_type', ProductType::class],
['bar', 'Bar'],
['foo_bar', 'FooBar'],
['foo_bar', 'Foo\FooBar'],
['foo_bar', 'Foo\Bar\FooBar'],
];
}
}
7 changes: 0 additions & 7 deletions src/Chartjs/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage
-----

Expand Down Expand Up @@ -99,9 +95,6 @@ First, install the plugin:
$ npm install chartjs-plugin-zoom -D
# or use yarn
$ yarn add chartjs-plugin-zoom --dev
Then register the plugin globally. This can be done in your ``app.js`` file:

.. code-block:: javascript
Expand Down
4 changes: 0 additions & 4 deletions src/Cropperjs/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage
-----

Expand Down
4 changes: 0 additions & 4 deletions src/Dropzone/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage
-----

Expand Down
4 changes: 0 additions & 4 deletions src/LazyImage/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage
-----

Expand Down
4 changes: 0 additions & 4 deletions src/LiveComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
If your project is localized in different languages (either via the `locale route parameter`_
or by `setting the locale in the request`_) add the ``{_locale}`` attribute to
the UX Live Components route definition to keep the locale between re-renders:
Expand Down
4 changes: 0 additions & 4 deletions src/Notify/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage
-----

Expand Down
4 changes: 0 additions & 4 deletions src/React/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ Next, install a package to help React:
$ npm install -D @babel/preset-react --force
$ npm run watch
# or use yarn
$ yarn add @babel/preset-react --dev --force
$ yarn watch
That's it! Any files inside ``assets/react/controllers/`` can now be rendered as
React components.

Expand Down
7 changes: 0 additions & 7 deletions src/Svelte/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Install the bundle using Composer and Symfony Flex:
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
The Flex recipe will automatically set things up for you, like adding
``.enableSvelte()`` to your ``webpack.config.js`` file and adding code
to load your Svelte components inside ``assets/app.js``.
Expand All @@ -45,9 +41,6 @@ Next, install a package to help Svelte:
$ npm install svelte-loader --save-dev
# or use yarn
$ yarn add svelte-loader --dev
That's it! Any files inside ``assets/svelte/controllers/`` can now be rendered as
Svelte components.

Expand Down
4 changes: 0 additions & 4 deletions src/Swup/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage
-----

Expand Down
4 changes: 0 additions & 4 deletions src/TogglePassword/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ needed if you're using AssetMapper):
$ npm install --force
$ npm run watch
# or use yarn
$ yarn install --force
$ yarn watch
Usage with Symfony Forms
------------------------

Expand Down
Loading

0 comments on commit ed408c2

Please sign in to comment.