symfony-2.1

Symfony2 KnpMenuBundle: set active a menu item even when its not on that menu

余生颓废 提交于 2019-12-10 14:00:04
问题 I created my menu builder and it works. One of my route is /database But this has a child route: database/view/{id} I don't want to put the view route into the menu items because without the ID it won't work. But I want the database route to be active when the user is on the view. How can I do this? 回答1: Managed to solve it with this little hack: in the menuBuider after you add all the Children but before you return the menu i added $request = $this->container->get('request'); $routeName =

Unable to find the controller for path “/login_check”

亡梦爱人 提交于 2019-12-10 13:49:46
问题 I have having trouble getting user authentication working on symfony. I have the login_path working properly, but check_path is malfunctioning. The path that I have specified gives the famous Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration? I've looked at the other posts, and they all seem to do what I am doing. I am very new to symfony and having trouble grasping the concepts, so I would greatly appreciate some

Invalid Argument Exception when generating Entities from existing database

耗尽温柔 提交于 2019-12-10 13:46:53
问题 I'm converting a Symfony 2 project from Propel to Doctrine and wish to convert the existing database into Doctrine Entities. To do this I'm following the tutorial on the Symfony website, however when I run the following command: php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force I immediately receive the following error: [InvalidArumentException] Doctrine ORM Manager named "" does not exist. Can anyone explain

Change WhiteOctober TCPDF bundle configuration values

半腔热情 提交于 2019-12-10 07:25:44
问题 I've started using the WhiteOctober TCPDF bundle in my symfony project but I can't figure out how to change the default configuration values, such as page format. I've tried putting that in my config.yml: white_october_tcpdf: tcpdf: k_tcpdf_external_config: true pdf_page_format: 'LETTER' pdf_author: 'Company Name' pdf_header_title: 'Order Confirmation' pdf_header_string: 'Company Name' pdf_header_logo: '%kernel.root_dir%/../web/images/logo.png' pdf_header_logo_width: '35' pdf_margin_header:

symfony2 is not a valid entity or mapped super class

我与影子孤独终老i 提交于 2019-12-10 00:28:40
问题 I have a symfony2 app, in my local pc with ubuntu and works well, but in server with CentOS and Cpanel not works, I obtained this error: Class "Propa\PageBundle\Entity\Page" is not a valid entity or mapped super class. CRITICAL - Doctrine\ORM\Mapping\MappingException: Class "Propa\PageBundle\Entity\Page" is not a valid entity or mapped super class. (uncaught exception) at /home/estudi83/domains/serverprova.com.es/propa/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php line 216

Symfony 2 - rearrange form fields

此生再无相见时 提交于 2019-12-09 17:14:19
问题 In our Symfony2 project we have a very complex structure for forms with embedded forms.... Now we got the requirement to bring the output of the form in an specific order. And here is the problem: We use the form_widget(form) and now we are looking for a solution in the object (e.g. via annotations) or the formbuilder to move a specific field to the end of the form. in symfony 1.4 it was the widget-movefield() function, i guess... Thx... 回答1: You can re-order the fields using this bundle:

Handle errors in Ajax within Symfony2 controller

两盒软妹~` 提交于 2019-12-08 16:23:20
问题 I am trying to handle errors in Ajax. For this, I am simply trying to reproduce this SO question in Symfony. $.ajaxSetup({ error: function(xhr){ alert('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText); } }); but I can't figure out what the code in the controller would look like in Symfony2 to trigger header('HTTP/1.0 419 Custom Error'); . Is it possible to attach a personal message with this, for example You are not allowed to delete this post . Do

Symfony/Doctrine: “Catchable Fatal Error: Object of class <type> could not be converted to string” when persisting

做~自己de王妃 提交于 2019-12-08 10:42:45
问题 A symfony2 application has a Job entity that has as a property of type WebSite . A simplified representation of this without other properties or methods: /** * @ORM\Entity * @ORM\Table(name="Job") */ class Job { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(type="integer", name="website_id", nullable=false) * @ORM\ManyToOne(targetEntity="Example\ExampleBundle\Entity\WebSite") */ protected $website; } Symfony/Doctrine is

Recursive roles with custom user provider entity

醉酒当歌 提交于 2019-12-08 10:42:27
问题 I've got a custom user provider entity which permits me to connect the users. This custom user provider entity implements UserInterface in accordance to this interface I've got a "getRoles()" function which give me the user's roles. But my roles are recursive. Example: a user got a role1, the role1 inherited the role2 so the user has gotten the role1 and the role2. To make this recursivity I create a role table, a role_role table (parent/child), a user table and finally a user_role table. To

pagination in symfony 4 using KnpPaginatorBundle

岁酱吖の 提交于 2019-12-08 08:32:44
问题 Attempted to load class " KnpPaginatorBundle " from namespace " App\Knp\Bundle\PaginatorBundle ". Did you forget a " use " statement for " Knp\Bundle\PaginatorBundle\KnpPaginatorBundle "? 回答1: Just add class namespace of KnpPaginatorBundle : in config/bundles.php : <?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], *************************************************************** **************