symfony

WHERE … IN query with sub-query in Doctrine queryBuilder or equivalent

穿精又带淫゛_ 提交于 2021-01-28 07:01:34
问题 In my Symfony 4 project I have a User entity and a UserRepository . I'm trying to implement the equivalent of this SQL query in the QueryBuilder (Doctrine 2) or even in DQL . SELECT * FROM user WHERE account_manager_id IN (SELECT id FROM user WHERE account_manager_id = :managerAdminId AND roles LIKE '%ROLE_MANAGER%') Or maybe use a different syntax. I tried different things, but couldn't figure out how to write the WHERE ... IN with the sub-query. This is all I could come up with, which I don

How to “install” Bootstrap Datetimepicker on Symfony?

China☆狼群 提交于 2021-01-28 06:40:34
问题 I have files like assets/css/bootstrap-4.3.1.css and assets/js/bootstrap-4.3.1.js and in webpack.config I have .addEntry('js/bootstrap','./assets/js/bootstrap-4.3.1.js') and .addStyleEntry('css/bootstrap', './assets/css/bootstrap-4.3.1.css') I need bootstrap-3.3.1.js and bootstrap-3.3.1.css , respectively. I need to install these in yarn in order to ensure that I have my perequisites for Bootstrap datetimepicker. Tried with yarn add bootstrap@3.3.1 without any luck. Then I tried to download

Symfony2 open_basedir restriction in effect

。_饼干妹妹 提交于 2021-01-28 05:49:46
问题 i'm trying to deploy a symfony 2.7 project to shared hosting. Everything works fine on localhost but on the server i got big fat error... When i try to hit the site: http://infinityproperty.sitetester.biz/ I was getting a error : Warning: is_dir(): open_basedir restriction in effect. File(/srv/www/infinityproperty.sitetester.biz/web) is not within the allowed path(s): When I try to enter 3-4 times it removes the error and i can see the structure. But the issue is there. Also no images from

Symfony Doctrine update query fail

浪尽此生 提交于 2021-01-28 05:33:35
问题 My code is: $query = $em->createQuery("UPDATE AppBundle:Project u SET u.name=1, u.key=?2, u.leader=?3 WHERE u.id = ?4"); $query->setParameter(1, $project->name); $query->setParameter(2, $project->key); $query->setParameter(3, $project->lead->name); $query->setParameter(4, $project->id); $result = $query->getResult(); Now when I run it, it gives me a error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your

How to inject global variables into all templates?

≡放荡痞女 提交于 2021-01-28 04:58:53
问题 In my twig template there are some variables that are required on each page like userName , userId or userImage . What is the best way to inject them into the template? I already read the article How to Inject Variables into all Templates but how could I write a variable (e.g. current user) into the config/packages/twig.php file? Right now there is code like this in every controller: return $this->render('admin/users/index.html.twig', [ "allUsers" => $allUsers, "pageTitle" =>

Symfony2 form unchecked checkbox not taken into account, why?

旧时模样 提交于 2021-01-28 04:23:43
问题 When I send a form with an unchecked checkbox, if the related entity property equals true , then it does not change to false . The other way round (setting property to true when the form is sent with a checked checkbox) works fine, as well as all the forms other fields saving. Here is how I build the form and declare the related property: // --- Form creation function EntityType::buildForm() --- $builder->add('secret', 'checkbox', array( 'required' => false )); // --- Entity related property,

Symfony2: class 'Doctrine\Common\Collections\ArrayCollection' was not found in the chain configured namespaces

烈酒焚心 提交于 2021-01-28 04:03:38
问题 Error occurs when attempting to persist a one-to-many relationship. In particular, a client may have multiple household members; a given household member is associated with one and only one client. [I am new to Symfony so errors are expected!] Your guidance gratefully accepted. N.B. Alternate controller snippet below yields integrity constraint error by trying to set the client's id in the household table to null. Clients Entity snippet namespace Mana\AdminBundle\Entity; use Doctrine\ORM

Symfony2: class 'Doctrine\Common\Collections\ArrayCollection' was not found in the chain configured namespaces

让人想犯罪 __ 提交于 2021-01-28 03:43:17
问题 Error occurs when attempting to persist a one-to-many relationship. In particular, a client may have multiple household members; a given household member is associated with one and only one client. [I am new to Symfony so errors are expected!] Your guidance gratefully accepted. N.B. Alternate controller snippet below yields integrity constraint error by trying to set the client's id in the household table to null. Clients Entity snippet namespace Mana\AdminBundle\Entity; use Doctrine\ORM

DQL query returns: StateFieldPathExpression or SingleValuedAssociationField expected

跟風遠走 提交于 2021-01-28 02:51:00
问题 I have the following DQL query: public function findByIdJoinedToCodeExample($pageId) { $query = $this->getEntityManager() ->createQuery(' SELECT c FROM acmeStyleGuideBundle:codeExample c JOIN c.PageContent p WHERE p.codeExample = :cex' ) ->setParameter('cex', $pageId); try { return $query->getResult(); } catch (\Doctrine\ORM\NoResultException $e) { return null; } } It is attempting to retreive data from an entity called codeExample which has a ManyToOne relationship with an entity called

“App\Entity\User object not found by the @ParamConverter annotation”

眉间皱痕 提交于 2021-01-28 00:51:28
问题 I have a problem with one of my route when I try to access it, I have this error : "App\Entity\CompanyUser object not found by the @ParamConverter annotation" Many people have the same problem but none of the solutions I could see could solve my problem. My function edit : private $passwordEncoder; public function __construct(UserPasswordEncoderInterface $passwordEncoder) { $this->passwordEncoder = $passwordEncoder; } /** * @Route("/{id}/edit", name="company_user_edit", methods={"GET","POST"}