Преглед на файлове

Ajout ArrayComponent

feature/symfony6.1
Guillaume Bourgeois преди 2 години
родител
ревизия
8c27fabfae
променени са 2 файла, в които са добавени 29 реда и са изтрити 1 реда
  1. +20
    -0
      Component/ArrayComponent.php
  2. +9
    -1
      Container/ComponentContainer.php

+ 20
- 0
Component/ArrayComponent.php Целия файл

@@ -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 Целия файл

@@ -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…
Отказ
Запис