From af9718951fc1ca60fe5988e52efb32cf575513e2 Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 26 Dec 2018 12:54:58 +0200 Subject: [PATCH] record service naming change --- application/Espo/Core/Controllers/Record.php | 24 ++++++++++---------- application/Espo/Services/Attachment.php | 4 ++-- application/Espo/Services/Email.php | 4 ++-- application/Espo/Services/EmailAccount.php | 4 ++-- application/Espo/Services/InboundEmail.php | 18 --------------- application/Espo/Services/Note.php | 12 +++++----- application/Espo/Services/Record.php | 21 ++++++++++------- application/Espo/Services/RecordTree.php | 8 +++---- application/Espo/Services/User.php | 12 +++++----- 9 files changed, 47 insertions(+), 60 deletions(-) diff --git a/application/Espo/Core/Controllers/Record.php b/application/Espo/Core/Controllers/Record.php index 6d20849c26..594ea8096b 100644 --- a/application/Espo/Core/Controllers/Record.php +++ b/application/Espo/Core/Controllers/Record.php @@ -67,7 +67,7 @@ class Record extends Base public function actionRead($params, $data, $request) { $id = $params['id']; - $entity = $this->getRecordService()->readEntity($id); + $entity = $this->getRecordService()->read($id); if (empty($entity)) { throw new NotFound(); @@ -95,7 +95,7 @@ class Record extends Base $service = $this->getRecordService(); - if ($entity = $service->createEntity($data)) { + if ($entity = $service->create($data)) { return $entity->getValueMap(); } @@ -116,7 +116,7 @@ class Record extends Base $id = $params['id']; - if ($entity = $this->getRecordService()->updateEntity($id, $data)) { + if ($entity = $this->getRecordService()->update($id, $data)) { return $entity->getValueMap(); } @@ -140,12 +140,12 @@ class Record extends Base throw new Forbidden("Max size should should not exceed " . $maxSizeLimit . ". Use offset and limit."); } - $result = $this->getRecordService()->findEntities($params); + $result = $this->getRecordService()->find($params); - return array( + return [ 'total' => $result['total'], 'list' => isset($result['collection']) ? $result['collection']->getValueMapList() : $result['list'] - ); + ]; } public function getActionListKanban($params, $data, $request) @@ -195,7 +195,7 @@ class Record extends Base throw new Forbidden("Max size should should not exceed " . $maxSizeLimit . ". Use offset and limit."); } - $result = $this->getRecordService()->findLinkedEntities($id, $link, $params); + $result = $this->getRecordService()->findLinked($id, $link, $params); return array( 'total' => $result['total'], @@ -211,7 +211,7 @@ class Record extends Base $id = $params['id']; - if ($this->getRecordService()->deleteEntity($id)) { + if ($this->getRecordService()->delete($id)) { return true; } throw new Error(); @@ -262,9 +262,9 @@ class Record extends Base $params['format'] = $data->format; } - return array( + return [ 'id' => $this->getRecordService()->export($params) - ); + ]; } public function actionMassUpdate($params, $data, $request) @@ -363,7 +363,7 @@ class Record extends Base $result = false; foreach ($foreignIdList as $foreignId) { - if ($this->getRecordService()->linkEntity($id, $link, $foreignId)) { + if ($this->getRecordService()->link($id, $link, $foreignId)) { $result = true; } } @@ -400,7 +400,7 @@ class Record extends Base $result = false; foreach ($foreignIdList as $foreignId) { - if ($this->getRecordService()->unlinkEntity($id, $link, $foreignId)) { + if ($this->getRecordService()->unlink($id, $link, $foreignId)) { $result = $result || true; } } diff --git a/application/Espo/Services/Attachment.php b/application/Espo/Services/Attachment.php index 0bdef87886..d0457608f3 100644 --- a/application/Espo/Services/Attachment.php +++ b/application/Espo/Services/Attachment.php @@ -65,7 +65,7 @@ class Attachment extends Record return $attachment; } - public function createEntity($data) + public function create($data) { if (!empty($data->file)) { $arr = explode(',', $data->file); @@ -127,7 +127,7 @@ class Attachment extends Record } } - $entity = parent::createEntity($data); + $entity = parent::create($data); if (!empty($data->file)) { $entity->clear('contents'); diff --git a/application/Espo/Services/Email.php b/application/Espo/Services/Email.php index 2acf23a4be..016deaf346 100644 --- a/application/Espo/Services/Email.php +++ b/application/Espo/Services/Email.php @@ -262,9 +262,9 @@ class Email extends Record return $this->streamService; } - public function createEntity($data) + public function create($data) { - $entity = parent::createEntity($data); + $entity = parent::create($data); if ($entity && $entity->get('status') == 'Sending') { $this->send($entity); diff --git a/application/Espo/Services/EmailAccount.php b/application/Espo/Services/EmailAccount.php index 1c6e91f94c..c1d70cfc3e 100644 --- a/application/Espo/Services/EmailAccount.php +++ b/application/Espo/Services/EmailAccount.php @@ -116,7 +116,7 @@ class EmailAccount extends Record throw new Error(); } - public function createEntity($data) + public function create($data) { if (!$this->getUser()->isAdmin()) { $count = $this->getEntityManager()->getRepository('EmailAccount')->where(array( @@ -127,7 +127,7 @@ class EmailAccount extends Record } } - $entity = parent::createEntity($data); + $entity = parent::create($data); if ($entity) { if (!$this->getUser()->isAdmin()) { $entity->set('assignedUserId', $this->getUser()->id); diff --git a/application/Espo/Services/InboundEmail.php b/application/Espo/Services/InboundEmail.php index c9d1d72089..a2ed498046 100644 --- a/application/Espo/Services/InboundEmail.php +++ b/application/Espo/Services/InboundEmail.php @@ -41,24 +41,6 @@ class InboundEmail extends \Espo\Services\Record const PORTION_LIMIT = 20; - public function createEntity($data) - { - $entity = parent::createEntity($data); - return $entity; - } - - public function getEntity($id = null) - { - $entity = parent::getEntity($id); - return $entity; - } - - public function updateEntity($id, $data) - { - $entity = parent::updateEntity($id, $data); - return $entity; - } - protected function init() { parent::init(); diff --git a/application/Espo/Services/Note.php b/application/Espo/Services/Note.php index f42a73ee04..1fc24279f2 100644 --- a/application/Espo/Services/Note.php +++ b/application/Espo/Services/Note.php @@ -48,7 +48,7 @@ class Note extends Record return $entity; } - public function createEntity($data) + public function create($data) { if (!empty($data->parentType) && !empty($data->parentId)) { $entity = $this->getEntityManager()->getEntity($data->parentType, $data->parentId); @@ -59,7 +59,7 @@ class Note extends Record } } - return parent::createEntity($data); + return parent::create($data); } protected function afterCreateEntity(Entity $entity, $data) @@ -197,20 +197,20 @@ class Note extends Record return true; } - public function linkEntity($id, $link, $foreignId) + public function link($id, $link, $foreignId) { if ($link === 'teams' || $link === 'users') { throw new Forbidden(); } - return parant::linkEntity($id, $link, $foreignId); + return parant::link($id, $link, $foreignId); } - public function unlinkEntity($id, $link, $foreignId) + public function unlink($id, $link, $foreignId) { if ($link === 'teams' || $link === 'users') { throw new Forbidden(); } - return parant::unlinkEntity($id, $link, $foreignId); + return parant::unlink($id, $link, $foreignId); } public function processNoteAclJob($data) diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index 8d47aea173..ba159253cc 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -261,7 +261,12 @@ class Record extends \Espo\Core\Services\Base $this->getEntityManager()->saveEntity($historyRecord); } - public function readEntity($id) + public function readEntity($id) //TODO Remove in 5.8 + { + return $this->read($id); + } + + public function read($id) { if (empty($id)) { throw new Error(); @@ -787,7 +792,7 @@ class Record extends \Espo\Core\Services\Base } } - public function createEntity($data) + public function createEntity($data) //TODO Remove in 5.8 { return $this->create($data); } @@ -845,7 +850,7 @@ class Record extends \Espo\Core\Services\Base throw new Error(); } - public function updateEntity($id, $data) + public function updateEntity($id, $data) //TODO Remove in 5.8 { return $this->update($id, $data); } @@ -944,7 +949,7 @@ class Record extends \Espo\Core\Services\Base { } - public function deleteEntity($id) + public function deleteEntity($id) //TODO Remove in 5.8 { return $this->delete($id); } @@ -1285,7 +1290,7 @@ class Record extends \Espo\Core\Services\Base ]; } - public function linkEntity($id, $link, $foreignId) + public function linkEntity($id, $link, $foreignId) //TODO Remove in 5.8 { return $this->link($id, $link, $foreignId); } @@ -1342,7 +1347,7 @@ class Record extends \Espo\Core\Services\Base return true; } - public function unlinkEntity($id, $link, $foreignId) + public function unlinkEntity($id, $link, $foreignId) //TODO Remove in 5.8 { return $this->unlink($id, $link, $foreignId); } @@ -1403,7 +1408,7 @@ class Record extends \Espo\Core\Services\Base return true; } - public function linkEntityMass($id, $link, $where, $selectData = null) + public function linkEntityMass($id, $link, $where, $selectData = null) //TODO Remove in 5.8 { return $this->linkMass($id, $link, $where, $selectData); } @@ -2238,7 +2243,7 @@ class Record extends \Espo\Core\Services\Base { } - protected function findLinkedEntitiesFollowers($id, $params) + protected function findLinkedFollowers($id, $params) { $maxSize = 0; diff --git a/application/Espo/Services/RecordTree.php b/application/Espo/Services/RecordTree.php index 5c7479a4c5..720142e3f9 100644 --- a/application/Espo/Services/RecordTree.php +++ b/application/Espo/Services/RecordTree.php @@ -174,21 +174,21 @@ class RecordTree extends Record } } - public function updateEntity($id, $data) + public function update($id, $data) { if (!empty($data->parentId) && $data->parentId == $id) { throw new Forbidden(); } - return parent::updateEntity($id, $data); + return parent::update($id, $data); } - public function linkEntity($id, $link, $foreignId) + public function link($id, $link, $foreignId) { if ($id == $foreignId ) { throw new Forbidden(); } - return parent::linkEntity($id, $link, $foreignId); + return parent::link($id, $link, $foreignId); } public function getLastChildrenIdList($parentId = null) diff --git a/application/Espo/Services/User.php b/application/Espo/Services/User.php index 6e29e3fcbc..1ece8f7c83 100644 --- a/application/Espo/Services/User.php +++ b/application/Espo/Services/User.php @@ -242,7 +242,7 @@ class User extends Record } } - public function createEntity($data) + public function create($data) { $newPassword = null; if (property_exists($data, 'password')) { @@ -250,7 +250,7 @@ class User extends Record $data->password = $this->hashPassword($data->password); } - $user = parent::createEntity($data); + $user = parent::create($data); if (!is_null($newPassword) && !empty($data->sendAccessInfo)) { if ($user->isActive()) { @@ -263,7 +263,7 @@ class User extends Record return $user; } - public function updateEntity($id, $data) + public function update($id, $data) { if ($id == 'system') { throw new Forbidden(); @@ -280,7 +280,7 @@ class User extends Record unset($data->type); } - $user = parent::updateEntity($id, $data); + $user = parent::update($id, $data); if (!is_null($newPassword)) { try { @@ -576,7 +576,7 @@ class User extends Record $this->getMailSender()->send($email); } - public function deleteEntity($id) + public function delete($id) { if ($id == 'system') { throw new Forbidden(); @@ -584,7 +584,7 @@ class User extends Record if ($id == $this->getUser()->id) { throw new Forbidden(); } - return parent::deleteEntity($id); + return parent::delete($id); } protected function checkEntityForMassRemove(Entity $entity)