Back to CMSHelper class

Method getDataObject

public \stdClass
getDataObject
(\Joomla\CMS\Table\TableInterface $table)
Method to get an object containing all of the table columns and values.
Parameters
  • \Joomla\CMS\Table\TableInterface $table Table object.
Returns
  • \stdClass Contains all of the columns and values.
Since
  • 3.2
Class: CMSHelper
Project: Joomla

Method getDataObject - Source code

/**
 * Method to get an object containing all of the table columns and values.
 *
 * @param   TableInterface  $table  Table object.
 *
 * @return  \stdClass  Contains all of the columns and values.
 *
 * @since   3.2
 */
public function getDataObject(TableInterface $table)
{
    $fields = $table->getFields();
    $dataObject = new \stdClass();
    foreach ($fields as $field) {
        $fieldName = $field->Field;
        $dataObject->{$fieldName} = $table->get($fieldName);
    }
    return $dataObject;
}