mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
eventlistener added to capitalize names correctly
This commit is contained in:
parent
09e6872724
commit
96e38a8a6d
@ -46,6 +46,7 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
|
|||||||
$loader->load('services/fixtures.yaml');
|
$loader->load('services/fixtures.yaml');
|
||||||
$loader->load('services/serializer.yaml');
|
$loader->load('services/serializer.yaml');
|
||||||
$loader->load('services/repository.yaml');
|
$loader->load('services/repository.yaml');
|
||||||
|
$loader->load('services/doctrineEventListener.yaml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepend(ContainerBuilder $container)
|
public function prepend(ContainerBuilder $container)
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ThirdPartyBundle\EventListener;
|
||||||
|
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
|
||||||
|
use const MB_CASE_TITLE;
|
||||||
|
|
||||||
|
class ThirdPartyEventListener
|
||||||
|
{
|
||||||
|
public function prePersistThirdParty(ThirdParty $thirdparty): void
|
||||||
|
{
|
||||||
|
if ($thirdparty->getKind() !== 'company') {
|
||||||
|
$firstnameCaps = mb_convert_case(mb_strtolower($thirdparty->getFirstname()), MB_CASE_TITLE, 'UTF-8');
|
||||||
|
$firstnameCaps = ucwords(strtolower($firstnameCaps), " \t\r\n\f\v'-");
|
||||||
|
$thirdparty->setFirstName($firstnameCaps);
|
||||||
|
|
||||||
|
$lastnameCaps = mb_strtoupper($thirdparty->getName(), 'UTF-8');
|
||||||
|
$thirdparty->setName($lastnameCaps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
Chill\ThirdPartyBundle\EventListener\ThirdPartyEventListener:
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
-
|
||||||
|
name: 'doctrine.orm.entity_listener'
|
||||||
|
event: 'prePersist'
|
||||||
|
entity: 'Chill\ThirdPartyBundle\Entity\ThirdParty'
|
||||||
|
method: 'prePersistThirdParty'
|
Loading…
x
Reference in New Issue
Block a user