I have a strange problem with the following public method on a model.
public function getAttributes()
{
return $this->getId() . $this->getStyle() . $this->getDataAttributes();
}
CMapIterator
warns with the following array_keys() expects parameter 1 to be array, string given
But if I alter it to
public function getAttributes()
{
return array($this->getId() . $this->getStyle() . $this->getDataAttributes())[0];
}
Everybody is happy. It's late and I'm probably shouldn't be coding but any thoughts on the issue would be much appreciated.
Here is the complete model for reference...
namespace Craft;
class Core_CodeModel extends BaseModel
{
/**
* @return array
*/
protected function defineAttributes()
{
return array_merge(parent::defineAttributes(), array(
'cssId' => array(AttributeType::String),
'cssClass' => array(AttributeType::String),
'style' => array(AttributeType::String),
'dataAttributes' => array(AttributeType::Mixed),
));
}
public function getDataAttributes()
{
return is_array($this->dataAttributes) ? ' ' . craft()->core_code->joinDataAttributes($this->dataAttributes) : '';
}
public function getId()
{
return !empty($this->cssId) ? ' id="' . $this->cssId . '"' : '';
}
public function getStyle()
{
return !empty($this->style) ? ' style="' . str_replace(array("\r", "\n"), '', $this->style) . '"' : '';
}
public function getAttributes()
{
return $this->getId() . $this->getStyle() . $this->getDataAttributes();
}
}