I want to override the EmailType of the lexik mailer bundle.
I tried
use Lexik\Bundle\MailerBundle\Form\Type\EmailType as BaseType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
* #author Laurent Heurtault <l.heurtault#lexik.fr>
* #author Yoann Aparici <y.aparici#lexik.fr>
*/
class EmailType extends BaseType
{
...
}
and put it in the exact same path in my bundle MailingBundle/Form/Type/EmailType.php
But it doesn't seem to work.
May I have to make something more than that?
thank you in advance.
You can redefine the Form Type class as parameter, as example:
parameters:
lexik_mailer.form.type.mailer_email.class: AppBundle\Form\MyEmailFormType
Hope this help
Related
I am currently developing an API and am using FOSRestBundle. I've gone wrong somewhere with the annotation side of my controller.
Please see my code below:
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
class DefaultController extends FOSRestController
{
/**
* #Rest\("/default/{string})
* #param string $string
*/
public function defaultAction($string)
{}
}
I am trying to to pass a parameter to the default action and do something with it. However, the parameter I include in the URL isn't getting passed to the action. Any help will be appreciated.
You're just missing the Get from your first annotation, it should be: #Rest\Get("/default/{string}")
I try to use CakeDC Users plugin version 6.0, with cakephp 3.5.12.
I can use the basci routes, but I would like to redefine controller, because I wouldn't use registration functionality.
I added AppUsersController to src/Controller directory whit this code
namespace App\Controller;
use CakeDC\Users\Controller\Traits\LoginTrait;
use CakeDC\Users\Controller\Traits\RegisterTrait;
class AppUsersController extends AppController
{
use LoginTrait;
//use RegisterTrait;
}
And added this content to config/users.php
<?php
/**
* Created by PhpStorm.
* User: mihaly
* Date: 2018.02.14.
* Time: 12:46
*/
namespace App\Controller;
use CakeDC\Users\Controller\Traits\LoginTrait;
use CakeDC\Users\Controller\Traits\RegisterTrait;
class AppUsersController extends AppController
{
use LoginTrait;
//use RegisterTrait;
}
But the register actions are available in this way too. I tried comment booth traits, but the authentication functionality stay available. What I'm doing wrong?
I tried use this documentation:
https://github.com/CakeDC/users/blob/master/Docs/Documentation/Extending-the-Plugin.md
For some weird reason my App and ApiBundle Classes are not found during registerbundles()-function of Appkernel.php.
The classes are there and seeem to be correct and I cannot understand what the problem is.
Appkernel-entries:
new Neulich\AppBundle\NeulichAppBundle(),
new Neulich\ApiBundle\NeulichApiBundle(),
Neulich/src/AppBundle/NeulichAppBundle.php:
<?php
namespace Neulich\AppBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Class NeulichAppBundle
*
* #package Neulich\AppBundle
*/
class NeulichAppBundle extends Bundle
{
}
Please give me a hint, I've been trying for a long time now.
Thanks a lot.
Steffen
trying to understand what is the Doctrine. I using PHPStorm 2016.3.2 and plugin "PHP Annotations".
When i'm create the Model i'm trying to use annotations like this:
use \Doctrine\ORM\Mapping as ORM;
/**
* Class Region
* #package models
* #ORM\Entity()
* #ORM\Table(name="regions")
*/
class Region { ... }
In annotations i'm using not #Entity, i'm using #ORM\Entity() because IDE understanding what is that and making tips for me. But on this way Doctrine didnt see my classes. How i can to resolve this problem? Thanks.
I came across the same issue while creating the Doctrine configuration through the
Setup::createAnnotationMetadataConfiguration()
method. When you set its fifth parameter $useSimpleAnnotationReader to false you can use the name-spaced syntax the PhpStorm extension expects.
Symfony's manual on ParamConverter has this example:
/**
* #Route("/blog/{post_id}")
* #Entity("post", expr="repository.find(post_id)")
*/
public function showAction(Post $post)
{
}
Source: http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#fetch-via-an-expression
But using #Entity annotation gives me this error.
The annotation "#Entity" in method AppBundle\Controller\CurrencyController::currencyAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?
Obviously, I need to use a namespace, but which one? Please help.
The Entity annotation only exist on master (or futur v4).
Source file here
But as you can see, this is only a shortcut to #ParamConverter annotation with expr option, so you have to use this one until next release.
Best regards.
You are trying to use ParameterConverter so this syntax is just wrong.
Use this instead
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
/**
* #Route("/blog/{post_id}")
* #ParamConverter("post_id", class="VendorBundle:Post")
*/
public function showAction(Post $post)
{
}
VendorBundle:Post should be replaced with whatever your Vendor is (if any) and Bundle is.
Using annotation #ParamConverter with option repository_method is deprecated
The repository_method option of #ParamConverter is deprecated and will be removed in 6.0. Use the expr option or #Entity.
Thus it's better to use #Entity (documentation)
You have to add the namespace :
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;