/** * Get current entity identifiers collection by relation identifier ans its value. * * @param string $relationID Relation entity identifier * @param mixed|Condition $relationValue Relation entity value or relation condition * @param array $filteringIDs Collection of entity identifiers for filtering query * @param string $locale Locale for requests * @return array Collection of entity identifiers filtered by navigation identifier. */ public function idsByRelationID($relationID, $relationValue = null, array $filteringIDs = array(), $locale = null) { $return = array(); /** @var Field $fieldRecord We need to have field record */ $fieldRecord = null; if (Field::byID($this->query, $relationID, $fieldRecord)) { // Get material identifiers by field $this->query->entity($this->relationIdentifier)->where(\samsoncms\api\MaterialField::F_DELETION, 1)->where($this->relationPrimary, $relationID); if ($relationValue instanceof ConditionInterface) { $this->query->whereCondition($relationValue); } else { $this->query->where($fieldRecord->valueFieldName(), $relationValue); } // Add material identifier filter if passed if (count($filteringIDs)) { $this->query->where($this->primaryField, $filteringIDs); } // If field is localized if ((int) $fieldRecord->local === 1) { // Add localization filter $this->query->where(\samsoncms\api\MaterialField::F_LOCALE, $locale); } // Perform database query and get only material identifiers collection $return = $this->query->fields($this->primaryField); } return $return; }
/** * Get select additional field text value. * * @param string $fieldID Field identifier * @return string Select field text */ public function selectText($fieldID) { // TODO: this is absurd as we do not have any additional values here /** @var Field $field */ $field = null; // If this entity has this field set if (Field::byID($this->query, $fieldID, $field) && isset($this[$field->Name][0])) { return $field->options($this[$field->Name]); } // Value not set return ''; }