{"action":"created","issue":{"url":"https://api.github.com/repos/mremi/ContactBundle/issues/19","labels_url":"https://api.github.com/repos/mremi/ContactBundle/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/mremi/ContactBundle/issues/19/comments","events_url":"https://api.github.com/repos/mremi/ContactBundle/issues/19/events","html_url":"https://github.com/mremi/ContactBundle/issues/19","id":52783160,"number":19,"title":"Change visibility of TwigSwiftMailer properties to extend class when overriding ","user":{"login":"webdevilopers","id":3479626,"avatar_url":"https://avatars.githubusercontent.com/u/3479626?v=3","gravatar_id":"","url":"https://api.github.com/users/webdevilopers","html_url":"https://github.com/webdevilopers","followers_url":"https://api.github.com/users/webdevilopers/followers","following_url":"https://api.github.com/users/webdevilopers/following{/other_user}","gists_url":"https://api.github.com/users/webdevilopers/gists{/gist_id}","starred_url":"https://api.github.com/users/webdevilopers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webdevilopers/subscriptions","organizations_url":"https://api.github.com/users/webdevilopers/orgs","repos_url":"https://api.github.com/users/webdevilopers/repos","events_url":"https://api.github.com/users/webdevilopers/events{/privacy}","received_events_url":"https://api.github.com/users/webdevilopers/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-23T23:21:50Z","updated_at":"2016-01-31T15:54:47Z","closed_at":null,"body":"I need to override the `TwigSwiftMailer`:\r\nhttps://github.com/mremi/ContactBundle/blob/master/Mailer/TwigSwiftMailer.php\r\n\r\nAt the moment I have to create my own class and add the properties in order to implement the `MailerInterface`:\r\n```php\r\nuse Mremi\\ContactBundle\\Mailer\\MailerInterface;\r\nuse Mremi\\ContactBundle\\Model\\ContactInterface;\r\n\r\nclass TwigSwiftMailer implements MailerInterface\r\n{\r\n    /**\r\n     * @var \\Swift_Mailer\r\n     */\r\n    private $mailer;\r\n\r\n    /**\r\n     * @var \\Twig_Environment\r\n     */\r\n    private $twig;\r\n\r\n    /**\r\n     * @var string\r\n     */\r\n    private $recipientAddress;\r\n\r\n    /**\r\n     * @var string\r\n     */\r\n    private $template;\r\n\r\n    /**\r\n     * Constructor\r\n     *\r\n     * @param \\Swift_Mailer     $mailer           A mailer instance\r\n     * @param \\Twig_Environment $twig             A Twig instance\r\n     * @param string            $recipientAddress The recipient email\r\n     * @param string            $template         The template used for email content\r\n     */\r\n    public function __construct(\\Swift_Mailer $mailer, \\Twig_Environment $twig, $recipientAddress, $template)\r\n    {\r\n        $this->mailer           = $mailer;\r\n        $this->twig             = $twig;\r\n        $this->recipientAddress = $recipientAddress;\r\n        $this->template         = $template;\r\n    }\r\n\r\n    /**\r\n     * {@inheritdoc}\r\n     */\r\n    public function sendMessage(ContactInterface $contact)\r\n    {\r\n    }\r\n}\r\n```\r\n\r\nIt would be easier if the properties were `protected` in order to extend the existing `TwigSwiftMailer` and simply change the `sendMessage` method:\r\n```php\r\nuse Mremi\\ContactBundle\\Mailer\\TwigSwiftMailer as MremiTwigSwiftMailer;\r\n\r\nclass TwigSwiftMailer extends MremiTwigSwiftMailer\r\n{\r\n    /**\r\n     * {@inheritdoc}\r\n     */\r\n    public function sendMessage(ContactInterface $contact)\r\n    {\r\n    }\r\n}\r\n```\r\n\r\nDo you agree, should I create a PR?\r\n\r\nIn addition I have problems to set `$recipientAddress` and `$template` to the constructor:\r\n```yaml\r\n# app/config.yml\r\n\r\nmremi_contact:\r\n    email:\r\n#        mailer:            mremi_contact.mailer.twig_swift\r\n        mailer:            acme.mailer.twig_swift\r\n        recipient_address: info@example.com\r\n        template:          MremiContactBundle:Contact:email.txt.twig\r\n```\r\n\r\nMy service:\r\n```xml\r\n        <service id=\"acme.mailer.twig_swift\" class=\"Acme\\AppBundle\\Mailer\\TwigSwiftMailer\" public=\"false\">\r\n            <argument type=\"service\" id=\"mailer\" />\r\n            <argument type=\"service\" id=\"twig\" />\r\n            <argument />\r\n            <argument />\r\n        </service>\r\n```\r\n\r\nAnd I override the template inside `app/Resources/MremiContactBundle/views/Contact/email.txt.twig` which works fine with the original mailer.\r\n\r\nThe error:\r\n**Unable to find template \"\".**\r\n\r\nThe same will happen for `$recipientAddress` when trying to send the `To` will be empty:\r\n**Address in mailbox given [] does not comply with RFC 2822, 3.6.2.**\r\n\r\nWhere am I missing the injection?\r\n\r\nOr could this be a problem after updating to Symfony **2.6** like in issue https://github.com/mremi/ContactBundle/issues/18 which makes config vars unavailable?\r\n\r\nIn my final step I would like to save my custom entity:\r\n```yaml\r\nmremi_contact:\r\n    store_data:            true\r\n#    contact_class:         Mremi\\ContactBundle\\Model\\Contact\r\n    contact_class:         Acme\\AppBundle\\Entity\\ContactRequest\r\n```\r\n\r\nMy entity uses a custom table structure and has no fields like `title` or `firstName`.\r\nBut the `ContactEvent` requires me to implement the `Mremi\\ContactBundle\\Model\\ContactInterface` that forces me to write all the abstract methods and extend `Serializable`.\r\n\r\nWhat is the best way to implement my own custom `save` method for the manager?\r\n\r\nIs it easier to override the doctrine mapping resp. disable to use my annotations only?\r\nhttps://github.com/mremi/ContactBundle/blob/master/Resources/config/doctrine/Contact.orm.xml\r\n\r\nIn the end, when adding all abstract methods, I can not save the form:\r\n**The form's view data is expected to be an instance of class Mremi\\ContactBundle\\Model\\Contact, but is an instance of class Acme\\AppBundle\\Entity\\ContactRequest.**\r\n\r\nAnd I really think this is related to the Symfony update issue again since he should adapt my config value for the `contact_class`."},"comment":{"url":"https://api.github.com/repos/mremi/ContactBundle/issues/comments/177532302","html_url":"https://github.com/mremi/ContactBundle/issues/19#issuecomment-177532302","issue_url":"https://api.github.com/repos/mremi/ContactBundle/issues/19","id":177532302,"user":{"login":"mremi","id":548536,"avatar_url":"https://avatars.githubusercontent.com/u/548536?v=3","gravatar_id":"","url":"https://api.github.com/users/mremi","html_url":"https://github.com/mremi","followers_url":"https://api.github.com/users/mremi/followers","following_url":"https://api.github.com/users/mremi/following{/other_user}","gists_url":"https://api.github.com/users/mremi/gists{/gist_id}","starred_url":"https://api.github.com/users/mremi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mremi/subscriptions","organizations_url":"https://api.github.com/users/mremi/orgs","repos_url":"https://api.github.com/users/mremi/repos","events_url":"https://api.github.com/users/mremi/events{/privacy}","received_events_url":"https://api.github.com/users/mremi/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T15:54:46Z","updated_at":"2016-01-31T15:54:46Z","body":"This recent PR #30 made all fields nullable, should fix the previous SQL exception."}}