unify access to custom fields (#3106)
This commit is contained in:
@@ -261,6 +261,20 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getMetaFieldValue(string $name)
|
||||
{
|
||||
$field = $this->getMetaField($name);
|
||||
if ($field === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $field->getValue();
|
||||
}
|
||||
|
||||
public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields
|
||||
{
|
||||
if (null === ($current = $this->getMetaField($meta->getName()))) {
|
||||
|
||||
@@ -531,6 +531,20 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getMetaFieldValue(string $name)
|
||||
{
|
||||
$field = $this->getMetaField($name);
|
||||
if ($field === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $field->getValue();
|
||||
}
|
||||
|
||||
public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields
|
||||
{
|
||||
if (null === ($current = $this->getMetaField($meta->getName()))) {
|
||||
|
||||
@@ -441,6 +441,20 @@ class Invoice implements EntityWithMetaFields
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getMetaFieldValue(string $name)
|
||||
{
|
||||
$field = $this->getMetaField($name);
|
||||
if ($field === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $field->getValue();
|
||||
}
|
||||
|
||||
public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields
|
||||
{
|
||||
if (null === ($current = $this->getMetaField($meta->getName()))) {
|
||||
|
||||
@@ -29,7 +29,7 @@ interface MetaTableTypeInterface
|
||||
public function setName(string $name): MetaTableTypeInterface;
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
* @return int|bool|string|null
|
||||
*/
|
||||
public function getValue();
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ trait MetaTableTypeTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
* @return int|bool|string|null
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
|
||||
@@ -425,6 +425,20 @@ class Project implements EntityWithMetaFields, EntityWithBudget
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getMetaFieldValue(string $name)
|
||||
{
|
||||
$field = $this->getMetaField($name);
|
||||
if ($field === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $field->getValue();
|
||||
}
|
||||
|
||||
public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields
|
||||
{
|
||||
if (null === ($current = $this->getMetaField($meta->getName()))) {
|
||||
|
||||
@@ -719,6 +719,20 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getMetaFieldValue(string $name)
|
||||
{
|
||||
$field = $this->getMetaField($name);
|
||||
if ($field === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $field->getValue();
|
||||
}
|
||||
|
||||
public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields
|
||||
{
|
||||
if (null === ($current = $this->getMetaField($meta->getName()))) {
|
||||
|
||||
@@ -537,7 +537,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $default
|
||||
* @return bool|int|null|string
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getPreferenceValue(string $name, $default = null)
|
||||
{
|
||||
@@ -549,6 +549,15 @@ class User implements UserInterface, EquatableInterface, \Serializable
|
||||
return $preference->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getMetaFieldValue(string $name)
|
||||
{
|
||||
return $this->getPreferenceValue($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserPreference $preference
|
||||
* @return User
|
||||
|
||||
Reference in New Issue
Block a user