symfony-2.1

How to add a custom field to the session table

蹲街弑〆低调 提交于 2019-12-06 09:26:36
问题 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

Adding custom columns to Propel model?

混江龙づ霸主 提交于 2019-12-06 09:26:23
问题 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' =>

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

只谈情不闲聊 提交于 2019-12-06 04:54:52
问题 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

Installing and running LiipImagineBundle in symfony 2.1

天大地大妈咪最大 提交于 2019-12-06 04:30:41
问题 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\

Symfony2 - Entire child entity in form and Twig template

空扰寡人 提交于 2019-12-06 03:31:50
In a Sonata admin form, I'd like to display all images related to the current object. Don't need to edit them. I managed to get this working with an entity field type and its property option to select the image URL as label so I can call all pictures in the template : ->add('image', 'entity', array( 'class' => 'Hop\HopBundle\Entity\Image', 'property' => 'image_url', 'query_builder' => function($er) use ($object) { return $er->createQueryBuilder('i') ->where('i.object = :object') ->setParameter('object', $object) ; }, 'expanded' => true, )) . {% for child in form %} <img src="{{ child.vars

Overriding symfony radio widget

醉酒当歌 提交于 2019-12-05 22:35:19
Default radio widget creates a following structure: <label>...</label> <div id="..."> <div class="clearfix prettyradio labelright blue"> <input type="radio" id="..._0" name="..." value="..." style="display: none;"> <a href="#" class=""></a> ... </div> I found the radio_widget block, but it contains only an input itself. So I can customize there only this part: <input type="radio" id="..._0" name="..." value="1" style="display: none;"> But I can't understand how to change whole the structure of radio choice field? Also, does anybody knows, why symfony adds display:none to the input? Thanks. if

symfony2 detect locale based on domain name

瘦欲@ 提交于 2019-12-05 19:25:32
i want to setup a new website with 2 locales and the locale should detected by the domain name that's used. Any idea how to do this? for example locales: nl and fr when www.somenldomainname.be is used then the nl locale should be detected when www.somefrdomainname.be is used then the fr locale should be detected it would also be great if i generate an url in nl or fr the right domain name is selected. kind regards, Daan You can create an event listener to detect your domain name: class LocaleListener implements EventSubscriberInterface { /** * Set default locale * * @param GetResponseEvent

set role for users in edit form of sonata admin

淺唱寂寞╮ 提交于 2019-12-05 18:50:31
I'm using Symfony 2.1 for a project. I use the FOSUserBundle for managing users & SonataAdminBundle for administration usage. I have some questions about that: As an admin, I want to set roles from users in users edit form. How can I have access to roles in role_hierarchy ? And how can I use them as choice fields so the admin can set roles to users? When I show roles in a list, it is shown as string like this: [0 => ROLE_SUPER_ADMIN] [1 => ROLE_USER] How can I change it to this? ROLE_SUPER_ADMIN, ROLE_USER I mean, having just the value of the array. Romain Bruckert Based on the answer of

Symfony 2.1 Security Cross Subdomain

岁酱吖の 提交于 2019-12-05 16:22:33
Running Symfony 2.1 on an application and we have different sandboxes of the code. Eg. aequasi.someurl.com dev.someurl.com hotcarl.someurl.com I cant seem to figure out why, but when im logged into aequasi , and i go to hotcarl , i need to log in again. When i do, it logs me out of aequasi . All sandboxes are using the same database for auth i have this in my config.yml : framework: session: cookie_domain: .someurl.com domain: .someurl.com ive got the php.ini set up to use the same url too also, the session_id's are the same Use a database, or memory as the Session storage. This allows you to

How to get web directory path from inside Entity?

a 夏天 提交于 2019-12-05 16:12:08
I researched the How to Handle File Uploads with Doctrine and I don't want to hard-code the __DIR__.'/../../../../web/'.$this->getUploadDir(); path because maybe in future I will change the web/ directory. How to do it more flexible? I found this but it doesn't answer the question how to do it more flexible from inside the Entity You shouldn't use entity class as a form model here. It's simply not suitable for that job. If the entity has the path property, the only valid values it can stores are: null (in case lack of the file) and string representing the path to the file. Create a separate