symfony-2.3

Sonata Admin - Custom AJAX call

蓝咒 提交于 2019-12-14 03:14:05
问题 I have created a custom list view in sonata admin to display a calendar. I'm trying to add events to the calendar dynamically, but I'm getting an error with the CSRF token being invalid. I have the following code: public function listAction() { if (false === $this->admin->isGranted('LIST')) { throw new AccessDeniedException(); } $datagrid = $this->admin->getDatagrid(); $formView = $datagrid->getForm()->createView(); // set the theme for the current Admin Form $this->get('twig')->getExtension(

how to check all available variable that have been passed form controller to twig template

帅比萌擦擦* 提交于 2019-12-13 21:47:04
问题 how to check all variable exist Exp in Controller return this to pass to twig template : return $this->render('index/index.html.twig', [ 'department'=>$departments,'URILink'=>$URILink,'departmentDetail'=>$departmentDetails, 'contentCell'=>$this->mContentCell ]); then twig template can reuse those variable by doin this index.html.twig: </div> {{ include ('department_list.html.twig',{'departments':department,'URILink':URILink}) }}</div> for Comparison in smarty template we can use this: get

Symfony2 - Call EmailValidator inside a Custom Validator

非 Y 不嫁゛ 提交于 2019-12-13 13:18:39
问题 I'm creating a custom validator constraint to validate a "Contact", which is something like "John Doe <jdoe@example.com>". Following the Cookbook I've created the Constraint Class: <?php namespace MyCompany\MyBundle\Validator\Constraints; use Symfony\Component\Validator\Constraint; /** * @Annotation */ class Contact extends Constraint { public $message = 'The string "%string%" is not a valid Contact.'; } and also created the validator: <?php namespace MyCompany\MyBundle\Validator\Constraints;

ElasticSearch RoutingMissingException

回眸只為那壹抹淺笑 提交于 2019-12-13 11:56:40
问题 I'm trying to populate objects having parent-child relation, but get an error: [Elastica\Exception\ResponseException] RoutingMissingException[routing is required for [myindex]/[comment]/[12345]] Excerpt from type conf: article: _source: enabled: false mappings: ... comment: _source: enabled: false _parent: type: article property: article_id identifier: id _routing: required: true path: article_id mappings: article: type: long index: not_analyzed ... Cant understand what I am missing here....

Implicit joins and Where in Doctrine - how?

佐手、 提交于 2019-12-12 17:45:33
问题 I have a ManyToMany relation of Users and Roles. That is I have User table and entity class, Role table and entity and a joining table "user_role" width user_id and role_id columns. Now, I recently tried to get users with their roles, by using joins, like this: $qb = $this->createQueryBuilder('u') ->join('user_role', 'ur', Join::ON, "I didn't know what to put here, nothing worked ") Anyway, thanks to this answer I added correct mapping (annotations) to my both entity classes and then removed

Dropdown Ajax onchange SonataAdminBundle Symfony2 Issue

守給你的承諾、 提交于 2019-12-12 11:34:04
问题 I am trying to implement onchange dropdown in SonataAdminBundle. My Entity is like class BuilderHomePage { /** * @var integer * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var \Hello\FrontendBundle\Entity\MtContentType * * @ORM\ManyToOne(targetEntity="Hello\FrontendBundle\Entity\MtContentType") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="content_type_id", referencedColumnName="id") * }) */ private

How to delete an entity from a template with a list of entities (CRUD)?

China☆狼群 提交于 2019-12-12 07:58:42
问题 Explanation: I have generated the CRUD of an entity, getting the following default actions: indexAction(): lists all entities. showAction($id): finds (by ID) and displays an entity. deleteAction($id): deletes an entity. another actions. So, I have seen I can only delete an entity within the actions that use the param $id (e.g.: showAction($id) ) but I want to delete an entity inside the indexAction template because I save a step to users. The deleteAction needs a request, an ID and use the

SULU CMS installation errors with Laravel Homestead

六月ゝ 毕业季﹏ 提交于 2019-12-12 04:30:54
问题 Follow this document http://docs.sulu.io/en/latest/book/getting-started.html at the end of installation process I got this error: Target: cache cache:clear ({"--no-optional-warmers":true,"--no-debug":true,"--no-interaction":true}) // Clearing the admin cache for the dev environment with debug true [Symfony\Component\Filesystem\Exception\IOException] Failed to remove directory "/home/vagrant/Code/sulu/var/cache/admin/de~/doctrine": . sulu:build [-D|--nodeps] [--destroy] [-h|--help] [-q|--quiet

In Doctrine, do I need do create a class only to make a join?

你离开我真会死。 提交于 2019-12-12 03:33:07
问题 I'm trying to make a join in my repository class (Symfony 3 with Doctrine). This is how it looks like: public function findByRole($roles){ $qb = $this->createQueryBuilder('u') ->join('user_role', 'ur', Join::ON, 'ur.id = u.customerId'); $q = $qb->getQuery(); $users = $q->getArrayResult(); dump($users); } And I've got this error: [Semantical Error] line 0, col 49 near 'user_role ur': Error: Class 'user_role' is not defined. There are two entity classes defined - User and Role. And Role is a

Symfony2 Catchable Fatal Error: Object of class DateTime could not be converted to string

一世执手 提交于 2019-12-12 02:52:32
问题 I have a person (Employee) search that is supposed to return a list of people by name, surname, date of birth and some other parameters. the search works fine for every parameter exempt for the date parameters, like date of birth. my controller code is this: $aWorker = new Worker(); $searchWorkerForm = $this->createFormBuilder($aWorker) ->add('omang', 'text', array('required' => false)) ->add('workerName', 'text', array('required' => false)) ->add('workerSurname', 'text', array('required' =>