2017-04-20 5 views
0

私はチュートリアル[リンクの説明を入力してくださいhereに従ってください。Sylius - カスタムプロモーションアクションを追加するにはどうすればよいですか?

私はこのアクションでプロモーションを追加しようとすると、しかし、私はこのエラーを取得:さらに調査時

Could not load type "AppBundle\Promotion\Action\CheapestProductDiscountPromotionActionCommand" 

CheapestProductDiscountPromotionActionCommand.phpFormRegistry.php次のコードブロックを通過:

if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) { 
    $type = new $name(); 
} else { 
    throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name)); 
} 

私が集めることのできるところから、CheapestProductDiscountPromotionActionCommand.phpFormTypeInterfaceを実装しているかどうかを確認していますが、なぜ完全にわからないのですか?私はCheapestProductDiscountConfigurationTypeAbstractTypeに拡張し、FormTypeInterfaceを実装すると考えましたか?たぶん私は間違っているが、私は上記のコードブロックを通過するべきではないと考えているだろうCheapestProductDiscountPromotionActionCommand.php

次のように私のスタックトレースは次のとおりです。

Stack Trace 

    in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php at line 87 + 

    at FormRegistry ->getType ('AppBundle\\Promotion\\Action\\CheapestProductDiscountPromotionActionCommand') 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 83 + 

    at FormFactory ->createNamedBuilder ('UK_WEB', 'AppBundle\\Promotion\\Action\\CheapestProductDiscountPromotionActionCommand', array(), array('auto_initialize' => false, 'label' => 'UK Web Store', 'currency' => 'GBP')) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 47 + 

    at FormFactory ->createNamed ('UK_WEB', 'AppBundle\\Promotion\\Action\\CheapestProductDiscountPromotionActionCommand', array(), array('auto_initialize' => false, 'label' => 'UK Web Store', 'currency' => 'GBP')) 
    in vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/Form/EventSubscriber/BuildChannelBasedPromotionActionFormSubscriber.php at line 114 + 

    at BuildChannelBasedPromotionActionFormSubscriber ->createConfigurationFieldForChannel (object(Channel), 'AppBundle\\Promotion\\Action\\CheapestProductDiscountPromotionActionCommand', array()) 
    in vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/Form/EventSubscriber/BuildChannelBasedPromotionActionFormSubscriber.php at line 74 + 

    at BuildChannelBasedPromotionActionFormSubscriber ->addConfigurationFields (object(Form), 'cheapest_product_discount', array()) 
    in vendor/sylius/sylius/src/Sylius/Bundle/PromotionBundle/Form/EventListener/AbstractConfigurationSubscriber.php at line 72 + 

    at AbstractConfigurationSubscriber ->preSetData (object(FormEvent), 'form.pre_set_data', object(EventDispatcher)) 

    at call_user_func (array(object(BuildChannelBasedPromotionActionFormSubscriber), 'preSetData'), object(FormEvent), 'form.pre_set_data', object(EventDispatcher)) 

    in vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php at line 174 + 

    at EventDispatcher ->doDispatch (array(array(object(BuildChannelBasedPromotionActionFormSubscriber), 'preSetData')), 'form.pre_set_data', object(FormEvent)) 
    in vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php at line 43 + 

    at EventDispatcher ->dispatch ('form.pre_set_data', object(FormEvent)) 
    in vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php at line 43 + 

    at ImmutableEventDispatcher ->dispatch ('form.pre_set_data', object(FormEvent)) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/Form.php at line 341 + 

    at Form ->setData (null) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/Form.php at line 477 + 

    at Form ->initialize() 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 226 + 

    at FormBuilder ->getForm() 
    in vendor/sylius/sylius/src/Sylius/Bundle/PromotionBundle/Form/Type/Core/AbstractConfigurationCollectionType.php at line 54 + 

    at AbstractConfigurationCollectionType ->buildForm (object(FormBuilder), array('block_name' => null, 'disabled' => false, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'required' => true, 'property_path' => null, 'mapped' => true, 'by_reference' => false, 'inherit_data' => false, 'compound' => true, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', 'entry_type' => 'Sylius\\Bundle\\PromotionBundle\\Form\\Type\\PromotionActionType', 'delete_empty' => false, 'button_delete_label' => 'sylius.form.collection.delete', 'label' => 'sylius.form.promotion.actions', 'attr' => array(), 'data_class' => null, 'empty_data' => object(Closure), 'error_bubbling' => true, 'label_attr' => array(), 'upload_max_size_message' => object(Closure), 'validation_groups' => null, 'constraints' => array(), 'entry_options' => array('block_name' => 'entry'), 'button_add_label' => 'sylius.form.promotion.add_action')) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php at line 126 + 

    at ResolvedFormType ->buildForm (object(FormBuilder), array('block_name' => null, 'disabled' => false, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'required' => true, 'property_path' => null, 'mapped' => true, 'by_reference' => false, 'inherit_data' => false, 'compound' => true, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', 'entry_type' => 'Sylius\\Bundle\\PromotionBundle\\Form\\Type\\PromotionActionType', 'delete_empty' => false, 'button_delete_label' => 'sylius.form.collection.delete', 'label' => 'sylius.form.promotion.actions', 'attr' => array(), 'data_class' => null, 'empty_data' => object(Closure), 'error_bubbling' => true, 'label_attr' => array(), 'upload_max_size_message' => object(Closure), 'validation_groups' => null, 'constraints' => array(), 'entry_options' => array('block_name' => 'entry'), 'button_add_label' => 'sylius.form.promotion.add_action')) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php at line 102 + 

    at ResolvedTypeDataCollectorProxy ->buildForm (object(FormBuilder), array('block_name' => null, 'disabled' => false, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'required' => true, 'property_path' => null, 'mapped' => true, 'by_reference' => false, 'inherit_data' => false, 'compound' => true, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', 'entry_type' => 'Sylius\\Bundle\\PromotionBundle\\Form\\Type\\PromotionActionType', 'delete_empty' => false, 'button_delete_label' => 'sylius.form.collection.delete', 'label' => 'sylius.form.promotion.actions', 'attr' => array(), 'data_class' => null, 'empty_data' => object(Closure), 'error_bubbling' => true, 'label_attr' => array(), 'upload_max_size_message' => object(Closure), 'validation_groups' => null, 'constraints' => array(), 'entry_options' => array('block_name' => 'entry'), 'button_add_label' => 'sylius.form.promotion.add_action')) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 89 + 

    at FormFactory ->createNamedBuilder ('actions', 'Sylius\\Bundle\\PromotionBundle\\Form\\Type\\PromotionActionCollectionType', null, array('label' => 'sylius.form.promotion.actions', 'button_add_label' => 'sylius.form.promotion.add_action')) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 106 + 

    at FormBuilder ->create ('actions', 'Sylius\\Bundle\\PromotionBundle\\Form\\Type\\PromotionActionCollectionType', array('label' => 'sylius.form.promotion.actions', 'button_add_label' => 'sylius.form.promotion.add_action')) 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 269 + 

    at FormBuilder ->resolveChildren() 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 215 + 

    at FormBuilder ->getForm() 
    in vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 39 + 

    at FormFactory ->create ('Sylius\\Bundle\\PromotionBundle\\Form\\Type\\PromotionType', object(Promotion), array()) 
    in vendor/sylius/sylius/src/Sylius/Bundle/ResourceBundle/Controller/ResourceFormFactory.php at line 44 + 

    at ResourceFormFactory ->create (object(RequestConfiguration), object(Promotion)) 
    in vendor/sylius/sylius/src/Sylius/Bundle/ResourceBundle/Controller/ResourceController.php at line 245 + 

    at ResourceController ->createAction (object(Request)) 

    at call_user_func_array (array(object(ResourceController), 'createAction'), array(object(Request))) 
    in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 153 + 

    at HttpKernel ->handleRaw (object(Request), 1) 
    in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 68 + 

    at HttpKernel ->handle (object(Request), 1, true) 
    in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php at line 168 + 

    at Kernel ->handle (object(Request)) 
    in web/app_dev.php at line 43 + 

    at require ('/Users/camerona/Documents/Projects/CheshireRaw/web/app_dev.php') 
    in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php at line 40 + 

答えて

0

私はCheapestProductDiscountPromotionActionCommandで問題を発見しました。 syliusのドキュメントで

here上場:

/** 
    * {@inheritdoc} 
*/ 
public function getConfigurationFormType() 
{ 
    return CheapestProductDiscountPromotionActionCommand::class; 
} 

しかし、これは次のようになります。コードはCheapestProductDiscountPromotionActionCommand.phpがFormTypeInterfaceを実装していることを確認し、なぜ

/** 
    * {@inheritdoc} 
*/ 
public function getConfigurationFormType() 
{ 
    return CheapestProductDiscountConfigurationType::class; 
} 

です。

Iveは自分のカスタムアクションとその動作を完全に追加することができました。 syliusのドキュメントにはいくつかの問題がありますが、実装はうまくいきます:)

関連する問題