symfony-2.1

Adding custom columns to Propel model?

余生长醉 提交于 2019-12-04 13:05:52
At the moment I am using the below query: $claims = ClaimQuery::create('c') ->leftJoinUser() ->withColumn('CONCAT(User.Firstname, " ", User.Lastname)', 'name') ->withColumn('User.Email', 'email') ->filterByArray($conditions) ->paginate($page = $page, $maxPerPage = $top); However I then want to add columns manually, so I thought this would simply work: foreach($claims as &$claim){ $claim->actions = array('edit' => array( 'url' => $this->get('router')->generate('hera_claims_edit'), 'text' => 'Edit' ) ); } return array('claims' => $claims, 'count' => count($claims)); However when the data is

How to add a custom field to the session table

不问归期 提交于 2019-12-04 12:57:26
I'm currently using Symfony 2.1.8 and the built-in PdoSessionHandler . I want to add a user_id field in the session table to identify to which (logged-in) user the session belongs. The idea is that I can force the user to log back in destroying his session. In my case it will happen if the privileges of the user are updated. I had a look to the build-in PdoSessionHandler that you can't extends because of those silly private variables. So I've tried created a new one (copy/paste) and add my column user_id . Now this column can be null if the user is not logged in (anonymous users). So I want to

Symfony2 FosUserBundle and SonataUserBundle : overriding entities?

我的未来我决定 提交于 2019-12-04 11:42:30
I use FosUserBundle and SonataUserBundle for my Symfony2 project. I get confused now. I want to add fields for the entity User but it's not working. There is no update for the schema for example. Here is my config : AppKernel: ... new FOS\UserBundle\FOSUserBundle(), new Sonata\UserBundle\SonataUserBundle(), new Application\Sonata\UserBundle\ApplicationSonataUserBundle('FOSUserBundle') config.yml: ... # FOSUserBundle Configuration fos_user: db_driver: orm # BDD type firewall_name: main # firewall name user_class: Application\Sonata\UserBundle\Entity\User # entity class defined And the User

With Symfony2 why are ESI tags inside cached responses ignored?

浪子不回头ぞ 提交于 2019-12-04 11:41:23
I have an ecommerce application that I'm try to set up for caching - initially via the Symfony2 Reverse Proxy, but then ultimately via Varnish in production. I'm using Symfony 2.1.8 on Apache2. My problem is I cannot get the ESI tags to be re-checked for each request when the primary controller action is cached (important for private content like the basket contents), but I don't understand why. For example, I cache the homepage with the following code: public function indexAction(Request $request) { // check cache $homepage = $this->getHomepage(); $response = new Response(); $response-

Correct way to set the driverOptions for Doctrine DBAL configuration in symfony2

懵懂的女人 提交于 2019-12-04 10:41:46
I have set driverOptions in the config file as mentioned in the doctrine DBAL documentation. But this gives an error 1/1 InvalidConfigurationException: Unrecognized options "driverOptions" under "doctrine.dbal.connections.pdoDevCon" My config file is dbal: default_connection: pdoDevCon connections: pdoDevCon: driver: %dev_database_driver% # < host: %dev_database_host% # | port: %dev_database_port% # | Defined in user: %dev_database_user% # | password: %dev_database_password% # < charset: UTF8 driverOptions: {3: 2} mapping_types: enum: string set: string orm: auto_generate_proxy_classes:

Installing and running LiipImagineBundle in symfony 2.1

大憨熊 提交于 2019-12-04 09:50:22
Here are the steps I followed: Added following in my composer.json: "require": { "imagine/Imagine": ">=0.2.8", "liip/imagine-bundle": "*@dev", .... } Ran following command at command line: composer update Installing imagine/imagine (v0.4.0) Installing liip/imagine-bundle (dev-master f7d5e4d) After composer update my directory structure inside vendor folder looks like as below: Then update vendor/composer/autoload_namespaces.php 'Imagine' => $vendorDir .'/imagine/Imagine/lib/', 'Liip\\ImagineBundle'=>$vendorDir . '/liip/imagine-bundle/', Registered bundle: new Liip\ImagineBundle

Symfony 2 | Form exception when modifying an object that has a file(picture) field

ⅰ亾dé卋堺 提交于 2019-12-04 07:53:34
问题 I'm using Symfony2. I have an entity Post that has a title and a picture field. My problem : Everything is fine when I create a post, I have my picture etc. But when I want to modify it, I have a problem with the "picture" field which is an uploaded file, Symfony wants a file type and it has a string (the path of the uploaded file) : The form's view data is expected to be an instance of class Symfony\Component\HttpFoundation\File\File, but is a(n) string. You can avoid this error by setting

Symfony 2 - rearrange form fields

笑着哭i 提交于 2019-12-04 05:09:16
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... You can re-order the fields using this bundle: https://github.com/egeloen/IvoryOrderedFormBundle This allows you to do things like this: $builder ->add('g',

Add data to return of all actions in a Symfony controller

不打扰是莪最后的温柔 提交于 2019-12-04 04:59:39
问题 I have a controller in a Symfony 2.1 application, let's just call it FooController in the BarBundle . This controller has a lot of actions fooAction , barAction , bazAction and a few more. All of them have something in common. They're displaying in some part's the same data in the view, not in all, so I can't just use one action with the type as parameter. I would like to add the data that has to be passed to the view in one central place, otherwise, it just wouldn't be dry. Bad (in my

Symfony2 send form ajax

♀尐吖头ヾ 提交于 2019-12-04 02:42:21
I'm trying to submit a form via ajax to update a field of an entity, but do not know how to retrieve the data from the controller: <form class="ajax" action="{{ path('ajax_setSocial') }}" method="post" {{ form_enctype(form) }}> <div class="editor"> {{ form_errors(form) }} <div class="editLabel pls">{{ form_label(form.ragSocial) }}</div> <div class="editField"> <div class="ptm"> {{ form_widget(form.ragSocial) }} {{ form_errors(form.ragSocial) }} </div> {{ form_rest(form) }} <div class="mtm"> <button class="btn btn-primary disabled save" type="submit">Save</button> <button class="btn ann">Close<