I want to create own custom meta-data parser for Phalcon models (as current hasn't annotations for indexes and mapping one column to another parameter). Unfortunately, when I am returning mapping as array:
/**
* @param \Phalcon\Mvc\ModelInterface $model
* @param \Phalcon\DiInterface $di
* @return array
*/
public function getColumnMaps($model, $di)
{
$columns = [];
/** @var \Phalcon\Annotations\Reflection $reflection */
$reflection = $di->get('annotations')->get($model);
foreach ($reflection->getPropertiesAnnotations() as $name => $collection) {
if ($collection->has('Column')) {
$columns[$collection->get('Column')->getNamedArgument('column') ?: $name] = $name;
}
}
return $columns;
}
As I found, Phalcon\Mvc\Model\MetaData\Strategy\Annotations in that method returns null. My result is like array of ID_IN_TABLE => PARAMETER_NAME, eg. 'referer_id' => 'refererId' which map field from database with underscore with camel-case field from model. It throws errors Notice: Undefined index: 0 and Notice: Undefined index: 1 when I am trying to use find, count or findFirst method, e.g.:
Users::find([
implode(' AND ', $conditions),
'bind' => $bind,
'limit' => $this->getLimit(),
'offset' => $this->getLimit() * ($this->getPage() - 1)
])
What am I doing wrong?
Thanks in advance, David.