/** * Handle the magic call by properly creating a Query object and returning its result. * * @param string $propertyName * @param string $value * @param string $flag * @return array */ protected function processMagicCall($propertyName, $value, $flag = '') { $fieldName = Property::name($propertyName)->of($this->dataType)->toFieldName(); /** @var $matcher Matcher */ $matcher = GeneralUtility::makeInstance('Fab\\Vidi\\Persistence\\Matcher', array(), $this->getDataType()); $table = Tca::table($this->dataType); if ($table->field($fieldName)->isGroup()) { $valueParts = explode('.', $value, 2); $fieldName = $fieldName . '.' . $valueParts[0]; $value = $valueParts[1]; } $matcher->equals($fieldName, $value); if ($flag == 'count') { $result = $this->countBy($matcher); } else { $result = $this->findBy($matcher); } return $flag == 'one' && !empty($result) ? reset($result) : $result; }
/** * Return the properties of this object. * * @return array */ public function toFields() { $result[] = 'uid'; $propertiesAndValues = json_decode(json_encode($this), TRUE); foreach ($propertiesAndValues as $propertyName => $value) { $result[] = Property::name($propertyName)->of($this)->toFieldName(); } return $result; }