* removed obsolete libs that are available as separate package
* updated fixtures * updated fixture import soluzion * updated jwt token handling parts
This commit is contained in:
parent
d77a3e4211
commit
8f843a8194
@ -54,7 +54,8 @@
|
||||
"zendframework/zend-mail": "^2.10.0",
|
||||
"zendframework/zend-permissions-rbac": "^3.0.0",
|
||||
"zendframework/zend-servicemanager": "^3.3",
|
||||
"zendframework/zend-stdlib": "^3.1"
|
||||
"zendframework/zend-stdlib": "^3.1",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0.1",
|
||||
|
||||
16
composer.lock
generated
16
composer.lock
generated
@ -4946,16 +4946,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "7.4.3",
|
||||
"version": "7.4.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "c151651fb6ed264038d486ea262e243af72e5e64"
|
||||
"reference": "b1be2c8530c4c29c3519a052c9fb6cee55053bbd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c151651fb6ed264038d486ea262e243af72e5e64",
|
||||
"reference": "c151651fb6ed264038d486ea262e243af72e5e64",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b1be2c8530c4c29c3519a052c9fb6cee55053bbd",
|
||||
"reference": "b1be2c8530c4c29c3519a052c9fb6cee55053bbd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -5026,7 +5026,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2018-10-23T05:57:41+00:00"
|
||||
"time": "2018-11-14T16:52:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "roave/security-advisories",
|
||||
@ -5102,7 +5102,7 @@
|
||||
"pagarme/pagarme-php": ">=0,<3",
|
||||
"paragonie/random_compat": "<2",
|
||||
"paypal/merchant-sdk-php": "<3.12",
|
||||
"phpmailer/phpmailer": ">=5,<5.2.24",
|
||||
"phpmailer/phpmailer": ">=5,<5.2.27|>=6,<6.0.6",
|
||||
"phpunit/phpunit": ">=4.8.19,<4.8.28|>=5.0.10,<5.6.3",
|
||||
"phpwhois/phpwhois": "<=4.2.5",
|
||||
"phpxmlrpc/extras": "<0.6.1",
|
||||
@ -5154,7 +5154,7 @@
|
||||
"symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7",
|
||||
"tecnickcom/tcpdf": "<6.2.22",
|
||||
"thelia/backoffice-default-template": ">=2.1,<2.1.2",
|
||||
"thelia/thelia": ">=2.1.0-beta1,<2.1.3|>=2.1,<2.1.2",
|
||||
"thelia/thelia": ">=2.1,<2.1.2|>=2.1.0-beta1,<2.1.3",
|
||||
"theonedemon/phpwhois": "<=4.2.5",
|
||||
"titon/framework": ">=0,<9.9.99",
|
||||
"truckersmp/phpwhois": "<=4.3.1",
|
||||
@ -5211,7 +5211,7 @@
|
||||
}
|
||||
],
|
||||
"description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it",
|
||||
"time": "2018-11-01T18:39:28+00:00"
|
||||
"time": "2018-11-16T03:31:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit-reverse-lookup",
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
return [
|
||||
'acl_config' => [
|
||||
'unguarded_routes' => [
|
||||
'home',
|
||||
'api.auth.login',
|
||||
'api.ping',
|
||||
'api.xlsx',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,253 +1,68 @@
|
||||
Users:
|
||||
User_1:
|
||||
User_Zero:
|
||||
id: 1
|
||||
name: Dávid
|
||||
email: yvan@yvan.hu
|
||||
wantsEmail: true
|
||||
wantsEmail: false
|
||||
job: tesztelő
|
||||
phone: "+36 1 123 4567"
|
||||
phone: "+36 70 450 5006"
|
||||
roles: admin
|
||||
active: true
|
||||
# uzemeltetesi_vezeto
|
||||
User_MajorosZoltan:
|
||||
# uzemeltetesi_vezeto - gül baba side
|
||||
User_UZVEZ:
|
||||
id: 10
|
||||
name: Majoros Zoltán
|
||||
email: techsupport.eycb@coe.int
|
||||
name: UZVEZ
|
||||
email: uzvez@bggeneral.hu
|
||||
wantsEmail: false
|
||||
job: technical support
|
||||
phone: "+36-1-438-0174"
|
||||
job: uzvez
|
||||
phone: "+36-1-123-1234"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_RozsaSandor:
|
||||
id: 11
|
||||
name: Rózsa Sándor
|
||||
email: techsupport.eycb@coe.int
|
||||
wantsEmail: false
|
||||
job: technical support
|
||||
phone: "+36-1-438-0174"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_HorvathCsaba:
|
||||
id: 12
|
||||
name: Horváth Csaba
|
||||
email: techsupport.eycb@coe.int
|
||||
wantsEmail: false
|
||||
job: technical support
|
||||
phone: "+36-1-438-0174"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_PohlottLaszlo:
|
||||
id: 13
|
||||
name: Pohlott László
|
||||
email: techsupport.eycb@coe.int
|
||||
wantsEmail: false
|
||||
job: technical support
|
||||
phone: "+36-1-438-0174"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_BalogKaroly:
|
||||
id: 14
|
||||
name: Balog Károly
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_SzenteRoland:
|
||||
id: 15
|
||||
name: Szente Roland
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_NekamIstvan:
|
||||
id: 16
|
||||
name: Nékám István
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_KotroczoIstvan:
|
||||
id: 17
|
||||
name: Kotroczó István
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_LandszmannZsolt:
|
||||
id: 18
|
||||
name: LandszmannZsolt
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_GoliczaZoltan:
|
||||
id: 19
|
||||
name: Golicza Zoltán
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_EckermannTibor:
|
||||
id: 20
|
||||
name: Eckermann Tibor
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_FarkasAndras:
|
||||
id: 21
|
||||
name: Farkas András
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_SimonZoltan:
|
||||
id: 22
|
||||
name: Simon Zoltán
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_ZsoldosGeza:
|
||||
id: 23
|
||||
name: Zsoldos Géza
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_MareschDavid:
|
||||
id: 24
|
||||
name: Maresch Dávid
|
||||
email: keyrm.beik@gmail.com
|
||||
wantsEmail: false
|
||||
job: biztonsági szolgálat
|
||||
phone: "+36-1-438-1041"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
canChangePassword: false
|
||||
User_BuczkoAttila:
|
||||
id: 25
|
||||
name: Buczkó Attila
|
||||
email: attila.buczko@coe.int
|
||||
wantsEmail: true
|
||||
job: technikus
|
||||
phone: "+36-1-438-1078"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
User_KedveCsaba:
|
||||
id: 26
|
||||
name: Kedve Csaba
|
||||
email: csaba.kedves@coe.int
|
||||
wantsEmail: true
|
||||
job: üzemeltetési vezető
|
||||
phone: "+36-1-438-1079"
|
||||
roles: uzemeltetesi_vezeto
|
||||
active: true
|
||||
# ufo
|
||||
User_DrHeimPeter:
|
||||
# ufo - minisztérium
|
||||
User_UFO:
|
||||
id: 40
|
||||
name: Dr. Heim Péter
|
||||
email: peter.heim@mfa.gov.hu
|
||||
wantsEmail: true
|
||||
job: főosztályvezető h.
|
||||
phone: ""
|
||||
name: UFO
|
||||
email: ufo@bggeneral.hu
|
||||
wantsEmail: false
|
||||
job: ufo
|
||||
phone: "+36-1-123-1234"
|
||||
roles: ufo
|
||||
active: true
|
||||
User_KrivdaLaszlo:
|
||||
id: 41
|
||||
name: Krivda László
|
||||
email: krivda@t-online.hu
|
||||
wantsEmail: true
|
||||
job: műszaki ellenőr
|
||||
phone: "+36 30 942 9072"
|
||||
roles: ufo
|
||||
active: true
|
||||
# betekinto
|
||||
User_BaloghGabor:
|
||||
# betekinto - bggeneral
|
||||
User_BenkeGabor:
|
||||
id: 60
|
||||
name: Balogh Gábor
|
||||
email: gabor.balogh@mfa.gov.hu
|
||||
wantsEmail: true
|
||||
job: főosztályvezető
|
||||
name: Benke Gábor
|
||||
email: benkeg@bggeneral.hu
|
||||
wantsEmail: false
|
||||
job: ügyvezető
|
||||
phone: ""
|
||||
roles: betekinto
|
||||
active: true
|
||||
User_CsicselyTibor:
|
||||
id: 61
|
||||
name: Csicsely Tibor
|
||||
email: csicselyt@laterex.hu
|
||||
wantsEmail: true
|
||||
job: ügyvezető
|
||||
phone: "+36 30 555 3634"
|
||||
roles: betekinto
|
||||
active: true
|
||||
# projektvezeto
|
||||
User_HantzmannGergely:
|
||||
id: 82
|
||||
name: Hantzmann Gergely
|
||||
email: hantzmanng@laterex.hu
|
||||
wantsEmail: true
|
||||
job: karbantartási csv.
|
||||
phone: "+36 30 181 3591"
|
||||
roles: projektvezeto,karbantarto
|
||||
active: true
|
||||
# projektvezeto - bggeneral
|
||||
User_KovacsLudovit:
|
||||
id: 83
|
||||
name: Kovác Ludovit
|
||||
email: kovacl@laterex.hu
|
||||
wantsEmail: true
|
||||
email: kovacl@bggeneral.hu
|
||||
wantsEmail: false
|
||||
job: projektvezető
|
||||
phone: "+36 30 257 4183"
|
||||
roles: projektvezeto
|
||||
active: true
|
||||
# karbantarto
|
||||
User_MeszarosBela:
|
||||
# karbantarto - bggeneral
|
||||
User_OlahSandor:
|
||||
id: 90
|
||||
name: Mészáros Béla
|
||||
email: karbantarto1@laterex.hu
|
||||
email: karbantarto1@bggeneral.hu
|
||||
wantsEmail: false
|
||||
job: karbantartó
|
||||
phone: ""
|
||||
roles: karbantarto
|
||||
active: true
|
||||
User_SzathmaryZsoltMiklos:
|
||||
User_FulopZoltan:
|
||||
id: 91
|
||||
name: Szathmáry Zsolt Miklos
|
||||
email: karbantarto2@laterex.hu
|
||||
name: Fülöp Zoltán
|
||||
email: karbantarto2@bggeneral.hu
|
||||
wantsEmail: false
|
||||
job: karbantartó
|
||||
phone: ""
|
||||
|
||||
@ -2,17 +2,17 @@
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Service\FixtureLoaderService;
|
||||
use App\Service\FixtureManager;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class InitializeFixtureCommand extends Command
|
||||
{
|
||||
/** @var FixtureLoaderService */
|
||||
/** @var FixtureManager */
|
||||
private $fixtureLoaderService;
|
||||
|
||||
public function __construct(FixtureLoaderService $fixtureLoaderService)
|
||||
public function __construct(FixtureManager $fixtureLoaderService)
|
||||
{
|
||||
$this->fixtureLoaderService = $fixtureLoaderService;
|
||||
parent::__construct();
|
||||
@ -26,6 +26,6 @@ class InitializeFixtureCommand extends Command
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->fixtureLoaderService->load($output);
|
||||
$this->fixtureLoaderService->initialize($output);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,15 +2,15 @@
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Service\FixtureLoaderService;
|
||||
use App\Service\FixtureManager;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class InitializeFixtureCommandFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
/** @var FixtureLoaderService $fixtureLoaderService */
|
||||
$fixtureLoaderService = $container->get(FixtureLoaderService::class);
|
||||
/** @var FixtureManager $fixtureLoaderService */
|
||||
$fixtureLoaderService = $container->get(FixtureManager::class);
|
||||
return new InitializeFixtureCommand($fixtureLoaderService);
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ class ConfigProvider
|
||||
Service\UserService::class => Service\UserServiceFactory::class,
|
||||
Service\FaultManagerService::class => Service\FaultManagerServiceFactory::class,
|
||||
Service\FaultAttachmentService::class => Service\FaultAttachmentServiceFactory::class,
|
||||
Service\FixtureLoaderService::class => Service\FixtureLoaderServiceFactory::class,
|
||||
Service\FixtureManager::class => Service\FixtureManagerFactory::class,
|
||||
Service\ErrorCategoryService::class => Service\ErrorCategoryServiceFactory::class,
|
||||
Service\ErrorOriginService::class => Service\ErrorOriginServiceFactory::class,
|
||||
Service\FacilityLocationService::class => Service\FacilityLocationServiceFactory::class,
|
||||
|
||||
@ -3,33 +3,38 @@
|
||||
namespace App\Fixture;
|
||||
|
||||
use App\Entity\ErrorCategory;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Fixture\Fixture;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class ErrorCategoryLoader extends AbstractFixture implements OrderedFixtureInterface
|
||||
class ErrorCategoryFixture implements Fixture
|
||||
{
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
/** @var OutputInterface */
|
||||
private $output;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
/** @var EntityManager */
|
||||
private $manager;
|
||||
|
||||
public function __construct(OutputInterface $output, EntityManager $em)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->manager = $em;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
/**
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$inputFileContents = file_get_contents("data/fixture/error-category.yml");
|
||||
$yamlData = Yaml::parse($inputFileContents);
|
||||
|
||||
/** @var \Doctrine\ORM\Mapping\ClassMetadata $metadata */
|
||||
$metadata = $manager->getClassMetadata(ErrorCategory::class);
|
||||
$metadata = $this->manager->getClassMetadata(ErrorCategory::class);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
|
||||
@ -41,17 +46,26 @@ class ErrorCategoryLoader extends AbstractFixture implements OrderedFixtureInter
|
||||
->setType($entityData['type'])
|
||||
->setActive($entityData['active']);
|
||||
|
||||
$this->addReference($entityId, $entity);
|
||||
|
||||
$manager->persist($entity);
|
||||
$this->manager->persist($entity);
|
||||
$this->output->writeln(" * " . $entityId);
|
||||
}
|
||||
$manager->flush();
|
||||
$this->manager->flush();
|
||||
$this->output->writeln(sprintf(" > %s END", __CLASS__));
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
/**
|
||||
* Purges the fixture from persistence storage.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
return 10;
|
||||
$entities = $this->manager->getRepository(ErrorCategory::class)->findAll();
|
||||
foreach ($entities as $entity) {
|
||||
$this->manager->remove($entity);
|
||||
}
|
||||
$this->manager->flush();
|
||||
}
|
||||
}
|
||||
@ -3,33 +3,38 @@
|
||||
namespace App\Fixture;
|
||||
|
||||
use App\Entity\ErrorOrigin;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Fixture\Fixture;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class ErrorOriginLoader extends AbstractFixture implements OrderedFixtureInterface
|
||||
class ErrorOriginFixture implements Fixture
|
||||
{
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
/** @var OutputInterface */
|
||||
private $output;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
/** @var EntityManager */
|
||||
private $manager;
|
||||
|
||||
public function __construct(OutputInterface $output, EntityManager $em)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->manager = $em;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
/**
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$inputFileContents = file_get_contents("data/fixture/error-origin.yml");
|
||||
$yamlData = Yaml::parse($inputFileContents);
|
||||
|
||||
/** @var \Doctrine\ORM\Mapping\ClassMetadata $metadata */
|
||||
$metadata = $manager->getClassMetadata(ErrorOrigin::class);
|
||||
$metadata = $this->manager->getClassMetadata(ErrorOrigin::class);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
|
||||
@ -41,17 +46,26 @@ class ErrorOriginLoader extends AbstractFixture implements OrderedFixtureInterfa
|
||||
->setCode($entityData['code'])
|
||||
->setActive($entityData['active']);
|
||||
|
||||
$this->addReference($entityId, $entity);
|
||||
|
||||
$manager->persist($entity);
|
||||
$this->manager->persist($entity);
|
||||
$this->output->writeln(" * " . $entityId);
|
||||
}
|
||||
$manager->flush();
|
||||
$this->manager->flush();
|
||||
$this->output->writeln(sprintf(" > %s END", __CLASS__));
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
/**
|
||||
* Purges the fixture from persistence storage.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
return 10;
|
||||
$entities = $this->manager->getRepository(ErrorOrigin::class)->findAll();
|
||||
foreach ($entities as $entity) {
|
||||
$this->manager->remove($entity);
|
||||
}
|
||||
$this->manager->flush();
|
||||
}
|
||||
}
|
||||
87
src/App/Fixture/FacilityLocationFixture.php
Normal file
87
src/App/Fixture/FacilityLocationFixture.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Fixture;
|
||||
|
||||
use App\Entity\FacilityLocation;
|
||||
use Doctrine\Fixture\Reference\ReferenceRepository;
|
||||
use Doctrine\Fixture\Reference\ReferenceRepositoryFixture;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class FacilityLocationFixture implements ReferenceRepositoryFixture
|
||||
{
|
||||
/** @var OutputInterface */
|
||||
private $output;
|
||||
|
||||
/** @var ReferenceRepository */
|
||||
private $referenceRepo;
|
||||
|
||||
/** @var EntityManager */
|
||||
private $manager;
|
||||
|
||||
public function __construct(OutputInterface $output, EntityManager $em)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->manager = $em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports the fixture into persistence storage.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$inputFileContents = file_get_contents("data/fixture/facility-location.yml");
|
||||
$yamlData = Yaml::parse($inputFileContents);
|
||||
|
||||
$this->output->writeln(sprintf(" > %s BEGIN", __CLASS__));
|
||||
foreach ($yamlData['FacilityLocations'] as $entityId => $entityData) {
|
||||
$entity = new FacilityLocation();
|
||||
$entity
|
||||
->setRoomNumber($entityData['roomNumber'])
|
||||
->setName($entityData['name'])
|
||||
->setSize($entityData['size']);
|
||||
|
||||
if ($entityData['parent']) {
|
||||
$entity->setParent($this->referenceRepo->get($entityData['parent']));
|
||||
}
|
||||
|
||||
$this->referenceRepo->add($entityId, $entity);
|
||||
|
||||
$this->manager->persist($entity);
|
||||
$this->output->writeln(" * " . $entityId);
|
||||
}
|
||||
$this->manager->flush();
|
||||
$this->output->writeln(sprintf(" > %s END", __CLASS__));
|
||||
}
|
||||
|
||||
/**
|
||||
* Purges the fixture from persistence storage.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
$entities = $this->manager->getRepository(FacilityLocation::class)->findAll();
|
||||
foreach ($entities as $entity) {
|
||||
$this->manager->remove($entity);
|
||||
}
|
||||
$this->manager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the Reference Repository.
|
||||
*
|
||||
* @param \Doctrine\Fixture\Reference\ReferenceRepository $referenceRepository
|
||||
*/
|
||||
function setReferenceRepository(ReferenceRepository $referenceRepository)
|
||||
{
|
||||
$this->referenceRepo = $referenceRepository;
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Fixture;
|
||||
|
||||
use App\Entity\FacilityLocation;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Gedmo\Tree\Entity\Repository\ClosureTreeRepository;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class FacilityLocationLoader extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private $output;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$inputFileContents = file_get_contents("data/fixture/facility-location.yml");
|
||||
$yamlData = Yaml::parse($inputFileContents);
|
||||
|
||||
$this->output->writeln(sprintf(" > %s BEGIN", __CLASS__));
|
||||
foreach ($yamlData['FacilityLocations'] as $entityId => $entityData) {
|
||||
$entity = new FacilityLocation();
|
||||
$entity
|
||||
->setRoomNumber($entityData['roomNumber'])
|
||||
->setName($entityData['name'])
|
||||
->setSize($entityData['size']);
|
||||
|
||||
if ($entityData['parent']) {
|
||||
$entity->setParent($this->getReference($entityData['parent']));
|
||||
}
|
||||
|
||||
$this->addReference($entityId, $entity);
|
||||
|
||||
$manager->persist($entity);
|
||||
$this->output->writeln(" * " . $entityId);
|
||||
}
|
||||
$manager->flush();
|
||||
$this->output->writeln(sprintf(" > %s END", __CLASS__));
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
@ -3,33 +3,38 @@
|
||||
namespace App\Fixture;
|
||||
|
||||
use App\Entity\SolutionTimeInterval;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Fixture\Fixture;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class SolutionTimeIntervalLoader extends AbstractFixture implements OrderedFixtureInterface
|
||||
class SolutionTimeIntervalFixture implements Fixture
|
||||
{
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
/** @var OutputInterface */
|
||||
private $output;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
/** @var EntityManager */
|
||||
private $manager;
|
||||
|
||||
public function __construct(OutputInterface $output, EntityManager $em)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->manager = $em;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
/**
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$inputFileContents = file_get_contents("data/fixture/solution-time-interval.yml");
|
||||
$yamlData = Yaml::parse($inputFileContents);
|
||||
|
||||
/** @var \Doctrine\ORM\Mapping\ClassMetadata $metadata */
|
||||
$metadata = $manager->getClassMetadata(SolutionTimeInterval::class);
|
||||
$metadata = $this->manager->getClassMetadata(SolutionTimeInterval::class);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
|
||||
@ -41,17 +46,27 @@ class SolutionTimeIntervalLoader extends AbstractFixture implements OrderedFixtu
|
||||
->setCode($entityData['code'])
|
||||
->setActive($entityData['active']);
|
||||
|
||||
$this->addReference($entityId, $entity);
|
||||
|
||||
$manager->persist($entity);
|
||||
$this->manager->persist($entity);
|
||||
$this->output->writeln(" * " . $entityId);
|
||||
}
|
||||
$manager->flush();
|
||||
$this->manager->flush();
|
||||
$this->output->writeln(sprintf(" > %s END", __CLASS__));
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
/**
|
||||
* Purges the fixture from persistence storage.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
return 10;
|
||||
$entities = $this->manager->getRepository(SolutionTimeInterval::class)->findAll();
|
||||
foreach ($entities as $entity) {
|
||||
$this->manager->remove($entity);
|
||||
}
|
||||
$this->manager->flush();
|
||||
}
|
||||
}
|
||||
@ -3,38 +3,42 @@
|
||||
namespace App\Fixture;
|
||||
|
||||
use App\Entity\User;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Fixture\Fixture;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Zend\Crypt\Password\Bcrypt;
|
||||
|
||||
class UserLoader extends AbstractFixture implements OrderedFixtureInterface
|
||||
class UserFixture implements Fixture
|
||||
{
|
||||
const GEN_PW_FILE = 'data/passwords-generated.txt';
|
||||
const PASSWORD_COST = 14;
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
/** @var OutputInterface */
|
||||
private $output;
|
||||
|
||||
/** @var EntityManager */
|
||||
private $manager;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
public function __construct(OutputInterface $output, EntityManager $em)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->manager = $em;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
/**
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$inputFileContents = file_get_contents("data/fixture/user.yml");
|
||||
$yamlData = Yaml::parse($inputFileContents);
|
||||
|
||||
/** @var \Doctrine\ORM\Mapping\ClassMetadata $metadata */
|
||||
$metadata = $manager->getClassMetadata(User::class);
|
||||
$metadata = $this->manager->getClassMetadata(User::class);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
|
||||
@ -70,22 +74,26 @@ class UserLoader extends AbstractFixture implements OrderedFixtureInterface
|
||||
->setCanChangePassword($canChangePassword)
|
||||
->setActive($entityData['active']);
|
||||
|
||||
$this->addReference($entityId, $entity);
|
||||
|
||||
$manager->persist($entity);
|
||||
$this->manager->persist($entity);
|
||||
$this->output->writeln(" * " . $entityId);
|
||||
}
|
||||
$manager->flush();
|
||||
$this->manager->flush();
|
||||
$this->output->writeln(sprintf(" > %s END", __CLASS__));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used as fixture load order
|
||||
* Purges the fixture from persistence storage.
|
||||
*
|
||||
* @return int
|
||||
* @return void
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
*/
|
||||
public function getOrder()
|
||||
public function purge()
|
||||
{
|
||||
return 9;
|
||||
$entities = $this->manager->getRepository(User::class)->findAll();
|
||||
foreach ($entities as $entity) {
|
||||
$this->manager->remove($entity);
|
||||
}
|
||||
$this->manager->flush();
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ class FaultAttachmentHandler extends CrudHandler
|
||||
/** @var UploadedFileInterface[] $files */
|
||||
$files = $request->getUploadedFiles()['file'];
|
||||
return new JsonResponse(
|
||||
$this->attachmentService->createAttachments($faultId, $files, $token->uid, $type),
|
||||
$this->attachmentService->createAttachments($faultId, $files, $token['uid'], $type),
|
||||
201
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@ -30,7 +30,7 @@ class FaultCommentHandler extends CrudHandler
|
||||
$jwt = $request->getAttribute('token');
|
||||
try {
|
||||
$data = $this->getRequestData($request);
|
||||
return new JsonResponse($this->faultManagerService->addFaultComment($faultId, $data, $jwt->uid), 201);
|
||||
return new JsonResponse($this->faultManagerService->addFaultComment($faultId, $data, $jwt['uid']), 201);
|
||||
} catch (\Exception $e) {
|
||||
return new JsonResponse($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ class FaultHandler extends CrudHandler
|
||||
try {
|
||||
$data = $this->getRequestData($request);
|
||||
$token = $request->getAttribute('token');
|
||||
return new JsonResponse($this->faultManagerService->createFault($data, $token->uid), 201);
|
||||
return new JsonResponse($this->faultManagerService->createFault($data, $token['uid']), 201);
|
||||
} catch (\Exception $e) {
|
||||
return new JsonResponse($e->getMessage(), 500);
|
||||
}
|
||||
@ -73,7 +73,7 @@ class FaultHandler extends CrudHandler
|
||||
$id = $request->getAttribute('id');
|
||||
$token = $request->getAttribute('token');
|
||||
$data = $this->getRequestData($request);
|
||||
return new JsonResponse($this->faultManagerService->updateFault($id, $data, $token->uid));
|
||||
return new JsonResponse($this->faultManagerService->updateFault($id, $data, $token['uid']));
|
||||
} catch (\Exception $e) {
|
||||
return new JsonResponse($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class FaultRejectHandler extends CrudHandler
|
||||
$jwt = $request->getAttribute('token');
|
||||
try {
|
||||
$data = $this->getRequestData($request);
|
||||
return new JsonResponse($this->faultManagerService->rejectFault($faultId, $data, $jwt->uid), 201);
|
||||
return new JsonResponse($this->faultManagerService->rejectFault($faultId, $data, $jwt['uid']), 201);
|
||||
} catch (\Exception $e) {
|
||||
return new JsonResponse($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ class PasswordHandler extends CrudHandler
|
||||
$token = $request->getAttribute('token');
|
||||
try {
|
||||
$data = $this->getRequestData($request);
|
||||
return new JsonResponse($this->userService->changePassword($token->uid, $data['old'], $data['new']));
|
||||
return new JsonResponse($this->userService->changePassword($token['uid'], $data['old'], $data['new']));
|
||||
} catch (\Exception $e) {
|
||||
return new JsonResponse([
|
||||
'message' => $e->getMessage()
|
||||
|
||||
@ -1,594 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace App\Hydrator;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Util\Inflector;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Traversable;
|
||||
use Zend\Stdlib\ArrayUtils;
|
||||
use Zend\Hydrator\AbstractHydrator;
|
||||
use Zend\Hydrator\Filter\FilterProviderInterface;
|
||||
|
||||
/**
|
||||
* This hydrator has been completely refactored for DoctrineModule 0.7.0. It provides an easy and powerful way
|
||||
* of extracting/hydrator objects in Doctrine, by handling most associations types.
|
||||
*
|
||||
* Starting from DoctrineModule 0.8.0, the hydrator can be used multiple times with different objects
|
||||
*
|
||||
* @license MIT
|
||||
* @link http://www.doctrine-project.org/
|
||||
* @since 0.7.0
|
||||
* @author Michael Gallego <mic.gallego@gmail.com>
|
||||
*/
|
||||
class DoctrineObject extends AbstractHydrator
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
*/
|
||||
protected $metadata;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $byValue = true;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ObjectManager $objectManager The ObjectManager to use
|
||||
* @param bool $byValue If set to true, hydrator will always use entity's public API
|
||||
*/
|
||||
public function __construct(ObjectManager $objectManager, $byValue = true)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->objectManager = $objectManager;
|
||||
$this->byValue = (bool) $byValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract values from an object
|
||||
*
|
||||
* @param object $object
|
||||
* @return array
|
||||
*/
|
||||
public function extract($object)
|
||||
{
|
||||
$this->prepare($object);
|
||||
|
||||
if ($this->byValue) {
|
||||
return $this->extractByValue($object);
|
||||
}
|
||||
|
||||
return $this->extractByReference($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate $object with the provided $data.
|
||||
*
|
||||
* @param array $data
|
||||
* @param object $object
|
||||
* @return object
|
||||
*/
|
||||
public function hydrate(array $data, $object)
|
||||
{
|
||||
$this->prepare($object);
|
||||
|
||||
if ($this->byValue) {
|
||||
return $this->hydrateByValue($data, $object);
|
||||
}
|
||||
|
||||
return $this->hydrateByReference($data, $object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the hydrator by adding strategies to every collection valued associations
|
||||
*
|
||||
* @param object $object
|
||||
* @return void
|
||||
*/
|
||||
protected function prepare($object)
|
||||
{
|
||||
$this->metadata = $this->objectManager->getClassMetadata(get_class($object));
|
||||
$this->prepareStrategies();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare strategies before the hydrator is used
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareStrategies()
|
||||
{
|
||||
$associations = $this->metadata->getAssociationNames();
|
||||
|
||||
foreach ($associations as $association) {
|
||||
if ($this->metadata->isCollectionValuedAssociation($association)) {
|
||||
// Add a strategy if the association has none set by user
|
||||
if (!$this->hasStrategy($association)) {
|
||||
if ($this->byValue) {
|
||||
$this->addStrategy($association, new Strategy\AllowRemoveByValue());
|
||||
} else {
|
||||
$this->addStrategy($association, new Strategy\AllowRemoveByReference());
|
||||
}
|
||||
}
|
||||
|
||||
$strategy = $this->getStrategy($association);
|
||||
|
||||
if (!$strategy instanceof Strategy\AbstractCollectionStrategy) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Strategies used for collections valued associations must inherit from '
|
||||
. 'Strategy\AbstractCollectionStrategy, %s given',
|
||||
get_class($strategy)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$strategy->setCollectionName($association)
|
||||
->setClassMetadata($this->metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract values from an object using a by-value logic (this means that it uses the entity
|
||||
* API, in this case, getters)
|
||||
*
|
||||
* @param object $object
|
||||
* @throws RuntimeException
|
||||
* @return array
|
||||
*/
|
||||
protected function extractByValue($object)
|
||||
{
|
||||
$fieldNames = array_merge($this->metadata->getFieldNames(), $this->metadata->getAssociationNames());
|
||||
$methods = get_class_methods($object);
|
||||
$filter = $object instanceof FilterProviderInterface
|
||||
? $object->getFilter()
|
||||
: $this->filterComposite;
|
||||
|
||||
$data = [];
|
||||
foreach ($fieldNames as $fieldName) {
|
||||
if ($filter && !$filter->filter($fieldName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$getter = 'get' . Inflector::classify($fieldName);
|
||||
$isser = 'is' . Inflector::classify($fieldName);
|
||||
|
||||
$dataFieldName = $this->computeExtractFieldName($fieldName);
|
||||
if (in_array($getter, $methods)) {
|
||||
$data[$dataFieldName] = $this->extractValue($fieldName, $object->$getter(), $object);
|
||||
} elseif (in_array($isser, $methods)) {
|
||||
$data[$dataFieldName] = $this->extractValue($fieldName, $object->$isser(), $object);
|
||||
} elseif (substr($fieldName, 0, 2) === 'is'
|
||||
&& ctype_upper(substr($fieldName, 2, 1))
|
||||
&& in_array($fieldName, $methods)) {
|
||||
$data[$dataFieldName] = $this->extractValue($fieldName, $object->$fieldName(), $object);
|
||||
}
|
||||
|
||||
// Unknown fields are ignored
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract values from an object using a by-reference logic (this means that values are
|
||||
* directly fetched without using the public API of the entity, in this case, getters)
|
||||
*
|
||||
* @param object $object
|
||||
* @return array
|
||||
*/
|
||||
protected function extractByReference($object)
|
||||
{
|
||||
$fieldNames = array_merge($this->metadata->getFieldNames(), $this->metadata->getAssociationNames());
|
||||
$refl = $this->metadata->getReflectionClass();
|
||||
$filter = $object instanceof FilterProviderInterface
|
||||
? $object->getFilter()
|
||||
: $this->filterComposite;
|
||||
|
||||
$data = [];
|
||||
foreach ($fieldNames as $fieldName) {
|
||||
if ($filter && !$filter->filter($fieldName)) {
|
||||
continue;
|
||||
}
|
||||
$reflProperty = $refl->getProperty($fieldName);
|
||||
$reflProperty->setAccessible(true);
|
||||
|
||||
$dataFieldName = $this->computeExtractFieldName($fieldName);
|
||||
$data[$dataFieldName] = $this->extractValue($fieldName, $reflProperty->getValue($object), $object);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the object using a by-value logic (this means that it uses the entity API, in this
|
||||
* case, setters)
|
||||
*
|
||||
* @param array $data
|
||||
* @param object $object
|
||||
* @throws RuntimeException
|
||||
* @return object
|
||||
*/
|
||||
protected function hydrateByValue(array $data, $object)
|
||||
{
|
||||
$tryObject = $this->tryConvertArrayToObject($data, $object);
|
||||
$metadata = $this->metadata;
|
||||
|
||||
if (is_object($tryObject)) {
|
||||
$object = $tryObject;
|
||||
}
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
$field = $this->computeHydrateFieldName($field);
|
||||
$value = $this->handleTypeConversions($value, $metadata->getTypeOfField($field));
|
||||
$setter = 'set' . Inflector::classify($field);
|
||||
|
||||
if ($metadata->hasAssociation($field)) {
|
||||
$target = $metadata->getAssociationTargetClass($field);
|
||||
|
||||
if ($metadata->isSingleValuedAssociation($field)) {
|
||||
if (! method_exists($object, $setter)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $this->toOne($target, $this->hydrateValue($field, $value, $data));
|
||||
|
||||
if (null === $value
|
||||
&& !current($metadata->getReflectionClass()->getMethod($setter)->getParameters())->allowsNull()
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$object->$setter($value);
|
||||
} elseif ($metadata->isCollectionValuedAssociation($field)) {
|
||||
$this->toMany($object, $field, $target, $value);
|
||||
}
|
||||
} else {
|
||||
if (! method_exists($object, $setter)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$object->$setter($this->hydrateValue($field, $value, $data));
|
||||
}
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the object using a by-reference logic (this means that values are modified directly without
|
||||
* using the public API, in this case setters, and hence override any logic that could be done in those
|
||||
* setters)
|
||||
*
|
||||
* @param array $data
|
||||
* @param object $object
|
||||
* @return object
|
||||
*/
|
||||
protected function hydrateByReference(array $data, $object)
|
||||
{
|
||||
$tryObject = $this->tryConvertArrayToObject($data, $object);
|
||||
$metadata = $this->metadata;
|
||||
$refl = $metadata->getReflectionClass();
|
||||
|
||||
if (is_object($tryObject)) {
|
||||
$object = $tryObject;
|
||||
}
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
$field = $this->computeHydrateFieldName($field);
|
||||
|
||||
// Ignore unknown fields
|
||||
if (!$refl->hasProperty($field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $this->handleTypeConversions($value, $metadata->getTypeOfField($field));
|
||||
$reflProperty = $refl->getProperty($field);
|
||||
$reflProperty->setAccessible(true);
|
||||
|
||||
if ($metadata->hasAssociation($field)) {
|
||||
$target = $metadata->getAssociationTargetClass($field);
|
||||
|
||||
if ($metadata->isSingleValuedAssociation($field)) {
|
||||
$value = $this->toOne($target, $this->hydrateValue($field, $value, $data));
|
||||
$reflProperty->setValue($object, $value);
|
||||
} elseif ($metadata->isCollectionValuedAssociation($field)) {
|
||||
$this->toMany($object, $field, $target, $value);
|
||||
}
|
||||
} else {
|
||||
$reflProperty->setValue($object, $this->hydrateValue($field, $value, $data));
|
||||
}
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function tries, given an array of data, to convert it to an object if the given array contains
|
||||
* an identifier for the object. This is useful in a context of updating existing entities, without ugly
|
||||
* tricks like setting manually the existing id directly into the entity
|
||||
*
|
||||
* @param array $data The data that may contain identifiers keys
|
||||
* @param object $object
|
||||
* @return object
|
||||
*/
|
||||
protected function tryConvertArrayToObject($data, $object)
|
||||
{
|
||||
$metadata = $this->metadata;
|
||||
$identifierNames = $metadata->getIdentifierFieldNames($object);
|
||||
$identifierValues = [];
|
||||
|
||||
if (empty($identifierNames)) {
|
||||
return $object;
|
||||
}
|
||||
|
||||
foreach ($identifierNames as $identifierName) {
|
||||
if (!isset($data[$identifierName])) {
|
||||
return $object;
|
||||
}
|
||||
|
||||
$identifierValues[$identifierName] = $data[$identifierName];
|
||||
}
|
||||
|
||||
return $this->find($identifierValues, $metadata->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle ToOne associations
|
||||
*
|
||||
* When $value is an array but is not the $target's identifiers, $value is
|
||||
* most likely an array of fieldset data. The identifiers will be determined
|
||||
* and a target instance will be initialized and then hydrated. The hydrated
|
||||
* target will be returned.
|
||||
*
|
||||
* @param string $target
|
||||
* @param mixed $value
|
||||
* @return object
|
||||
*/
|
||||
protected function toOne($target, $value)
|
||||
{
|
||||
$metadata = $this->objectManager->getClassMetadata($target);
|
||||
|
||||
if (is_array($value) && array_keys($value) != $metadata->getIdentifier()) {
|
||||
// $value is most likely an array of fieldset data
|
||||
$identifiers = array_intersect_key(
|
||||
$value,
|
||||
array_flip($metadata->getIdentifier())
|
||||
);
|
||||
$object = $this->find($identifiers, $target) ?: new $target;
|
||||
return $this->hydrate($value, $object);
|
||||
}
|
||||
|
||||
return $this->find($value, $target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle ToMany associations. In proper Doctrine design, Collections should not be swapped, so
|
||||
* collections are always handled by reference. Internally, every collection is handled using specials
|
||||
* strategies that inherit from AbstractCollectionStrategy class, and that add or remove elements but without
|
||||
* changing the collection of the object
|
||||
*
|
||||
* @param object $object
|
||||
* @param mixed $collectionName
|
||||
* @param string $target
|
||||
* @param mixed $values
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function toMany($object, $collectionName, $target, $values)
|
||||
{
|
||||
$metadata = $this->objectManager->getClassMetadata(ltrim($target, '\\'));
|
||||
$identifier = $metadata->getIdentifier();
|
||||
|
||||
if (!is_array($values) && !$values instanceof Traversable) {
|
||||
$values = (array)$values;
|
||||
}
|
||||
|
||||
$collection = [];
|
||||
|
||||
// If the collection contains identifiers, fetch the objects from database
|
||||
foreach ($values as $value) {
|
||||
if ($value instanceof $target) {
|
||||
// assumes modifications have already taken place in object
|
||||
$collection[] = $value;
|
||||
continue;
|
||||
} elseif (empty($value)) {
|
||||
// assumes no id and retrieves new $target
|
||||
$collection[] = $this->find($value, $target);
|
||||
continue;
|
||||
}
|
||||
|
||||
$find = [];
|
||||
if (is_array($identifier)) {
|
||||
foreach ($identifier as $field) {
|
||||
switch (gettype($value)) {
|
||||
case 'object':
|
||||
$getter = 'get' . ucfirst($field);
|
||||
if (method_exists($value, $getter)) {
|
||||
$find[$field] = $value->$getter();
|
||||
} elseif (property_exists($value, $field)) {
|
||||
$find[$field] = $value->$field;
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
if (array_key_exists($field, $value) && $value[$field] != null) {
|
||||
$find[$field] = $value[$field];
|
||||
unset($value[$field]); // removed identifier from persistable data
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$find[$field] = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($find) && $found = $this->find($find, $target)) {
|
||||
$collection[] = (is_array($value)) ? $this->hydrate($value, $found) : $found;
|
||||
} else {
|
||||
$collection[] = (is_array($value)) ? $this->hydrate($value, new $target) : new $target;
|
||||
}
|
||||
}
|
||||
|
||||
$collection = array_filter(
|
||||
$collection,
|
||||
function ($item) {
|
||||
return null !== $item;
|
||||
}
|
||||
);
|
||||
|
||||
// Set the object so that the strategy can extract the Collection from it
|
||||
|
||||
/** @var \DoctrineModule\Stdlib\Hydrator\Strategy\AbstractCollectionStrategy $collectionStrategy */
|
||||
$collectionStrategy = $this->getStrategy($collectionName);
|
||||
$collectionStrategy->setObject($object);
|
||||
|
||||
// We could directly call hydrate method from the strategy, but if people want to override
|
||||
// hydrateValue function, they can do it and do their own stuff
|
||||
$this->hydrateValue($collectionName, $collection, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle various type conversions that should be supported natively by Doctrine (like DateTime)
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $typeOfField
|
||||
* @return DateTime
|
||||
*/
|
||||
protected function handleTypeConversions($value, $typeOfField)
|
||||
{
|
||||
switch ($typeOfField) {
|
||||
case 'datetimetz':
|
||||
case 'datetime':
|
||||
case 'time':
|
||||
case 'date':
|
||||
if ('' === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_int($value)) {
|
||||
$dateTime = new DateTime();
|
||||
$dateTime->setTimestamp($value);
|
||||
$value = $dateTime;
|
||||
} elseif (is_string($value)) {
|
||||
$value = new DateTime($value);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an object by a given target class and identifier
|
||||
*
|
||||
* @param mixed $identifiers
|
||||
* @param string $targetClass
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
protected function find($identifiers, $targetClass)
|
||||
{
|
||||
if ($identifiers instanceof $targetClass) {
|
||||
return $identifiers;
|
||||
}
|
||||
|
||||
if ($this->isNullIdentifier($identifiers)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->objectManager->find($targetClass, $identifiers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if a provided identifier is to be considered null
|
||||
*
|
||||
* @param mixed $identifier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isNullIdentifier($identifier)
|
||||
{
|
||||
if (null === $identifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($identifier instanceof Traversable || is_array($identifier)) {
|
||||
$nonNullIdentifiers = array_filter(
|
||||
ArrayUtils::iteratorToArray($identifier),
|
||||
function ($value) {
|
||||
return null !== $value;
|
||||
}
|
||||
);
|
||||
|
||||
return empty($nonNullIdentifiers);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the naming strategy if there is one set
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function computeHydrateFieldName($field)
|
||||
{
|
||||
if ($this->hasNamingStrategy()) {
|
||||
$field = $this->getNamingStrategy()->hydrate($field);
|
||||
}
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the naming strategy if there is one set
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function computeExtractFieldName($field)
|
||||
{
|
||||
if ($this->hasNamingStrategy()) {
|
||||
$field = $this->getNamingStrategy()->extract($field);
|
||||
}
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Hydrator;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class DoctrineObjectFactory
|
||||
{
|
||||
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$em = $container->get('doctrine.entity_manager.orm_default');
|
||||
return new DoctrineObject($em);
|
||||
}
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace App\Hydrator\Filter;
|
||||
|
||||
use Zend\Hydrator\Filter\FilterInterface;
|
||||
|
||||
/**
|
||||
* Provides a filter to restrict returned fields by whitelisting or
|
||||
* blacklisting property names.
|
||||
*
|
||||
* @license MIT
|
||||
* @link http://www.doctrine-project.org/
|
||||
* @author Liam O'Boyle <liam@ontheroad.net.nz>
|
||||
*/
|
||||
class PropertyName implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* The propteries to exclude.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = [];
|
||||
|
||||
/**
|
||||
* Either an exclude or an include.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $exclude = null;
|
||||
|
||||
/**
|
||||
* @param [ string | array ] $properties The properties to exclude or include.
|
||||
* @param bool $exclude If the method should be excluded
|
||||
*/
|
||||
public function __construct($properties, $exclude = true)
|
||||
{
|
||||
$this->exclude = $exclude;
|
||||
$this->properties = is_array($properties)
|
||||
? $properties
|
||||
: [$properties];
|
||||
}
|
||||
|
||||
public function filter($property)
|
||||
{
|
||||
return in_array($property, $this->properties)
|
||||
? !$this->exclude
|
||||
: $this->exclude;
|
||||
}
|
||||
}
|
||||
@ -1,190 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace App\Hydrator\Strategy;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Zend\Hydrator\Strategy\StrategyInterface;
|
||||
|
||||
/**
|
||||
* @license MIT
|
||||
* @link http://www.doctrine-project.org/
|
||||
* @since 0.7.0
|
||||
* @author Michael Gallego <mic.gallego@gmail.com>
|
||||
*/
|
||||
abstract class AbstractCollectionStrategy implements StrategyInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $collectionName;
|
||||
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
*/
|
||||
protected $metadata;
|
||||
|
||||
/**
|
||||
* @var object
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
|
||||
/**
|
||||
* Set the name of the collection
|
||||
*
|
||||
* @param string $collectionName
|
||||
* @return AbstractCollectionStrategy
|
||||
*/
|
||||
public function setCollectionName($collectionName)
|
||||
{
|
||||
$this->collectionName = (string) $collectionName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCollectionName()
|
||||
{
|
||||
return $this->collectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the class metadata
|
||||
*
|
||||
* @param ClassMetadata $classMetadata
|
||||
* @return AbstractCollectionStrategy
|
||||
*/
|
||||
public function setClassMetadata(ClassMetadata $classMetadata)
|
||||
{
|
||||
$this->metadata = $classMetadata;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class metadata
|
||||
*
|
||||
* @return ClassMetadata
|
||||
*/
|
||||
public function getClassMetadata()
|
||||
{
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object
|
||||
*
|
||||
* @param object $object
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return AbstractCollectionStrategy
|
||||
*/
|
||||
public function setObject($object)
|
||||
{
|
||||
if (!is_object($object)) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('The parameter given to setObject method of %s class is not an object', get_called_class())
|
||||
);
|
||||
}
|
||||
|
||||
$this->object = $object;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getObject()
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function extract($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the collection by value (using the public API)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getCollectionFromObjectByValue()
|
||||
{
|
||||
$object = $this->getObject();
|
||||
$getter = 'get' . ucfirst($this->getCollectionName());
|
||||
|
||||
if (!method_exists($object, $getter)) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'The getter %s to access collection %s in object %s does not exist',
|
||||
$getter,
|
||||
$this->getCollectionName(),
|
||||
get_class($object)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $object->$getter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the collection by reference (not using the public API)
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getCollectionFromObjectByReference()
|
||||
{
|
||||
$object = $this->getObject();
|
||||
$refl = $this->getClassMetadata()->getReflectionClass();
|
||||
$reflProperty = $refl->getProperty($this->getCollectionName());
|
||||
|
||||
$reflProperty->setAccessible(true);
|
||||
|
||||
return $reflProperty->getValue($object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is used internally by array_udiff to check if two objects are equal, according to their
|
||||
* SPL hash. This is needed because the native array_diff only compare strings
|
||||
*
|
||||
* @param object $a
|
||||
* @param object $b
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function compareObjects($a, $b)
|
||||
{
|
||||
return strcmp(spl_object_hash($a), spl_object_hash($b));
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace App\Hydrator\Strategy;
|
||||
|
||||
/**
|
||||
* When this strategy is used for Collections, if the new collection does not contain elements that are present in
|
||||
* the original collection, then this strategy remove elements from the original collection. For instance, if the
|
||||
* collection initially contains elements A and B, and that the new collection contains elements B and C, then the
|
||||
* final collection will contain elements B and C (while element A will be asked to be removed).
|
||||
*
|
||||
* This strategy is by reference, this means it won't use public API to add/remove elements to the collection
|
||||
*
|
||||
* @license MIT
|
||||
* @link http://www.doctrine-project.org/
|
||||
* @since 0.7.0
|
||||
* @author Michael Gallego <mic.gallego@gmail.com>
|
||||
*/
|
||||
class AllowRemoveByReference extends AbstractCollectionStrategy
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hydrate($value)
|
||||
{
|
||||
$collection = $this->getCollectionFromObjectByReference();
|
||||
$collectionArray = $collection->toArray();
|
||||
|
||||
$toAdd = array_udiff($value, $collectionArray, [$this, 'compareObjects']);
|
||||
$toRemove = array_udiff($collectionArray, $value, [$this, 'compareObjects']);
|
||||
|
||||
foreach ($toAdd as $element) {
|
||||
$collection->add($element);
|
||||
}
|
||||
|
||||
foreach ($toRemove as $element) {
|
||||
$collection->removeElement($element);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace App\Hydrator\Strategy;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use LogicException;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* When this strategy is used for Collections, if the new collection does not contain elements that are present in
|
||||
* the original collection, then this strategy remove elements from the original collection. For instance, if the
|
||||
* collection initially contains elements A and B, and that the new collection contains elements B and C, then the
|
||||
* final collection will contain elements B and C (while element A will be asked to be removed).
|
||||
*
|
||||
* This strategy is by value, this means it will use the public API (in this case, adder and remover)
|
||||
*
|
||||
* @license MIT
|
||||
* @link http://www.doctrine-project.org/
|
||||
* @since 0.7.0
|
||||
* @author Michael Gallego <mic.gallego@gmail.com>
|
||||
*/
|
||||
class AllowRemoveByValue extends AbstractCollectionStrategy
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hydrate($value)
|
||||
{
|
||||
// AllowRemove strategy need "adder" and "remover"
|
||||
$adder = 'add' . ucfirst($this->collectionName);
|
||||
$remover = 'remove' . ucfirst($this->collectionName);
|
||||
|
||||
if (!method_exists($this->object, $adder) || !method_exists($this->object, $remover)) {
|
||||
throw new LogicException(
|
||||
sprintf(
|
||||
'AllowRemove strategy for DoctrineModule hydrator requires both %s and %s to be defined in %s
|
||||
entity domain code, but one or both seem to be missing',
|
||||
$adder,
|
||||
$remover,
|
||||
get_class($this->object)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$collection = $this->getCollectionFromObjectByValue();
|
||||
|
||||
if ($collection instanceof Collection) {
|
||||
$collection = $collection->toArray();
|
||||
}
|
||||
|
||||
$toAdd = new ArrayCollection(array_udiff($value, $collection, [$this, 'compareObjects']));
|
||||
$toRemove = new ArrayCollection(array_udiff($collection, $value, [$this, 'compareObjects']));
|
||||
|
||||
$this->object->$adder($toAdd);
|
||||
$this->object->$remover($toRemove);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace App\Hydrator\Strategy;
|
||||
|
||||
/**
|
||||
* When this strategy is used for Collections, if the new collection does not contain elements that are present in
|
||||
* the original collection, then this strategy will not remove those elements. At most, it will add new elements. For
|
||||
* instance, if the collection initially contains elements A and B, and that the new collection contains elements B
|
||||
* and C, then the final collection will contain elements A, B and C.
|
||||
*
|
||||
* This strategy is by reference, this means it won't use the public API to remove elements
|
||||
*
|
||||
* @license MIT
|
||||
* @link http://www.doctrine-project.org/
|
||||
* @since 0.7.0
|
||||
* @author Michael Gallego <mic.gallego@gmail.com>
|
||||
*/
|
||||
class DisallowRemoveByReference extends AbstractCollectionStrategy
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hydrate($value)
|
||||
{
|
||||
$collection = $this->getCollectionFromObjectByReference();
|
||||
$collectionArray = $collection->toArray();
|
||||
|
||||
$toAdd = array_udiff($value, $collectionArray, [$this, 'compareObjects']);
|
||||
|
||||
foreach ($toAdd as $element) {
|
||||
$collection->add($element);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace App\Hydrator\Strategy;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use LogicException;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* When this strategy is used for Collections, if the new collection does not contain elements that are present in
|
||||
* the original collection, then this strategy will not remove those elements. At most, it will add new elements. For
|
||||
* instance, if the collection initially contains elements A and B, and that the new collection contains elements B
|
||||
* and C, then the final collection will contain elements A, B and C.
|
||||
*
|
||||
* This strategy is by value, this means it will use the public API (in this case, remover)
|
||||
*
|
||||
* @license MIT
|
||||
* @link http://www.doctrine-project.org/
|
||||
* @since 0.7.0
|
||||
* @author Michael Gallego <mic.gallego@gmail.com>
|
||||
*/
|
||||
class DisallowRemoveByValue extends AbstractCollectionStrategy
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hydrate($value)
|
||||
{
|
||||
// AllowRemove strategy need "adder"
|
||||
$adder = 'add' . ucfirst($this->collectionName);
|
||||
|
||||
if (!method_exists($this->object, $adder)) {
|
||||
throw new LogicException(
|
||||
sprintf(
|
||||
'DisallowRemove strategy for DoctrineModule hydrator requires %s to
|
||||
be defined in %s entity domain code, but it seems to be missing',
|
||||
$adder,
|
||||
get_class($this->object)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$collection = $this->getCollectionFromObjectByValue();
|
||||
|
||||
if ($collection instanceof Collection) {
|
||||
$collection = $collection->toArray();
|
||||
}
|
||||
|
||||
$toAdd = new ArrayCollection(array_udiff($value, $collection, [$this, 'compareObjects']));
|
||||
|
||||
$this->object->$adder($toAdd);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
@ -12,8 +12,6 @@ use Zend\Expressive\Router\Route;
|
||||
|
||||
class JwtAuthenticationFactory
|
||||
{
|
||||
const DEFAULT_HMAC = 'thisShouldBeChangedForReal';
|
||||
|
||||
/** @var Config */
|
||||
private $config;
|
||||
|
||||
@ -22,13 +20,12 @@ class JwtAuthenticationFactory
|
||||
$config = $container->get('config');
|
||||
$this->config = (new Config($config))->get('acl_config');
|
||||
return new JwtAuthentication([
|
||||
"secret" => $this->config->get('hmac_key', self::DEFAULT_HMAC),
|
||||
"secret" => $this->config->get('hmac_key'),
|
||||
"path" => "/api",
|
||||
"ignore" => $this->getPassThroughRoutes($container),
|
||||
"secure" => true,
|
||||
"relaxed" => [
|
||||
"localhost",
|
||||
"wnapi.yvan.hu",
|
||||
],
|
||||
"error" => function (ResponseInterface $response, $arguments) {
|
||||
$data["status"] = "error";
|
||||
|
||||
@ -44,12 +44,12 @@ class RouteAuthorization implements MiddlewareInterface
|
||||
$routeResult = $request->getAttribute(RouteResult::class, false);
|
||||
$token = $request->getAttribute('token');
|
||||
|
||||
if ($this->hasRouteAccess($routeResult->getMatchedRouteName(), $token->roles ?? [])) {
|
||||
if ($this->hasRouteAccess($routeResult->getMatchedRouteName(), $token['roles'] ?? [])) {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
return new JsonResponse([
|
||||
'status' => 'err',
|
||||
'status' => $token['roles'],
|
||||
'message' => "Access denied to " . $routeResult->getMatchedRouteName(),
|
||||
], 401);
|
||||
}
|
||||
|
||||
@ -126,14 +126,14 @@ class AuthService
|
||||
$builder = new Builder();
|
||||
|
||||
return $builder
|
||||
->setId($token->jti, true)
|
||||
->setId($token['jti'], true)
|
||||
->setIssuedAt(time())
|
||||
->setNotBefore(time())
|
||||
->setExpiration(time() + 3600)
|
||||
->set('uid', $token->uid)
|
||||
->set('name', $token->name)
|
||||
->set('email', $token->email)
|
||||
->set('roles', $token->roles)
|
||||
->set('uid', $token['uid'])
|
||||
->set('name', $token['name'])
|
||||
->set('email', $token['email'])
|
||||
->set('roles', $token['roles'])
|
||||
->sign($signer, $hmacKey)
|
||||
->getToken();
|
||||
}
|
||||
|
||||
@ -6,11 +6,11 @@ use App\ApiResponse;
|
||||
use App\Entity\Attachment;
|
||||
use App\Entity\Fault;
|
||||
use App\Entity\User;
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Doctrine\ORM\Query;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
class FaultAttachmentService
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class FaultAttachmentServiceFactory
|
||||
|
||||
@ -6,9 +6,9 @@ use App\Entity\Fault;
|
||||
use App\Entity\FaultComment;
|
||||
use App\Entity\FaultSnapshot;
|
||||
use App\Entity\User;
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Query;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
|
||||
class FaultManagerService
|
||||
{
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class FaultManagerServiceFactory
|
||||
|
||||
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Fixture\ErrorCategoryLoader;
|
||||
use App\Fixture\ErrorOriginLoader;
|
||||
use App\Fixture\FacilityLocationLoader;
|
||||
use App\Fixture\SolutionTimeIntervalLoader;
|
||||
use App\Fixture\UserLoader;
|
||||
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
||||
use Doctrine\Common\DataFixtures\Loader;
|
||||
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FixtureLoaderService
|
||||
{
|
||||
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $em;
|
||||
|
||||
public function __construct(EntityManager $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function load(OutputInterface $output)
|
||||
{
|
||||
$loader = new Loader();
|
||||
$loader->addFixture(new ErrorCategoryLoader($output));
|
||||
$loader->addFixture(new ErrorOriginLoader($output));
|
||||
$loader->addFixture(new FacilityLocationLoader($output));
|
||||
$loader->addFixture(new SolutionTimeIntervalLoader($output));
|
||||
$loader->addFixture(new UserLoader($output));
|
||||
|
||||
$purger = new ORMPurger();
|
||||
$executor = new ORMExecutor($this->em, $purger);
|
||||
$executor->execute($loader->getFixtures());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
56
src/App/Service/FixtureManager.php
Normal file
56
src/App/Service/FixtureManager.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Fixture\ErrorCategoryFixture;
|
||||
use App\Fixture\ErrorOriginFixture;
|
||||
use App\Fixture\FacilityLocationFixture;
|
||||
use App\Fixture\SolutionTimeIntervalFixture;
|
||||
use App\Fixture\UserFixture;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\Fixture\Configuration;
|
||||
use Doctrine\Fixture\Executor;
|
||||
use Doctrine\Fixture\Filter\ChainFilter;
|
||||
use Doctrine\Fixture\Loader\ClassLoader;
|
||||
use Doctrine\Fixture\Reference\DoctrineCacheReferenceRepository;
|
||||
use Doctrine\Fixture\Reference\ReferenceRepositoryEventSubscriber;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FixtureManager
|
||||
{
|
||||
|
||||
/** @var EntityManager */
|
||||
private $em;
|
||||
|
||||
public function __construct(EntityManager $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function initialize(OutputInterface $output)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$executor = new Executor($configuration);
|
||||
$classLoader = new ClassLoader([
|
||||
new ErrorCategoryFixture($output, $this->em),
|
||||
new ErrorOriginFixture($output, $this->em),
|
||||
new FacilityLocationFixture($output, $this->em),
|
||||
new SolutionTimeIntervalFixture($output, $this->em),
|
||||
new UserFixture($output, $this->em),
|
||||
]);
|
||||
$filter = new ChainFilter();
|
||||
|
||||
$eventManager = $configuration->getEventManager();
|
||||
$eventManager->addEventSubscriber(
|
||||
new ReferenceRepositoryEventSubscriber(
|
||||
new DoctrineCacheReferenceRepository(
|
||||
new ArrayCache()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$executor->execute($classLoader, $filter, Executor::IMPORT | Executor::PURGE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -5,13 +5,13 @@ namespace App\Service;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class FixtureLoaderServiceFactory
|
||||
class FixtureManagerFactory
|
||||
{
|
||||
|
||||
public function __invoke(ContainerInterface $container): FixtureLoaderService
|
||||
public function __invoke(ContainerInterface $container): FixtureManager
|
||||
{
|
||||
/** @var EntityManager $em */
|
||||
$em = $container->get('doctrine.entity_manager.orm_default');
|
||||
return new FixtureLoaderService($em);
|
||||
return new FixtureManager($em);
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,11 @@ use Monolog\Logger;
|
||||
class LoggerFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return Logger
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __invoke(ContainerInterface $container): Logger
|
||||
{
|
||||
$config = $container->get('config');
|
||||
|
||||
@ -6,10 +6,10 @@ use App\Entity\Device;
|
||||
use App\Entity\DeviceGroup;
|
||||
use App\Entity\DeviceMaintenanceTask;
|
||||
use App\Entity\Maintenance;
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Query;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
|
||||
class MaintenanceManagerService
|
||||
{
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class MaintenanceManagerServiceFactory
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
use Zend\Crypt\Password\Bcrypt;
|
||||
|
||||
class UserService
|
||||
@ -41,6 +41,9 @@ class UserService
|
||||
/**
|
||||
* @param int $id
|
||||
* @return User
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
* @throws \Doctrine\ORM\TransactionRequiredException
|
||||
*/
|
||||
public function get(int $id): User
|
||||
{
|
||||
@ -53,6 +56,9 @@ class UserService
|
||||
* @param int $id
|
||||
* @param $data
|
||||
* @return User
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
* @throws \Doctrine\ORM\TransactionRequiredException
|
||||
*/
|
||||
public function update(int $id, $data): User
|
||||
{
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Hydrator\DoctrineObject;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use DoctrineExpressiveModule\Hydrator\DoctrineObject;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class UserServiceFactory
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user