/** * Get entity by type * * @param string $type * @param int $limit * @param int $page * @param string $sort * @return array */ public function getByType($type, $limit = null, $page = null, $sort = null) { $entityType = is_numeric($type) ? Table\EntityTypes::findById($type) : Table\EntityTypes::findBy(['name' => $type]); $rows = []; if (isset($entityType->id)) { $rows = $this->getAll($entityType->id, $limit, $page, $sort); } return $rows; }
/** * Remove an entity type * * @param array $fields * @return void */ public function remove(array $fields) { if (isset($fields['rm_entity_types'])) { foreach ($fields['rm_entity_types'] as $id) { $type = Table\EntityTypes::findById((int) $id); if (isset($type->id)) { $type->delete(); } } } }