symfony

Referencing a template in Twig / Symfony2

删除回忆录丶 提交于 2021-01-28 00:40:18
问题 A Twig template in one bundle calls another Twig template in another bundle, but I can't reference it. The file is in this folder: src/Company/Bundle/ActivityBundle/Resources/views/Default/index.html.twig And I am trying to reference it from a Twig file in another bundle like this: {% extends "Company/Bundle/ActivityBundle/index.html.twig" %} I've tried every possible combination, but it just doesn't pick it up and I get a "Twig_Error_Loader: Unable to find template" error 回答1: I think you've

DQL query returns: StateFieldPathExpression or SingleValuedAssociationField expected

主宰稳场 提交于 2021-01-27 23:50: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

Autowire symfony CacheInterface depending on environment

天涯浪子 提交于 2021-01-27 22:50:10
问题 I am trying to use different cache system on my environments. I would like to have, for example, Filesystem for dev and memcached for prod . I am using symfony 3.3.10 . To achieve this, I would like to autowire the CacheInterface as follow: use Psr\SimpleCache\CacheInterface; class Api { public function __construct(CacheInterface $cache) { $this->cache = $cache; } } Here are my configuration files: config_dev.yml : framework: cache: app: cache.adapter.filesystem config_prod.yml : framework:

Symfony routing not working

不想你离开。 提交于 2021-01-27 21:38:53
问题 I am using a normal host (i.e access to web pages via public_html and no access to php (apache) configuration ). so here what i did renamed my web dir => public_html renamed app.php (prod application) to index.php I've also added a route to my page (template) named "littlebird" Problem when I call www.mywebsite.com/littlebird => 404 page not found but when I use www.mywebsite.com/index.php/littlebird every thing works just fine. 回答1: My original guess was that you didn't have the mod_rewrite

Symfony / Doctrine - Multiple Users Types

拟墨画扇 提交于 2021-01-27 20:36:52
问题 I'm creating a website that should have at least two types of users, Company and Client, two of them have the same login form and different registration forms, and they can send messages to each other ... Normaly (Without think about Doctrine) I think the database should look something like that: User (id, email, password, facebook_id, roles) Company (id, user_id, name, city, ...) Client (id, user_id, name, sex ...) Messages (id, sender_id(user_id), receiver_id(user_id), message, ...) ... So

Sonata admin export fields with collection fields

Deadly 提交于 2021-01-27 20:01:25
问题 I'm trying to make custom columns for export, but I can't access children. Is there any possibility to do that ? My code at this moment looks like this: public function getExportFields() { return [ 'ID' => 'id', 'Transaction number' => 'transactionNumber', 'Loan account' => 'loan', 'Loan name' => 'loan.name', 'Amount' => 'amount', //'Amount ($)' => '', 'Transaction type' => 'transactionCategory', 'Reference' => 'transactionAssociation.cashTransaction.transactionNumber', 'Date' => 'date' ]; }

delete form-control in form-row symfony/twig

你离开我真会死。 提交于 2021-01-27 19:08:45
问题 When i create this builder $builder ->add('categorie', EntityType::class, [ // This field shows all the categories 'class' => Categorie::class, 'mapped' => false, 'multiple' => true, 'attr' => ['class' => 'mdb-select'] ]) and when i do form_row(form.name) i see class has value 'form-control' automaticaly, but me i'm use MDBootstrap and i want to set only mdb-select 回答1: It is caused by one of the default form themes of Symfony, I think by default currently it's the bootstrap 4 theme. To get

$this->container is NULL in Controller on Symfony3

早过忘川 提交于 2021-01-27 18:47:28
问题 I got an annoying problem when I call this in a controller (ClientDomainController) : $this->getDoctrine()->getManager(); I got this error : Call to a member function has() on null I looked the stack trace and see that : $this->container is null My controller extends from the Symfony Controller component : use Symfony\Bundle\FrameworkBundle\Controller\Controller; The funny thing is that in an other controller (HomeController) I make the exact same things : Extend from Controller (the exact

Doctrine can't generate a schema when using single table inheritance?

≯℡__Kan透↙ 提交于 2021-01-27 17:27:52
问题 An interesting problem. I'm building an application using Symfony 2 and I'm trying to get Doctrine to auto-generate my schema from my entity classes. I have two entity classes, Invoice and CreditNote . CreditNote extends Invoice . They look like this - Invoice.php - namespace My\Bundle\BillingBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="invoice") * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="discriminator", type="string") *

Many dependencies in service

不打扰是莪最后的温柔 提交于 2021-01-27 15:19:46
问题 I have trouble with dependencies in my application in service layer. I have following class: <?php class UserService{ private $userRepository; private $vocationService; private $roleService; public function __construct(UserRepository $userRepository, VocationService $vocationService, RoleService $roleService) { $this->userRepository = $userRepository; $this->vocationService = $vocationService; $this->roleService = $roleService; } } There are only three dependencies which I'm injecting. Assume