Browse Source

Ajout ArrayComponent

feature/symfony6.1
Guillaume Bourgeois 1 year ago
parent
commit
8c27fabfae
2 changed files with 29 additions and 1 deletions
  1. +20
    -0
      Component/ArrayComponent.php
  2. +9
    -1
      Container/ComponentContainer.php

+ 20
- 0
Component/ArrayComponent.php View File

@@ -0,0 +1,20 @@
<?php

namespace Lc\SovBundle\Component;

use Cocur\Slugify\Slugify;

class ArrayComponent
{
public function contains(array $array, $entity): bool
{
foreach($array as $entityTest) {
if(get_class($entityTest) == get_class($entity)
&& $entityTest->getId() == $entity->getId()) {
return true;
}
}

return false;
}
}

+ 9
- 1
Container/ComponentContainer.php View File

@@ -26,6 +26,7 @@ class ComponentContainer
protected NumberComponent $numberComponent;
protected PointLocationComponent $pointLocationComponent;
protected StringComponent $stringComponent;
protected ArrayComponent $arrayComponent;

public function __construct(
CitiesComponent $citiesComponent,
@@ -37,7 +38,8 @@ class ComponentContainer
MetaComponent $metaComponent,
NumberComponent $numberComponent,
PointLocationComponent $pointLocationComponent,
StringComponent $stringComponent
StringComponent $stringComponent,
ArrayComponent $arrayComponent
) {
$this->citiesComponent = $citiesComponent;
$this->cookieComponent = $cookieComponent;
@@ -49,6 +51,7 @@ class ComponentContainer
$this->numberComponent = $numberComponent;
$this->pointLocationComponent = $pointLocationComponent;
$this->stringComponent = $stringComponent;
$this->arrayComponent = $arrayComponent;
}

public function getCitiesComponent(): CitiesComponent
@@ -100,4 +103,9 @@ class ComponentContainer
{
return $this->stringComponent;
}

public function getArrayComponent(): ArrayComponent
{
return $this->arrayComponent;
}
}

Loading…
Cancel
Save