-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Question] How can I use a custom action? #257
Comments
@JRomeoSalazar : Do you use the bundle standalone? You should register it in your kernel (AppKernel.php) and define your new controller in your configuration. |
Yes I use the bundle standalone, and I have registered it in AppKernel.php. How can I define the controller in the configuration? I thought it was only necessary to map a new route to the controller as I have done. This is my AppKernel.php: <?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Sylius\Bundle\ProductBundle\SyliusProductBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new MDW\DemoBundle\MDWDemoBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new KTSport\WebBundle\KTSportWebBundle(),
new JMS\I18nRoutingBundle\JMSI18nRoutingBundle(),
new JMS\TranslationBundle\JMSTranslationBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
} |
This is my config.yml: sylius_product:
driver: doctrine/orm
#engine: twig # Templating engine to use by default.
classes:
product:
model: Sylius\Bundle\ProductBundle\Model\Product # The product model class.
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
#repository: ~
form: Sylius\Bundle\ProductBundle\Form\Type\ProductType
property:
model: Sylius\Bundle\ProductBundle\Model\Property
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
#repository: ~
form: Sylius\Bundle\ProductBundle\Form\Type\PropertyType
prototype:
model: Sylius\Bundle\ProductBundle\Model\Prototype
controller: Sylius\Bundle\ProductBundle\Controller\PrototypeController
#repository: ~
form: Sylius\Bundle\ProductBundle\Form\Type\PrototypeType It seems like PrototypeController is already configured but Symfony still throws me the error :( Any idea? |
Your error looks like you would intend to use a bundle named "sylius.controller.prototype" which is of course impossible. Could you paste here the full error trace? |
Yes, of course, here it is: Stack trace:
Logs:
|
You have something extra here - |
That's it! I should pass to the form the prototype id instead to the controller. But now I have another problem, the same as this #249 but with another field, in this case, "value".
Do you know why? |
Do you use the latest version? Try |
Yes, I have just updated the bundle as you have said. I use 0.1.* |
We don't support version |
Fixed missing sign and parentheses
I have been reading the documentation but "Custom Actions" is not yet written.
Inside SyliusProductBundle there is a file "PrototypeController.php" which extends "ResourceController" and ads the "buildAction" in order to build products based on Prototype.
I'm trying to use this custom action but it is not working:
The error:
The route:
And this is PrototypeController.php
https://github.com/Sylius/SyliusProductBundle/blob/master/Controller/PrototypeController.php
Thanks.
The text was updated successfully, but these errors were encountered: