add getEntityType into entity
This commit is contained in:
@@ -81,6 +81,7 @@ class EntityManager
|
||||
"namespace Espo\Custom\Entities;\n".
|
||||
"class {$normalizedName} extends \Espo\Core\Templates\Entities\\{$type}\n".
|
||||
"{\n".
|
||||
" protected \$entityType = \"$name\";\n".
|
||||
"}\n";
|
||||
|
||||
$filePath = "custom/Espo/Custom/Entities/{$normalizedName}.php";
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class CaseObj extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
protected $entityName = 'Case';
|
||||
protected $entityType = 'Case';
|
||||
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ abstract class Entity implements IEntity
|
||||
private $isSaved = false;
|
||||
|
||||
/**
|
||||
* Entity name (entity type).
|
||||
* Entity type.
|
||||
* @var string
|
||||
*/
|
||||
protected $entityName;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* @var array Defenition of fields.
|
||||
@@ -67,9 +67,9 @@ abstract class Entity implements IEntity
|
||||
|
||||
public function __construct($defs = array(), EntityManager $entityManager = null)
|
||||
{
|
||||
if (empty($this->entityName)) {
|
||||
if (empty($this->entityType)) {
|
||||
$classNames = explode('\\', get_class($this));
|
||||
$this->entityName = end($classNames);
|
||||
$this->entityType = end($classNames);
|
||||
}
|
||||
|
||||
$this->entityManager = $entityManager;
|
||||
@@ -140,7 +140,7 @@ abstract class Entity implements IEntity
|
||||
}
|
||||
|
||||
if (!empty($this->relations[$name])) {
|
||||
$value = $this->entityManager->getRepository($this->entityName)->findRelated($this, $name, $params);
|
||||
$value = $this->entityManager->getRepository($this->getEntityType())->findRelated($this, $name, $params);
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,12 @@ abstract class Entity implements IEntity
|
||||
|
||||
public function getEntityName()
|
||||
{
|
||||
return $this->entityName;
|
||||
return $this->getEntityType();
|
||||
}
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
public function hasField($fieldName)
|
||||
|
||||
Reference in New Issue
Block a user