2015-07-23 11:43:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Objects;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Data\Db\DbObject;
|
|
|
|
|
|
|
|
class SyncProperty extends DbObject
|
|
|
|
{
|
|
|
|
protected $table = 'sync_property';
|
|
|
|
|
|
|
|
protected $keyName = 'id';
|
|
|
|
|
|
|
|
protected $autoincKeyName = 'id';
|
|
|
|
|
|
|
|
protected $defaultProperties = array(
|
2016-02-26 11:58:37 +01:00
|
|
|
'id' => null,
|
|
|
|
'rule_id' => null,
|
|
|
|
'source_id' => null,
|
2015-11-02 09:11:13 +01:00
|
|
|
'source_expression' => null,
|
2016-02-26 11:58:37 +01:00
|
|
|
'destination_field' => null,
|
|
|
|
'priority' => null,
|
|
|
|
'filter_expression' => null,
|
|
|
|
'merge_policy' => null
|
2015-07-23 11:43:41 +02:00
|
|
|
);
|
|
|
|
|
2016-02-26 11:58:37 +01:00
|
|
|
/**
|
|
|
|
* Virtual property for source_column
|
|
|
|
*
|
|
|
|
* Internally we always use an expression. Form indirectly uses this
|
|
|
|
*
|
|
|
|
* Avoid complaints for method names with underscore:
|
|
|
|
* @codingStandardsIgnoreStart
|
|
|
|
*
|
|
|
|
* @return self
|
|
|
|
*/
|
2015-11-02 09:11:13 +01:00
|
|
|
public function setSource_column($value)
|
|
|
|
{
|
2016-02-26 11:58:37 +01:00
|
|
|
// @codingStandardsIgnoreEnd
|
2015-11-02 16:21:35 +01:00
|
|
|
$this->source_expression = '${' . $value . '}';
|
2016-02-26 11:58:37 +01:00
|
|
|
return $this;
|
2015-11-02 09:11:13 +01:00
|
|
|
}
|
2015-11-06 09:50:06 +01:00
|
|
|
|
|
|
|
public function sourceIsSingleColumn()
|
|
|
|
{
|
|
|
|
return $this->getSourceColumn() !== null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSourceColumn()
|
|
|
|
{
|
|
|
|
if (preg_match('/^\${([A-Za-z0-9_-]+)}$/', $this->source_expression, $m)) {
|
|
|
|
return $m[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2015-07-23 11:43:41 +02:00
|
|
|
}
|