Symfony4: validation contraints translation are not applied - symfony

Context
I am working on a Symfony 4 application, with an OroPlatform overlay.
I have followed this tutorial : https://symfony.com/doc/4.4/validation/translations.html
Here is my code :
<?php
/**
* #ORM\Entity(repositoryClass="Baltimore\Bundle\AppBundle\Repository\SubscriptionRepository")
* #ORM\Table(name="app_subscription")
*/
class Subscription
{
/**
* #ORM\Id()
* #ORM\GeneratedValue(strategy="AUTO")
* #ORM\Column(type="integer")
*
* #var int
*/
private $id;
/**
* #ORM\Column(type="integer")
* #Assert\NotBlank(message="author.name.not_blank")
* #Assert\Type(type="integer")
*
* #var int
*/
private $number;
}
As you can see, I have put this line to change to default NotBlank message #Assert\NotBlank(message="author.name.not_blank")
Issue
My current locale is fr_FR, I have check with the following code :
<?php
$locale = $request->getLocale();
Here is my translations/validators.fr_FR.xlf (path is relative to the project root directory) :
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="fr" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="author.name.not_blank">
<source>author.name.not_blank</source>
<target>Veuillez entrer un nom d'auteur</target>
</trans-unit>
</body>
</file>
</xliff>
Cache is cleared symfony console cache:clear
But nothing change, the error message is author.name.not_blank instead of my translation.
The output of the command line php bin/console debug:translation fr BaltimoreAppBundle :

It seems to came from the fact that OroPlatform have his own command line to update translation.
Here is my working configuration :
# /translations/validators.fr_FR.yml
This value should not be blank.: Cette valeur ne doit pas être vide
Then, I run these commands : php bin/console clear:cache and php bin/console oro:translation:dump
Now I can see my updated translation.

Related

The class Mock_* was not found in the chain configured namespaces App\Entity [Symfony 5.3][PHPUnit 8.5]

I am trying to write PHPUnit tests for my Symfony 5.3 project with some Repositories mocked with others real.
$ bin/console -v
Symfony 5.3.10 (env: dev, debug: true)
$ bin/phpunit -V
PHPUnit 8.5.19 by Sebastian Bergmann and contributors.
Doctrine\Persistence\Mapping\MappingException: The class 'Mock_SType_b1b7aee4' was not found in the chain configured namespaces App\Entity
/var/www/cir/vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/MappingException.php:23
/var/www/cir/vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/Driver/MappingDriverChain.php:91
/var/www/cir/vendor/doctrine/doctrine-bundle/Mapping/MappingDriver.php:45
/var/www/cir/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:156
/var/www/cir/vendor/doctrine/doctrine-bundle/Mapping/ClassMetadataFactory.php:19
/var/www/cir/vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php:382
/var/www/cir/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:85
/var/www/cir/vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php:251
/var/www/cir/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:293
/var/www/cir/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1789
/var/www/cir/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1764
/var/www/cir/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:629
/var/www/cir/src/Component/User/UserManager.php:1059
/var/www/cir/src/Component/User/UserManager.php:383
/var/www/cir/tests/Component/User/Manager/Creation/ATCPTest.php:146
I have created a KernelTestCase where:
$sTypeRepository = $this->createStub(STypeRepository::class);
So I tried to use the actual Repository:
$sTypeRepository = static::getContainer()->get('doctrine')->getRepository(SType::class);
and I get error:
TypeError: Argument 2 passed to App\Component\User\UserManager::__construct() must be an instance of App\Repository\STypeRepository, instance of Doctrine\ORM\EntityRepository given, called in /var/www/cir/tests/Component/User/Manager/Creation/ATCPTest.php on line 122
/var/www/cir/src/Component/User/UserManager.php:214
/var/www/cir/tests/Component/User/Manager/Creation/ATCPTest.php:122
Other tests run fine for other mocked classes, like here:
$this->SUserRoleRepository = $this->createStub(SUserRoleRepository::class);
So, why do I get a MappingException or TypeError, respectively, for some repositories but not others? Perhaps help me to understand the errors better? Thanks!
The issue was that my SType entity did not have an accurate #ORM\Entity(...) annotation. I had:
/**
* SType.
*
* #ORM\Table(name="s_type", indexes={#ORM\Index(name="idx_s_type_1", columns={"type_group"}), #ORM\Index(name="idx_s_type_2", columns={"code"})})
* #ORM\Entity
*/
class SType {}
Needed the repositoryClass relation:
/**
* SType.
*
* #ORM\Table(name="s_type", indexes={#ORM\Index(name="idx_s_type_1", columns={"type_group"}), #ORM\Index(name="idx_s_type_2", columns={"code"})})
* #ORM\Entity(repositoryClass="App\Repository\STypeRepository")
*/
class SType {}

