web-base/Core/Objects/DatabaseEntity/Controller/NMRelationReference.class.php

49 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2023-01-10 22:12:05 +01:00
<?php
namespace Core\Objects\DatabaseEntity\Controller;
use Core\Driver\SQL\SQL;
class NMRelationReference implements Persistable {
private DatabaseEntityHandler $handler;
private string $thisProperty;
private string $refProperty;
public function __construct(DatabaseEntityHandler $handler, string $thisProperty, string $refProperty) {
$this->handler = $handler;
$this->thisProperty = $thisProperty;
$this->refProperty = $refProperty;
}
public function dependsOn(): array {
return [$this->handler->getTableName()];
}
public function getTableName(): string {
return $this->handler->getTableName();
}
public function getCreateQueries(SQL $sql): array {
return []; // nothing to do here, will be managed by other handler
}
public function getThisProperty(): string {
return $this->thisProperty;
}
public function getRefProperty(): string {
return $this->refProperty;
}
2023-01-16 21:47:23 +01:00
public function getRefColumns(): array {
return [
$this->handler->getColumnName($this->getThisProperty(), false),
$this->handler->getColumnName($this->getRefProperty(), false),
];
}
2023-01-10 22:12:05 +01:00
public function getRelHandler(): DatabaseEntityHandler {
return $this->handler;
}
}