public function getAll($filter = null)
    {
        $className = self::getEntitiesClassName();
        $results = $this->getDataSource()->retrieveAll($filter);

        // Convert the resulting data to entities.
        $entities = array();
        foreach ($results as $data) {
            $id = @$data['id'];
            $entity = $this->getEntity($id);
            if (empty($entity)) {
                $entity = new $className($data);
            }
            $entities[] = $entity;
        }

        return $entities;
    }