Admin Model

It is method to get a single record.

integer $pk - The id of the primary key.

return \JObject|boolean - Object on success, false on failure.

public function getItem($pk = null)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState($this->getName() . '.id');
$table = $this->getTable();

if ($pk > 0)
{
// Attempt to load the row.
$return = $table->load($pk);

// Check for a table object error.
if ($return === false && $table->getError())
{
$this->setError($table->getError());

return false;
}
}

// Convert to the \JObject before adding other data.
$properties = $table->getProperties(1);
$item = ArrayHelper::toObject($properties, '\JObject');

if (property_exists($item, 'params'))
{
$registry = new Registry($item->params);
$item->params = $registry->toArray();
}

return $item;
}