Jupyter download as pdf

How can I solve this problem when I want to download as pdf through Jupyter?
nbconvert failed: PDF creating failed, captured latex output:
Failed to run "['xelatex', './notebook.tex', '-quiet']" command:
This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./notebook.tex
LaTeX2e <2018-12-01>
'''(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size11.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/tcolorbox/tcolorbox.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-li
sts.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
(/usr/local/texlive/2019/texmf-dist/tex/latex/ms/everyshi.sty))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-def/xetex.def)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-xetex.de
f
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-dvipdfmx
.def
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p
df.def))))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.
code.tex)) (/usr/local/texlive/2019/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.
tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic
.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo
nometric.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando
m.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa
rison.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round
.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integ
erarithmetics.code.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)
)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst
ruct.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage
.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicst
ate.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransform
ations.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.cod
e.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.c
ode.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathproce
ssing.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.cod
e.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.cod
e.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.
code.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretranspare
ncy.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.
tex)))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.cod
e.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.
tex)
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-0-65.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-1-18.sty)) (/usr/local/texlive/2019/texmf-dist/tex/latex/tools/verbatim.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/environ/environ.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/trimspaces/trimspaces.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tcolorbox/tcbbreakable.code.tex
Library (tcolorbox): 'tcbbreakable.code.tex' version '4.20'
)) (/usr/local/texlive/2019/texmf-dist/tex/latex/parskip/parskip.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ifluatex.sty)))))
(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/iftex.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/tuenc.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/caption/caption.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/caption/caption3.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/adjustbox.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/adjcalc.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/trimclip.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/collectbox/collectbox.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/tc-xetex.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/ifoddpage/ifoddpage.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/varwidth/varwidth.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/float/float.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/enumerate.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/textcomp.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/upquote/upquote.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/eurosym/eurosym.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v3.2a <2019/01/15> (tvz))
(/usr/local/texlive/2019/texmf-dist/tex/latex/oberdiek/grffile.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/local/texlive/2019/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/local/texlive/2019/texmf-dist/tex/latex/url/url.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/hyperref/hxetex.def
(/usr/local/texlive/2019/texmf-dist/tex/latex/hyperref/puenc.def)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/stringenc.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/titling/titling.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/longtable.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/booktabs/booktabs.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/enumitem/enumitem.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/ulem/ulem.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/jknapltx/mathrsfs.sty)
No file notebook.aux.
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1cmr.fd)
ABD: EveryShipout initializing macros
(/usr/local/texlive/2019/texmf-dist/tex/latex/caption/ltcaption.sty)
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
*geometry* verbose mode - [ preamble ] result:
* driver: xetex
* paper: <default>
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes:
* h-part:(L,W,R)=(72.26999pt, 469.75502pt, 72.26999pt)
* v-part:(T,H,B)=(72.26999pt, 650.43001pt, 72.26999pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=469.75502pt
* \textheight=650.43001pt
* \oddsidemargin=0.0pt
* \evensidemargin=0.0pt
* \topmargin=-37.0pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=11.0pt
* \footskip=30.0pt
* \marginparwidth=59.0pt
* \marginparsep=10.0pt
* \columnsep=10.0pt
* \skip\footins=10.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \#twocolumnfalse
* \#twosidefalse
* \#mparswitchfalse
* \#reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)
(/usr/local/texlive/2019/texmf-dist/tex/latex/ucs/ucsencs.def)
(/usr/local/texlive/2019/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
Package hyperref Warning: Rerun to get /PageLabels entry.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsb.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/jknapltx/ursfs.fd)
LaTeX Warning: No \author given.
! LaTeX Error: Command \b already defined.
Or name \end... illegal, see p.192 of the manual.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.384 \newcommand{\b}{\mathbf{b}}
?
! Emergency stop.
...
l.384 \newcommand{\b}{\mathbf{b}}
No pages of output.
Transcript written on notebook.log.

symfony: Format date in assert message

I have assertion on my entity to validate dates. It's work well, but the outuput is formated whith time. I need only the date. (The text is in french)
My entity :
/**
* #var \DateTime
* #Assert\DateTime(format="d/m/Y")
* #Assert\LessThanOrEqual(
* value="-2 days",
* message="rapports.max_date"
* )
*/
protected $dateDebut;
My translation file :
max_date: 'La date saisie doit être inférieur ou égale au {{ compared_value }}.'
That output is "La date saisie doit être supérieur ou égale au 1 janv. 2015 à 01:00.". I want "La date saisie doit être supérieur ou égale au 01/001/2015."
I want to format the 'compared_value'. WHo can I do that ?
Maybe use the date_format filter:
max_date: 'La date saisie doit être inférieur ou égale au {{ compared_value | date_format('Y-m-d') }}.'
You can do the following:
Write a service and make it globally available to the twig engine.
This service has to define a public function that takes the compared_value, parses the wrongly formatted date, and outputs the correctly formatted one.
So:
class MyService
{
public function parse($compared_value) {
return date_format('Y-m-d', strtotime($compared_value));
}
}
in config.yml
twig:
globals:
my_service: '#my_service'
services:
my_service:
class: AppBundle\Service\MyService
and finally
max_date: 'La date saisie doit être inférieur ou égale au {{ my_service.parse(compared_value) }}.'

Warning: include(1) [function.include]: failed to open stream

I have this massage at the top of the wordpress site and can`t enter in admin area!
Warning: include(1) [function.include]: failed to open stream: No such
file or directory in /home/pharmme/public_html/bphsa.bg/wp-config.php
on line 21
Warning: include() [function.include]: Failed opening '1' for
inclusion (include_path='.:/usr/local/php52/pear') in
/home/pharmme/public_html/bphsa.bg/wp-config.php on line 21
What is the problem?
?php
/**
* The*/include /* base configuration for WordPress
*
*
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://codex.wordpress.org/Editing_wp-config.php
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'pharmme_wp573'); <--- line 21
The second line is the problem.
* The*/include /* base configuration for WordPress
should be:
* The include base configuration for WordPress
Now PHP thinks it the include function. Which is causing the error.

Duplicate index on sqlite, not on mysql

I have a entity definition that works on dev and production envs (mysql), but not on test (sqlite):
/**
* Invoice
*
* #ORM\Table(name="invoice", indexes={
* #ORM\Index(name="ref_idx", columns={"ref"}),
* #ORM\Index(name="created_at_idx", columns={"created_at"}),
* #ORM\Index(name="paid_idx", columns={"paid"}),
* #ORM\Index(name="is_valid_idx", columns={"is_valid"}),
* #ORM\Index(name="canceled_idx", columns={"canceled"})
* })
* #ORM\Entity(repositoryClass="AppBundle\Repository\InvoiceRepository")
*/
class Invoice
// [...]
When I run doctrine:schema:create or doctrine:schema:update --force on test env, I have the following error:
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'CREATE INDEX created_at_idx ON invoice (created_at)':
SQLSTATE[HY000]: General error: 1 index created_at_idx already exists
[PDOException]
SQLSTATE[HY000]: General error: 1 index created_at_idx already exists
Is someone already had this kind of issue? How to solve/ignore it?
Thanks.
The solution is here: https://stackoverflow.com/a/24634713/1731473
In a nutshell, your index must have a unique name across your database.
So you can't have:
invoice -> created_at_idx
user -> created_at_idx
But:
invoive -> invoice_created_at_idx
user -> user_created_at_idx

Resources