symfony

Force 'fetch joined' relations to include IDENTITY of their ManyToOne relations using HYDRATE_ARRAY?

风流意气都作罢 提交于 2021-01-29 10:58:19
问题 I have a query in which I'm joining a number of tables to my original Person entity. A Person may have multiple Child relations (OneToMany), and a Child may have a School they go to (ManyToOne). Problem is, I don't need the entire School entity that connects to each child, only their id , which is already stored on Child . I'm using a Paginator to iterate through the results and I use HYDRATE_ARRAY to reduce overhead of the ORM parsing data to entity objects. But the id fields of unfetched

Symfony Form - Add required fields to form depending on other field value

喜你入骨 提交于 2021-01-29 10:53:14
问题 I want to add some required fields to my form when an other field has some value. I've tried to do it with PRE_SET_DATA event but I cannot get data in my event. My example here is to add partner name field when a user is married. My UserType public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('familyStatus', ChoiceType::class, [ 'label' => 'Statut de famille', 'label_attr' => [ 'class' => 'fg-label' ], 'attr' => [ 'class' => 'sc-gqjmRU fQXahQ' ],

Twig variables as references

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 09:16:01
问题 I'm trying to change a Twig variable via a php reference but I can't achieve that. I looked around and nor with Twig functions nor with Twig filters I could do what I want. Any idea how to do that? {% set hiding_options_classes = "default" %} {{ hiding_options_func(content.field_hiding_options, hiding_options_classes) }} {{ hiding_options_classes }} In my Twig extension file: public function hiding_options_func($hiding_options, &$hiding_options_classes) { $hiding_options_classes = "coucou"; }

Doctrine return error with “eq”, no with “in”

给你一囗甜甜゛ 提交于 2021-01-29 08:33:46
问题 With Symfony and Doctrine, I have an error with "eq" subquery : It's OK, no error : public function getForums() { $qb = $this->createQueryBuilder('fc'); return $qb ->innerJoin('fc.versions', 'fcv') ->innerJoin('fc.versions', 'fcvl', 'WITH', $qb->expr()->in( 'fcvl.id', $this->_em->createQueryBuilder() ->select('MAX(v.id)') ->from(ForumCategoryVersion::class, 'v') ->where('v.forumCategory = fc') ->getDQL() )) ->select('fc, fcv') ->getQuery() ->getResult(); } Replace in by eq : public function

Symfony calling functions between controllers

坚强是说给别人听的谎言 提交于 2021-01-29 08:21:06
问题 Can anyone give me direction on how to accomplish cross controller variable exchange and/or function calls? I'm new to Symfony and I have a reasonably complex practice sample site which has two controllers - PageController and BlogController. PageController has actions to generate my home, about and contact page. The home page simply has a list of blogs. The BlogController has all the CRUD related functions - create, delete etc My issue is that I want to call my BlogController:createAction

DoctrineParamConverter error after fresh symfony skeleton website installation

人走茶凉 提交于 2021-01-29 07:03:21
问题 I installed symfony 5.1 but when I run application following error occured. Argument 1 passed to Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry or null, instance of Doctrine\Bundle\DoctrineBundle\Registry 回答1: you just need to upgrade your composer with command "composer upgrade". Try it and give feedback. 来源: https://stackoverflow.com/questions/63576784/doctrineparamconverter

Error when loading parameters into Symfony bundle

雨燕双飞 提交于 2021-01-29 06:42:39
问题 I get following error: There is no extension able to load the configuration for "upload_images" (in "/var/www/vhosts/diabetigraph-dev/vendor/verzeilberg/upload-images/src/Resources/services.yaml"). Looked for namespace "upload_images", found "none" This are my files: services.yaml services: verzeilberg\UploadImagesBundle\Service\Rotate: autowire: true upload_images: version: 100 Configuration namespace verzeilberg\UploadImagesBundle\DependencyInjection; use Symfony\Component\Config\Definition

Symfony form category - subcategory

心不动则不痛 提交于 2021-01-29 06:01:26
问题 I try to make a form with category and subcategory like the picture below : So, I made my form like that : ->add('souscategorie', EntityType::class, array( 'label' => false, 'class' => 'App:souscategorie', 'query_builder' => function(EntityRepository $er) { return $er->createQueryBuilder('souscategorie') ->leftJoin('souscategorie.categorie', 'categorie') ->addSelect('souscategorie') ->addSelect('categorie') ; }, 'expanded'=> true, 'multiple'=> true, 'choice_label' => function($sousCategorie){

Symfony 2 / Php : json_encode

≯℡__Kan透↙ 提交于 2021-01-29 02:58:42
问题 I've been looking to a solution to my problem for a while without success so I'm asking here. How can we return a json-encoded result on an array of objects (or just an object) containing private properties ? Indeed, when you use json_encode($myObject), it won't display the private or protected properties, which are present everywhere in the model when using Symfony... I'm surprised I couldn't find any method like json_encode that would call getters instead of properties themselves. Any idea

Running python script in Laravel Controller: “sh: 1: python: not found ”

╄→尐↘猪︶ㄣ 提交于 2021-01-28 19:46:30
问题 I am trying to run a python script in my Laravel PHP controller using Symfony Process. The python file is located in the public directory. The python file is: import requests URL = 'someURL.com' response = request.get(url); print(response) Here is my code in my PHP Controller: $process = new Process('python '.public_path('MyPython.py')); $process->run(); //executes after the command finishes if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } Log::error($process-