Skip to content
Snippets Groups Projects
Commit 547f6954 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Nouvelle méthode isImportedProperty

parent 01b49a83
No related branches found
No related tags found
No related merge requests found
Pipeline #18127 passed
......@@ -147,7 +147,7 @@ class SchemaService extends AbstractService
*
* @return string[]
*/
public function getImportViews()
public function getImportViews(): array
{
$sql = "SELECT view_name FROM USER_VIEWS WHERE view_name LIKE 'SRC_%'";
$stmt = $this->getEntityManager()->getConnection()->query($sql);
......@@ -167,7 +167,7 @@ class SchemaService extends AbstractService
* @param string $tableName
* @param string $columnName
*/
public function hasColumn($tableName, $columnName)
public function hasColumn(string $tableName, string $columnName): bool
{
$sql = "
SELECT
......@@ -188,7 +188,7 @@ class SchemaService extends AbstractService
/**
* Retourne les colonnes concernées par l'import pour une table donnée
*/
public function getImportCols($tableName)
public function getImportCols($tableName): array
{
if (!array_key_exists($tableName, $this->importColsCache)) {
$sql = "
......@@ -216,18 +216,18 @@ class SchemaService extends AbstractService
/**
* Détecte si une propriété d'une classe est importable ou non
*
* @param string|\stdClass $className
* @param object|string $entity
* @param string $fieldName
*
* @return bool
*/
public function isImportedProperty($className, string $fieldName): bool
public function isImportedProperty(object|string $entity, string $fieldName): bool
{
if (is_object($className)){
$className = get_class($className);
if (is_object($entity)){
$entity = get_class($entity);
}
$metadata = $this->getEntityManager()->getClassMetadata($className);
$metadata = $this->getEntityManager()->getClassMetadata($entity);
$tableName = $metadata->getTableName();
......@@ -242,4 +242,24 @@ class SchemaService extends AbstractService
return in_array($columnName, $importCols);
}
/**
* @param object|string $entity
*
* @return bool
*/
public function isImportedEntity(object|string $entity): bool
{
if (is_object($entity)){
$entity = get_class($entity);
}
$metadata = $this->getEntityManager()->getClassMetadata($entity);
$tableName = $metadata->getTableName();
return in_array($tableName, $this->getImportTables());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment