/**
* Get CakePHP property
*
* @param string $dataName Column data name
*
* @throws Exception
* @return array|string
*/
protected function getProperty($dataName)
{
$dataName = explode('.', trim($dataName));
if (count($dataName) != 2) {
throw new Exception('You are set invalid date.');
}
$tableAlias = $dataName[0];
$colName = $dataName[1];
if ($this->query->repository()->alias() == $tableAlias) {
return $colName;
} elseif (array_key_exists($tableAlias, $this->query->contain())) {
return ['propertyPath' => $this->query->eagerLoader()->normalized($this->query->repository())[$tableAlias]['propertyPath'], 'field' => $colName];
}
}