|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / app / code / Mirasvit / ReportApi / Config / Entity / |
Filename | /home/dev2.destoffenstraat.com/app/code/Mirasvit/ReportApi/Config/Entity/Relation.php |
Size | 4.13 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 15-Oct-2024 20:30 |
Last accessed | 22-Aug-2025 02:07 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* Mirasvit
*
* This source file is subject to the Mirasvit Software License, which is available at https://mirasvit.com/license/.
* Do not edit or add to this file if you wish to upgrade the to newer versions in the future.
* If you wish to customize this module for your needs.
* Please refer to http://www.magentocommerce.com for more information.
*
* @category Mirasvit
* @package mirasvit/module-report-api
* @version 1.0.71
* @copyright Copyright (C) 2024 Mirasvit (https://mirasvit.com/)
*/
namespace Mirasvit\ReportApi\Config\Entity;
use Mirasvit\ReportApi\Api\Config\FieldInterface;
use Mirasvit\ReportApi\Api\Config\RelationInterface;
use Mirasvit\ReportApi\Api\Config\TableInterface;
class Relation implements RelationInterface
{
/**
* @var TableInterface
*/
private $leftTable;
/**
* @var FieldInterface
*/
private $leftField;
/**
* @var TableInterface
*/
private $rightTable;
/**
* @var FieldInterface
*/
private $rightField;
/**
* @var string
*/
private $condition;
/**
* @var string
*/
private $type;
/**
* Relation constructor.
* @param TableInterface $leftTable
* @param mixed $leftField
* @param TableInterface $rightTable
* @param mixed $rightField
* @param string $type
* @param string $condition
*/
public function __construct(
TableInterface $leftTable,
$leftField,
TableInterface $rightTable,
$rightField,
$type,
$condition = ''
) {
$this->leftTable = $leftTable;
$this->leftField = $leftField;
$this->rightTable = $rightTable;
$this->rightField = $rightField;
$this->condition = $condition;
$this->type = $type;
}
/**
* {@inheritdoc}
*/
public function getLeftTable()
{
return $this->leftTable;
}
/**
* @return FieldInterface
*/
public function getLeftField()
{
return $this->leftField;
}
/**
* {@inheritdoc}
*/
public function getRightTable()
{
return $this->rightTable;
}
/**
* @return FieldInterface
*/
public function getRightField()
{
return $this->rightField;
}
/**
* {@inheritdoc}
*/
public function getType(TableInterface $table)
{
if ($this->rightTable === $table) {
return $this->type[1];
}
return $this->type[0];
}
/**
* {@inheritdoc}
*/
public function getOppositeTable(TableInterface $table)
{
if ($this->leftTable === $table) {
return $this->rightTable;
} elseif ($this->rightTable === $table) {
return $this->leftTable;
}
return false;
}
/**
* @param FieldInterface $field
* @return bool|FieldInterface
*/
public function getOppositeField(FieldInterface $field)
{
if ($this->leftField === $field) {
return $this->rightField;
} elseif ($this->rightField === $field) {
return $this->leftField;
}
return false;
}
/**
* @return string
*/
public function __toString()
{
return "{$this->type}\t{$this->leftTable->getName()}\t{$this->rightTable->getName()}\t\t{$this->getCondition()}";
}
/**
* {@inheritdoc}
*/
public function getCondition()
{
$condition = '';
if ($this->leftField && $this->rightField) {
$right = $this->rightField instanceof FieldInterface ? $this->rightField->toDbExpr() : $this->rightField;
$condition = $this->leftField->toDbExpr() . ' = ' . $right;
}
if ($this->condition) {
if ($condition) {
$condition .= ' AND ' . $this->condition;
} else {
$condition .= $this->condition;
}
$condition = str_replace('%1', $this->leftTable->getName(), $condition);
$condition = str_replace('%2', $this->rightTable->getName(), $condition);
}
//
return $condition;
}
}
/**
* Mirasvit
*
* This source file is subject to the Mirasvit Software License, which is available at https://mirasvit.com/license/.
* Do not edit or add to this file if you wish to upgrade the to newer versions in the future.
* If you wish to customize this module for your needs.
* Please refer to http://www.magentocommerce.com for more information.
*
* @category Mirasvit
* @package mirasvit/module-report-api
* @version 1.0.71
* @copyright Copyright (C) 2024 Mirasvit (https://mirasvit.com/)
*/
namespace Mirasvit\ReportApi\Config\Entity;
use Mirasvit\ReportApi\Api\Config\FieldInterface;
use Mirasvit\ReportApi\Api\Config\RelationInterface;
use Mirasvit\ReportApi\Api\Config\TableInterface;
class Relation implements RelationInterface
{
/**
* @var TableInterface
*/
private $leftTable;
/**
* @var FieldInterface
*/
private $leftField;
/**
* @var TableInterface
*/
private $rightTable;
/**
* @var FieldInterface
*/
private $rightField;
/**
* @var string
*/
private $condition;
/**
* @var string
*/
private $type;
/**
* Relation constructor.
* @param TableInterface $leftTable
* @param mixed $leftField
* @param TableInterface $rightTable
* @param mixed $rightField
* @param string $type
* @param string $condition
*/
public function __construct(
TableInterface $leftTable,
$leftField,
TableInterface $rightTable,
$rightField,
$type,
$condition = ''
) {
$this->leftTable = $leftTable;
$this->leftField = $leftField;
$this->rightTable = $rightTable;
$this->rightField = $rightField;
$this->condition = $condition;
$this->type = $type;
}
/**
* {@inheritdoc}
*/
public function getLeftTable()
{
return $this->leftTable;
}
/**
* @return FieldInterface
*/
public function getLeftField()
{
return $this->leftField;
}
/**
* {@inheritdoc}
*/
public function getRightTable()
{
return $this->rightTable;
}
/**
* @return FieldInterface
*/
public function getRightField()
{
return $this->rightField;
}
/**
* {@inheritdoc}
*/
public function getType(TableInterface $table)
{
if ($this->rightTable === $table) {
return $this->type[1];
}
return $this->type[0];
}
/**
* {@inheritdoc}
*/
public function getOppositeTable(TableInterface $table)
{
if ($this->leftTable === $table) {
return $this->rightTable;
} elseif ($this->rightTable === $table) {
return $this->leftTable;
}
return false;
}
/**
* @param FieldInterface $field
* @return bool|FieldInterface
*/
public function getOppositeField(FieldInterface $field)
{
if ($this->leftField === $field) {
return $this->rightField;
} elseif ($this->rightField === $field) {
return $this->leftField;
}
return false;
}
/**
* @return string
*/
public function __toString()
{
return "{$this->type}\t{$this->leftTable->getName()}\t{$this->rightTable->getName()}\t\t{$this->getCondition()}";
}
/**
* {@inheritdoc}
*/
public function getCondition()
{
$condition = '';
if ($this->leftField && $this->rightField) {
$right = $this->rightField instanceof FieldInterface ? $this->rightField->toDbExpr() : $this->rightField;
$condition = $this->leftField->toDbExpr() . ' = ' . $right;
}
if ($this->condition) {
if ($condition) {
$condition .= ' AND ' . $this->condition;
} else {
$condition .= $this->condition;
}
$condition = str_replace('%1', $this->leftTable->getName(), $condition);
$condition = str_replace('%2', $this->rightTable->getName(), $condition);
}
//
return $condition;
}
}