/** * Get tag content * * @param Table\Tags $tag * @param \Pop\Module\Manager $modules * @return void */ protected function getTag(Table\Tags $tag, \Pop\Module\Manager $modules) { if ($modules->isRegistered('phire-fields')) { $t = \Phire\Fields\Model\FieldValue::getModelObject('Phire\\Tags\\Model\\Tag', [$tag->id]); $data = $t->toArray(); } else { $data = $tag->getColumns(); } $items = []; $c2t = Table\TagItems::findBy(['tag_id' => $tag->id], ['order' => 'content_id DESC']); if ($c2t->hasRows()) { foreach ($c2t->rows() as $c) { if ($modules->isRegistered('phire-fields')) { $item = \Phire\Fields\Model\FieldValue::getModelObject('Phire\\Content\\Model\\Content', [$c->content_id], 'getById', $modules['phire-tags']['filters']); } else { $class = 'Phire\\Content\\Model\\Content'; $model = new $class(); call_user_func_array([$model, 'getById'], [$c->content_id]); $item = $model; } if ($item->status == 1 && count($item->roles) == 0) { $items[$item->id] = new \ArrayObject($item->toArray(), \ArrayObject::ARRAY_AS_PROPS); } } } $data['items'] = $items; $this->data = array_merge($this->data, $data); }