public function exportContenttypesRecords() { if ($this->getError()) { return $this; } // Keep track of our export progress as some data formats require closing elements $last = false; $end = array_keys($this->contenttypes); $end = end($end); foreach ($this->contenttypes as $key => $contenttype) { if ($key === $end) { $last = true; } $this->exportContenttypeRecords($contenttype, $last); } return $this; }