diff --git a/src/Service/SchemaService.php b/src/Service/SchemaService.php index ffb6e001161635212ad7fd5ff8eea35be4fcc130..692bcc45c18c8b51639eb0a0da5d321c3c7fa1ac 100644 --- a/src/Service/SchemaService.php +++ b/src/Service/SchemaService.php @@ -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