Skip to content

Commit

Permalink
Merge pull request #7 from BitBagCommerce/OPSRC355
Browse files Browse the repository at this point in the history
Opsrc355
  • Loading branch information
tbuczen authored Jan 20, 2022
2 parents 985a206 + 53c7e48 commit 55e0b22
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Entity/Agreement/AgreementsRequiredTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

trait AgreementsRequiredTrait
{
/** @var Collection|AgreementInterface[] */
/** @var ?Collection|AgreementInterface[] */
protected $agreements;

public function getAgreements(): ?Collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AgreementAutocompleteChoiceType extends AbstractType
Expand All @@ -23,12 +25,21 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}

public function buildView(
FormView $view,
FormInterface $form,
array $options
): void {
$view->vars['remote_criteria_type'] = 'contains';
$view->vars['remote_criteria_name'] = 'phrase';
}

/**
* @inheritdoc
*/
public function getBlockPrefix(): string
{
return 'bitbag_sylius_agreement_plugin_autocomplete_choice';
return 'bitbag_sylius_agreement_plugin_admin_ajax_agreement_choice';
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Form/Type/Agreement/Admin/AgreementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$contexts = $this->prepareContextsData();

$builder
->add('parent', AgreementAutocompleteChoiceType::class, [
->add('parent', TextType::class, [
'label' => 'bitbag_sylius_agreement_plugin.ui.agreement',
'resource' => 'bitbag_sylius_agreement_plugin.agreement',
'choice_name' => 'code',
'choice_value' => 'id',
])
->add('code', TextType::class, [
'label' => 'bitbag_sylius_agreement_plugin.ui.code',
Expand Down
3 changes: 1 addition & 2 deletions src/Resources/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
imports:
- { resource: "@SyliusAgreementPlugin/Resources/config/resources.yaml" }
- { resource: "@SyliusAgreementPlugin/Resources/config/grids/admin/agreement.yaml" }
- { resource: "@SyliusAgreementPlugin/Resources/config/grids/*/*.yaml" }

sylius_agreement:
extended_form_types:
Expand All @@ -15,4 +15,3 @@ sylius_agreement:
twig:
form_themes:
- '@SyliusAgreementPlugin/Form/agreement_approval_widget.html.twig'
- '@SyliusAgreementPlugin/Admin/Form/agreement_autocomplete_choice.html.twig'
3 changes: 0 additions & 3 deletions src/Resources/config/routes.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion src/Resources/config/routing/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bitbag_sylius_agreement_plugin_admin_agreement_archive:
parameters: {}

bitbag_sylius_agreement_plugin_admin_ajax_agreement_choice:
path: /agreements/new/search
path: /admin/agreement/search
methods: [GET]
defaults:
_controller: bitbag_sylius_agreement_plugin.controller.agreement:indexAction
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<service id="bitbag_sylius_agreement_plugin.form.type.agreement.admin.agreement_type"
class="BitBag\SyliusAgreementPlugin\Form\Type\Agreement\Admin\AgreementType">
<argument>%bitbag_sylius_agreement_plugin.model.agreement.class%</argument>
<argument type="service" id="bitbag_sylius_agreement_plugin.repository.agreement"/>
<argument>%bitbag_sylius_agreement_plugin.form.type.agreement.validation_groups%</argument>
<argument>%sylius_agreement_plugin.modes%</argument>
<argument>%sylius_agreement_plugin.contexts%</argument>
Expand All @@ -42,7 +43,7 @@

<service id="bitbag_sylius_agreement_plugin.form.type.agreement.shop.agreement_collection_type"
class="BitBag\SyliusAgreementPlugin\Form\Type\Agreement\Shop\AgreementCollectionType">
<argument type="service" id="bitbag_sylius_agreement_plugin.repository.agreement"/>
<argument type="service" id="bitbag_sylius_agreement_plugin.repository.agreement"/>
<tag name="form.type"/>
</service>

Expand Down Expand Up @@ -74,13 +75,12 @@
<service id="BitBag\SyliusAgreementPlugin\Resolver\AgreementHistory\OrderAgreementHistoryResolver">
<argument type="service" id="sylius.context.cart"/>
<tag name="bitbag_sylius_agreement_plugin.agreement_history_resolver" priority="0"/>
<argument type="service" id="bitbag_sylius_agreement_plugin.repository.agreement_history"/>
<argument type="service" id="BitBag\SyliusAgreementPlugin\Repository\AgreementHistoryRepository"></argument>
</service>

<service id="BitBag\SyliusAgreementPlugin\Resolver\AgreementHistory\ShopUserAgreementHistoryResolver">
<argument type="service" id="security.helper"/>
<argument type="service" id="bitbag_sylius_agreement_plugin.repository.agreement_history"/>
<tag name="bitbag_sylius_agreement_plugin.agreement_history_resolver" priority="10"/>
<argument type="service" id="BitBag\SyliusAgreementPlugin\Repository\AgreementHistoryRepository"></argument>
</service>

<service id="form.extension"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends '@SyliusUi/Form/theme.html.twig' %}

{% block bitbag_sylius_agreement_plugin_admin_ajax_agreement_choice %}
{{ form_row(form, {'remote_url': path('bitbag_sylius_agreement_plugin_admin_ajax_agreement_choice'), 'load_edit_url': path('bitbag_sylius_agreement_plugin_admin_agreement_index')}) }}
{{ form_row(form, {'remote_url': path('bitbag_sylius_agreement_plugin_admin_agreement_archive') }) }}
{% endblock %}
9 changes: 7 additions & 2 deletions tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ imports:

- { resource: "@SyliusAgreementPlugin/Resources/config/config.yaml" }

- { resource: "../../src/Resources/config/config.yaml" }

parameters:
sylius_core.public_dir: '%kernel.project_dir%/public'

sylius_shop:
product_grid:
include_all_descendants: true

sylius_customer:
resources:
customer:
classes:
model: Tests\BitBag\SyliusAgreementPlugin\Entity\Customer\Customer

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Tests\BitBag\SyliusAgreementPlugin\Entity\Customer;

use BitBag\SyliusAgreementPlugin\Entity\Agreement\AgreementsRequiredInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Sylius\Component\Core\Model\CustomerInterface as BaseCustomerInterface;

interface CustomerInterface extends BaseCustomerInterface, AgreementsRequiredInterface
Expand Down
5 changes: 0 additions & 5 deletions tests/Application/src/Resources/config/config.yaml

This file was deleted.

0 comments on commit 55e0b22

Please sign in to comment.