symfony-2.1

symfony2.1 bundle version confusion, for symfony and sonata admin / knp menu bundle

走远了吗. 提交于 2019-12-05 06:05:49
I want to use symfony2.1 for a new project. I try to install symfony2 with composer. But there were multiple errors/problems and so I have also questions for each problem in bold font style . Sometimes I don't know if I do it the right way. I want to use a stable version so I chosen the 2.1.0 version and not the dev/master. php composer.phar create-project symfony/framework-standard-edition symfony v2.1.0 the result was this: Installing symfony/framework-standard-edition (v2.1.0) - Installing symfony/framework-standard-edition (v2.1.0) Downloading: 100% Created project in symfony Loading

How to use ChoiceList in Symfony 2.1?

别等时光非礼了梦想. 提交于 2019-12-05 01:53:20
问题 I have a file containing a list of the US states. Alabama Alaska etc .. In symfony 2.0 I used ChoiceListInterface.php to use it in my form. I simply wrote this : <?php namespace MyBundle\Form; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; class StateChoiceList implements ChoiceListInterface { public function getChoices() { $lines = file('listes/us_states.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); // fill the array $arr = array(); foreach ($lines as $line

Symfony 2 - Best practice to upload an image on Amazon S3

[亡魂溺海] 提交于 2019-12-05 01:52:00
问题 I have a form in which I have a file field to upload an image. I need to upload this image on Amazon S3. Building this step by step I started to upload the image on the local disk and it's now working. The upload is occurring inside my entity Page as it's recommended to test the success of the upload before to save the entity. I ended up with this chunk of code /** * @ORM\Column(name="objectThumbnail", type="string", length=255, nullable=true) */ protected $objectThumbnail; /** * This is not

Doctrine doesn't map fields from FOSUserBundle User class

南笙酒味 提交于 2019-12-05 01:45:31
问题 I am using Symfony 2.1 RC1 and the FOSUserbundle on a Windows server running PHP 5.3.13. I have followed the instructions here but Doctrine doesn't create fields in the database for the properties inherited from the base FOS User class (only the fields from my class). Trying to login using the FOS login form produces the error: Unrecognized field: usernameCanonical I have the following Doctrine configuration: # Doctrine Configuration doctrine: dbal: driver: %database_driver% host: %database

Force reauthentication after user permissions have been changed

自闭症网瘾萝莉.ら 提交于 2019-12-04 21:38:57
问题 In my application I can change user permissions and roles in backend. When a user is logged in and I remove a role of the user, the user can still access content which he actually is not permitted to access anymore, because he is missing the role. The changes take effect only when the user reauthenticates himself with logout/login. So my question is, can I access the session of a logged in user (not me)? I know I can access my own session and destroy it which forces me to login again. But I

Symfony Form Class: rename fields name attribute's value

岁酱吖の 提交于 2019-12-04 19:54:49
Is there a way to set individual form fields name in the FormBuilder? What I mean is normally you get is form_name[field_name] , or if the form_name is an empty string you get field_name . Now I want to ask if it is possible to rename individual field name and the form still works. Something like this: First field name="form_name[field_name]" Second field name="renamed_fildname" Third field name="form_name[field_name]" etc... So is this possible? More explanation: this is what I am trying to achieve: Default Symfony User Entity with Form Class I Figured out that the default login requires the

Form does not display form errors in template

£可爱£侵袭症+ 提交于 2019-12-04 19:33:47
For my contact form no form errors are displayed. $contact = new Contact(); $form = $this->createForm(new ContactFormType(), $contact); /* handle contact form submission */ if ('POST' == $request->getMethod()) { $form->bindRequest($request); if ($form->isValid()) { //Do something } } return $this->render('MainBundle:Default:contact.html.twig', array( 'form' => $form->createView() )); My validator Fc\MainBundle\Entity\Contact: properties: firstName: - NotBlank: ~ lastName: - NotBlank: ~ email: - NotBlank: ~ - Email: checkMX: true title: - NotBlank: ~ message: - NotBlank: ~ I have added a

Role Interface and Manage Roles

大憨熊 提交于 2019-12-04 19:09:39
I have simple UserInterface entity: function getRoles() { return $this->roles->toArray(); } and with many to many relation with Role Entity interface /** * @ORM\ManyToMany(targetEntity="Role", inversedBy="users", cascade={"persist"}) */ protected $roles; When I try to manage user roles with form Type public function buildForm(FormBuilder $builder, array $options) { $builder->add('roles'); } Symfony returns me an error: Expected argument of type "Doctrine\Common\Collections\Collection", "array" given I know the error is in the getRoles method of the entity User that returns an array but I also

Symfony2 multiple config and routing files for subdomain routing

烈酒焚心 提交于 2019-12-04 14:03:52
We are building a Symfony2 application that will serve different sections using subdomains: api.tld.com - API system docs.tld.com - Documentation assets.tld.com - System for serving images How we are doing this is creating an app directory for each subdomain, and keeping the standard /app directory in place as the central shared config. There is also a custom bootstrap in the web directory for each app. Subdomains are routed accordingly using .htaccess. The problem I am having is where multiple config files come in, particularly when they have their own routing imports. In some cases, there

Testing database insert using Symfony

一世执手 提交于 2019-12-04 13:27:44
问题 Good day everyone, I have been looking into Test Driven Development a lot in the past few days and decided that I need to learn it as well. Although I can not figure out how to do it precisely. My project depends on the Symfony2.1.6 framework and Doctrine so I have some Database-tables that needs filling. Book (1,n) - (0,n) Genre Now if I want to insert a Genre-record I first need to write a test to ensure everything is being inserted as it should (or am I wrong?) The problem now is that I