-
Notifications
You must be signed in to change notification settings - Fork 33
Remove autowiring #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove autowiring #285
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,26 +4,35 @@ | |
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<defaults autowire="true" autoconfigure="true" /> | ||
<service id="meilisearch.engine" class="Meilisearch\Bundle\Engine"> | ||
<argument type="service" id="meilisearch.client" /> | ||
</service> | ||
|
||
<prototype namespace="Meilisearch\Bundle\Command\" resource="../src/Command" /> | ||
<!-- After bumping to Symfony >5.1 deeprecate public services into private services --> | ||
<service id="meilisearch.service" class="Meilisearch\Bundle\Services\MeilisearchService" public="true"> | ||
<argument /><!-- After bumping to Symfony 5.1 use type="abstract" --> | ||
<argument type="service" id="meilisearch.engine" /> | ||
<argument type="collection" /><!-- After bumping to Symfony 5.1 use type="abstract" --> | ||
<argument type="service" id="property_accessor" /> | ||
</service> | ||
<service id="search.service" alias="meilisearch.service" public="true"> | ||
<deprecated package="meilisearch/search-bundle" version="0.14">The "%alias_id%" service alias is deprecated. Use "meilisearch.service" instead.</deprecated> | ||
</service> | ||
|
||
<service id="meilisearch.search_indexer_subscriber" | ||
class="Meilisearch\Bundle\EventListener\DoctrineEventSubscriber" | ||
public="true"> | ||
<service id="meilisearch.search_indexer_subscriber" class="Meilisearch\Bundle\EventListener\DoctrineEventSubscriber" public="true"> | ||
<argument type="service" id="meilisearch.service" /> | ||
</service> | ||
<service id="search.search_indexer_subscriber" alias="meilisearch.search_indexer_subscriber"> | ||
<deprecated package="meilisearch/search-bundle" version="0.14">The "%alias_id%" service alias is deprecated. Use "meilisearch.search_indexer_subscriber" instead.</deprecated> | ||
</service> | ||
|
||
<service id="meilisearch.client" class="Meilisearch\Client" public="true" lazy="true"> | ||
<argument key="$url">%meili_url%</argument> | ||
<argument key="$apiKey">%meili_api_key%</argument> | ||
<argument key="$httpClient" type="service" id="psr18.http_client" on-invalid="ignore" /> | ||
<argument key="$clientAgents" type="collection"> | ||
<argument>%meili_symfony_version%</argument> | ||
</argument> | ||
<argument /><!-- url --> | ||
<argument /><!-- api key --> | ||
<argument type="service" id="psr18.http_client" on-invalid="ignore" /><!-- http client --> | ||
<argument>null</argument><!-- request factory --> | ||
<argument /><!-- client agents --> | ||
<argument>null</argument><!-- stream factory --> | ||
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to rework this as something was not right on Symfony 5.4: |
||
</service> | ||
<service id="search.client" alias="meilisearch.client" public="true"> | ||
<deprecated package="meilisearch/search-bundle" version="0.14">The "%alias_id%" service alias is deprecated. Use "meilisearch.client" instead.</deprecated> | ||
|
@@ -34,5 +43,28 @@ | |
<deprecated package="meilisearch/search-bundle" version="0.14">The "%alias_id%" service alias is deprecated. Use "meilisearch.client" instead.</deprecated> | ||
</service> | ||
<service id="Meilisearch\Bundle\SearchService" alias="meilisearch.service" /> | ||
|
||
<service id="Meilisearch\Bundle\Command\MeilisearchClearCommand"> | ||
<argument type="service" id="meilisearch.service" /> | ||
<tag name="console.command" /> | ||
</service> | ||
|
||
<service id="Meilisearch\Bundle\Command\MeilisearchCreateCommand"> | ||
<argument type="service" id="meilisearch.service" /> | ||
<argument type="service" id="meilisearch.client" /> | ||
<tag name="console.command" /> | ||
</service> | ||
|
||
<service id="Meilisearch\Bundle\Command\MeilisearchDeleteCommand"> | ||
<argument type="service" id="meilisearch.service" /> | ||
<tag name="console.command" /> | ||
</service> | ||
|
||
<service id="Meilisearch\Bundle\Command\MeilisearchImportCommand"> | ||
<argument type="service" id="meilisearch.service" /> | ||
<argument type="service" id="doctrine" /> | ||
<argument type="service" id="meilisearch.client" /> | ||
<tag name="console.command" /> | ||
</service> | ||
</services> | ||
</container> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,15 @@ | |
use Meilisearch\Bundle\SearchService; | ||
use Symfony\Component\Config\Definition\Exception\Exception; | ||
use Symfony\Component\PropertyAccess\PropertyAccess; | ||
use Symfony\Component\PropertyAccess\PropertyAccessor; | ||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
final class MeilisearchService implements SearchService | ||
{ | ||
private NormalizerInterface $normalizer; | ||
private Engine $engine; | ||
private Collection $configuration; | ||
private PropertyAccessor $propertyAccessor; | ||
private PropertyAccessorInterface $propertyAccessor; | ||
/** | ||
* @var list<class-string> | ||
*/ | ||
|
@@ -42,12 +42,12 @@ final class MeilisearchService implements SearchService | |
private array $classToSerializerGroup; | ||
private array $indexIfMapping; | ||
|
||
public function __construct(NormalizerInterface $normalizer, Engine $engine, array $configuration) | ||
public function __construct(NormalizerInterface $normalizer, Engine $engine, array $configuration, PropertyAccessorInterface $propertyAccessor = null) | ||
{ | ||
$this->normalizer = $normalizer; | ||
$this->engine = $engine; | ||
$this->configuration = new Collection($configuration); | ||
$this->propertyAccessor = PropertyAccess::createPropertyAccessor(); | ||
$this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Symfony defines a property accessor already, so we can inject it through DI. |
||
|
||
$this->setSearchableEntities(); | ||
$this->setAggregatorsAndEntitiesAggregators(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, now we don't need to add the
key=""
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the
src/DependencyInjection/MeilisearchExtension.php
, I saw that you are changing to use a positional instead of a named argument. How is this better?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After PR, I left the comment about it :) #285 (comment)