symfony-2.8

Symfony Update 2.8 to 3.4

百般思念 提交于 2019-12-05 17:11:45
I wanted to upgrade my old Symfony project from 2.8 to 4.0 but I stacked at upgrade from 2.8 to 3.4. I used this tutorial for the upgrade Moving to Symfony 3.4 . I got some errors while trying to update through composer Composer Upgrade Errors : # php composer.phar update symfony/symfony --with-dependencies Dependency "symfony/polyfill-apcu" is also a root requirement, but is not explicitly whitelisted. Ignoring. Dependency "twig/twig" is also a root requirement, but is not explicitly whitelisted. Ignoring. Dependency "ircmaxell/password-compat" is also a root requirement, but is not

How to customize form field based on user roles in Symfony2/3?

China☆狼群 提交于 2019-12-05 15:50:20
问题 Is there a correct way to customize a form depending on the role of the user that requests it? My scenario is pretty simple: I need to hide some fields if the user has not the ROLE_ADMIN granted. I tried to avoid the field display on Twig, but {% if is_granted('ROLE_ADMIN') %} {{form_row(form.field)}} {% endif %} not works, because the form builder bypass this check. Symfony version: 2.8.2 EDIT Thanks to the @Rooneyl suggestion I've found the solution: At first, you need to add the 'role' key

Symfony 2.7 / 3 - Doctrine: You have requested a non-existent service “fos_user.doctrine_registry”

感情迁移 提交于 2019-12-03 22:10:09
Doing a composer update today suddenly getting the following error: [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] You have requested a non-existent service "fos_user.doctrine_registry". when composer is executing the cache:clear --no-warmup command. Search found an answer related to converting from doctrine to MongoDB but the solutions are not working for me. I am using Doctrine. I've tried Fosuserbundle dev-master, dev-master@dev, 2.0.0-alpha1 and 2.0.0-alpha3. Any other suggestions? Composer update was working fine a couple of days ago. Issue created here: https:

Symfony 2.8/3.0 upgrade: how to deal with form types with variable parameters?

回眸只為那壹抹淺笑 提交于 2019-12-03 15:56:44
Let's say I create custom form types as services, as it is described in the Symfony documentation . But I want 2 "gender" custom types, with 2 different input parameters, which I was doing like this in Symfony 2.7: # app/config/config.yml parameters: genders1: m: Male f: Female genders2: # This makes no sense at all, but it is for the example purpose! h: Horse t: Turtle And then, I was declaring 2 services like this: <!-- src/AppBundle/Resources/config/services.xml --> <service id="app.form.type.gender1" class="AppBundle\Form\Type\GenderType"> <argument>%genders1%</argument> <tag name="form

LDAP Authentication with Symfony 2.8

谁说胖子不能爱 提交于 2019-12-03 08:19:45
I'm trying to use the new LdapUserProvider in Symfony 2.8. I believe I have configured everything per the docs . My user can successfully authenticate, and then gets redirected to the secured page. After the redirection is where the issue begins. Symfony tries to bind as the authenticated user, but with a null password, which is rejected by open ldap. Here are the relevant log entries and config values. Config: services: app.ldap: class: Symfony\Component\Ldap\LdapClient arguments: [ "localhost" ] Security: security: firewalls: restricted_area: provider: app_users form_login_ldap: service: app

How to get the root dir of the Symfony2 application?

ぃ、小莉子 提交于 2019-12-03 00:28:57
问题 What is the best way to get the root app directory from inside the controller? Is it possible to get it outside of the controller? Now I get it by passing it (from parameters) to the service as an argument, like this: services: sr_processor: class: Pro\Processor arguments: [%kernel.root_dir%] Is there a better, simpler way to get this information in Symfony2? 回答1: UPDATE 2018-10-21: As of this week, getRootDir() was deprecated. Please use getProjectDir() instead, as suggested in the comment

Symfony 2.8 -> 3.4 Upgrade IsGranted('IS_AUTHENTICATED_ANONYMOUSLY') Throws Errors

不打扰是莪最后的温柔 提交于 2019-12-01 21:36:58
I'm in the process of upgrading Symfony from 2.8 to 3.4 and I have a Authentication Listener. The constructor of the listener public function __construct(EntityManager $entityManager, SessionInterface $session, Security $security, LoggerInterface $logger, Redis $redis, $secret) { $this->entityManager = $entityManager; $this->session = $session; $this->security = $security; $this->logger = $logger; $this->redis = $redis; $this->secret = $secret; } On Request Function which is calling in listener public function onRequest(GetResponseEvent $event) { //Validate token //Get Authorization Header

Executing closure on Twig

可紊 提交于 2019-12-01 06:20:34
I'm trying to execute a closure that resides inside an array on a Twig template. Below you could find a simplified snippet of which I'm trying: //Symfony controller ... $funcs = array( "conditional" => function($obj){ return $obj->getFoo() === $obj::TRUE_FOO } ); $this->render('template_name', array('funcs' => $funcs)); {# Twig template #} {# obj var is set #} ... {% if funcs.conditional(obj)%} <p>Got it</p> {% endif %} When Twig renders the template, throws an exception complaining about an Array to string conversion An exception has been thrown during the rendering of a template ("Notice:

Generating forms with Symfony 2.8 throws a Twig_Error_Runtime

断了今生、忘了曾经 提交于 2019-12-01 02:08:22
Since the last LTS version of Symfony was released few days ago (30.11.2015) I started playing with it. Unfortunately I can't generate a CRUD with write actions with the same code that works fine in Symfony 2.7.7. First I create a new Symfony project using the bash under Linux Mint 17.2: symfony new tasks lts The new directory tasks gets created with a new Symfony 2.8.0 project inside. After adapting the database credentials in app/config/parameters.yml I create the database: app/console doctrine:database:create and generate a new bundle: app/console generate:bundle --namespace=Acme

Symfony 2.8 dynamic ChoiceType options

有些话、适合烂在心里 提交于 2019-11-30 04:02:00
in my project I have some forms with choice types with a lot of options. So I decided to build an autocomplete choice type based on jquery autocomplete, which adds new <option> HTML elements to the original <select> on runtime. When selected they are submitted correctly, but can't be handled within the default ChoicesToValuesTransformer , since the don't exist in my form when I create it. How can I make symfony accept my dynamically added values? I found this answer Validating dynamically loaded choices in Symfony 2 , where the submitted values are used to modify the form on the PRE_SUBMIT