mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-29 15:36:07 +00:00
dev
This commit is contained in:
@@ -36,26 +36,25 @@ class ControllerManager
|
||||
|
||||
public function process($controllerName, $actionName, $params, $data)
|
||||
{
|
||||
$customeClassName = '\\Espo\\Custom\\Controllers\\' . $controllerName;
|
||||
$customeClassName = '\\Espo\\Custom\\Controllers\\' . Util::normilizeClassName($controllerName);
|
||||
if (class_exists($customeClassName)) {
|
||||
$controllerClassName = $customeClassName;
|
||||
} else {
|
||||
$moduleName = $this->metadata->getScopeModuleName($controllerName);
|
||||
if ($moduleName) {
|
||||
$controllerClassName = '\\Espo\\Modules\\' . $moduleName . '\\Controllers\\' . $controllerName;
|
||||
$controllerClassName = '\\Espo\\Modules\\' . $moduleName . '\\Controllers\\' . Util::normilizeClassName($controllerName);
|
||||
} else {
|
||||
$controllerClassName = '\\Espo\\Controllers\\' . $controllerName;
|
||||
$controllerClassName = '\\Espo\\Controllers\\' . Util::normilizeClassName($controllerName);
|
||||
}
|
||||
}
|
||||
|
||||
if ($data) {
|
||||
$data = json_decode($data, true);
|
||||
}
|
||||
|
||||
|
||||
if (!class_exists($controllerClassName)) {
|
||||
throw new NotFound("Controller '$controllerName' is not found");
|
||||
}
|
||||
}
|
||||
|
||||
$controller = new $controllerClassName($this->container, $this->serviceFactory);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Espo\Core\Controllers;
|
||||
|
||||
use \Espo\Core\Container;
|
||||
use \Espo\Core\ServiceFactory;
|
||||
use \Espo\Core\Utils\Util;
|
||||
|
||||
abstract class Base
|
||||
{
|
||||
@@ -24,18 +25,20 @@ abstract class Base
|
||||
$this->container = $container;
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
|
||||
$name = get_class($this);
|
||||
if (preg_match('@\\\\([\w]+)$@', $name, $matches)) {
|
||||
$name = $matches[1];
|
||||
}
|
||||
$this->name = $name;
|
||||
if (empty($this->name)) {
|
||||
$name = get_class($this);
|
||||
if (preg_match('@\\\\([\w]+)$@', $name, $matches)) {
|
||||
$name = $matches[1];
|
||||
}
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
if (empty($this->serviceClassName)) {
|
||||
$moduleName = $this->getMetadata()->getScopeModuleName($this->name);
|
||||
if ($moduleName) {
|
||||
$className = '\\Espo\\Modules\\' . $moduleName . '\\Services\\' . $this->name;
|
||||
$className = '\\Espo\\Modules\\' . $moduleName . '\\Services\\' . Util::normilizeClassName($this->name);
|
||||
} else {
|
||||
$className = '\\Espo\\Services\\' . $this->name;
|
||||
$className = '\\Espo\\Services\\' . Util::normilizeClassName($this->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Core\ORM;
|
||||
use \Espo\Core\Utils\Util;
|
||||
|
||||
class EntityManager extends \Espo\ORM\EntityManager
|
||||
{
|
||||
@@ -24,7 +25,7 @@ class EntityManager extends \Espo\ORM\EntityManager
|
||||
}
|
||||
|
||||
public function normalizeRepositoryName($name)
|
||||
{
|
||||
{
|
||||
return $this->espoMetadata->getRepositoryPath($name);
|
||||
}
|
||||
|
||||
|
||||
@@ -269,18 +269,18 @@ class Metadata
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEntityPath($entityName, $delim= '\\')
|
||||
public function getEntityPath($entityName, $delim = '\\')
|
||||
{
|
||||
$path = $this->getScopePath($entityName, $delim);
|
||||
|
||||
return implode($delim, array($path, 'Entities', ucfirst($entityName)));
|
||||
return implode($delim, array($path, 'Entities', Util::normilizeClassName(ucfirst($entityName))));
|
||||
}
|
||||
|
||||
public function getRepositoryPath($entityName, $delim= '\\')
|
||||
public function getRepositoryPath($entityName, $delim = '\\')
|
||||
{
|
||||
$path = $this->getScopePath($entityName, $delim);
|
||||
|
||||
return implode($delim, array($path, 'Repositories', ucfirst($entityName)));
|
||||
return implode($delim, array($path, 'Repositories', Util::normilizeClassName(ucfirst($entityName))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,16 +6,18 @@ namespace Espo\Core\Utils;
|
||||
class Util
|
||||
{
|
||||
/**
|
||||
* @var string - default directory separator
|
||||
*/
|
||||
protected static $separator= DIRECTORY_SEPARATOR;
|
||||
* @var string - default directory separator
|
||||
*/
|
||||
protected static $separator = DIRECTORY_SEPARATOR;
|
||||
|
||||
protected static $reservedWords = array('Case');
|
||||
|
||||
|
||||
/**
|
||||
* Get a folder separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* Get a folder separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSeparator()
|
||||
{
|
||||
return static::$separator;
|
||||
@@ -23,15 +25,15 @@ class Util
|
||||
|
||||
|
||||
/**
|
||||
* Convert to format with defined delimeter
|
||||
* ex. Espo/Utils to Espo\Utils
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $delim - delimiter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toFormat($name, $delim= '/')
|
||||
* Convert to format with defined delimeter
|
||||
* ex. Espo/Utils to Espo\Utils
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $delim - delimiter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toFormat($name, $delim = '/')
|
||||
{
|
||||
//preg_match_all('/[\/]/', $name, $match);
|
||||
//preg_match_all('/(.*)[\/\\\](.*)/', $name, $match);
|
||||
@@ -169,11 +171,11 @@ class Util
|
||||
|
||||
|
||||
/**
|
||||
* Convert array to object format recursively
|
||||
*
|
||||
* @param array $array
|
||||
* @return object
|
||||
*/
|
||||
* Convert array to object format recursively
|
||||
*
|
||||
* @param array $array
|
||||
* @return object
|
||||
*/
|
||||
public static function arrayToObject($array)
|
||||
{
|
||||
if (is_array($array)) {
|
||||
@@ -185,11 +187,11 @@ class Util
|
||||
|
||||
|
||||
/**
|
||||
* Convert object to array format recursively
|
||||
*
|
||||
* @param object $object
|
||||
* @return array
|
||||
*/
|
||||
* Convert object to array format recursively
|
||||
*
|
||||
* @param object $object
|
||||
* @return array
|
||||
*/
|
||||
public static function objectToArray($object)
|
||||
{
|
||||
if (is_object($object)) {
|
||||
@@ -198,6 +200,20 @@ class Util
|
||||
|
||||
return is_array($object) ? array_map("static::objectToArray", $object) : $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends 'Obj' if name is reserved PHP word.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function normilizeClassName($name)
|
||||
{
|
||||
if (in_array($name, self::$reservedWords)) {
|
||||
$name .= 'Obj';
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -254,4 +270,4 @@ class Util
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
8
application/Espo/Modules/Crm/Controllers/Call.php
Normal file
8
application/Espo/Modules/Crm/Controllers/Call.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Call extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
9
application/Espo/Modules/Crm/Controllers/CaseObj.php
Normal file
9
application/Espo/Modules/Crm/Controllers/CaseObj.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class CaseObj extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
protected $name = 'Case';
|
||||
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Controllers/Lead.php
Normal file
8
application/Espo/Modules/Crm/Controllers/Lead.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Lead extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Controllers/Meeting.php
Normal file
8
application/Espo/Modules/Crm/Controllers/Meeting.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Meeting extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Controllers/Opportunity.php
Normal file
8
application/Espo/Modules/Crm/Controllers/Opportunity.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Opportunity extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Controllers/Prospect.php
Normal file
8
application/Espo/Modules/Crm/Controllers/Prospect.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Prospect extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Controllers/Task.php
Normal file
8
application/Espo/Modules/Crm/Controllers/Task.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Task extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Entities/Call.php
Normal file
8
application/Espo/Modules/Crm/Entities/Call.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class Call extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
10
application/Espo/Modules/Crm/Entities/CaseObj.php
Normal file
10
application/Espo/Modules/Crm/Entities/CaseObj.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class CaseObj extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
protected $entityName = 'Case';
|
||||
|
||||
}
|
||||
11
application/Espo/Modules/Crm/Entities/Lead.php
Normal file
11
application/Espo/Modules/Crm/Entities/Lead.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class Lead extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
protected function getName()
|
||||
{
|
||||
return $this->get('firstName') . ' ' . $this->get('lastName');
|
||||
}
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Entities/Meeting.php
Normal file
8
application/Espo/Modules/Crm/Entities/Meeting.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class Meeting extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Entities/Opportunity.php
Normal file
8
application/Espo/Modules/Crm/Entities/Opportunity.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class Opportunity extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
11
application/Espo/Modules/Crm/Entities/Prospect.php
Normal file
11
application/Espo/Modules/Crm/Entities/Prospect.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class Prospect extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
protected function getName()
|
||||
{
|
||||
return $this->get('firstName') . ' ' . $this->get('lastName');
|
||||
}
|
||||
}
|
||||
8
application/Espo/Modules/Crm/Entities/Task.php
Normal file
8
application/Espo/Modules/Crm/Entities/Task.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class Task extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
@@ -937,8 +937,15 @@ abstract class Mapper implements IMapper
|
||||
$join =
|
||||
"JOIN {$relTable} ON {$this->toDb($entity->getEntityName())}." . $this->toDb($key) . " = {$relTable}." . $this->toDb($nearKey)
|
||||
. " AND "
|
||||
. "{$relTable}.deleted = " . $this->pdo->quote(0) . " "
|
||||
. "JOIN {$distantTable} ON {$distantTable}." . $this->toDb($foreignKey) . " = {$relTable}." . $this->toDb($distantKey)
|
||||
. "{$relTable}.deleted = " . $this->pdo->quote(0);
|
||||
|
||||
if (!empty($relOpt['conditions']) && is_array($relOpt['conditions'])) {
|
||||
foreach ($relOpt['conditions'] as $f => $v) {
|
||||
$join .= " AND {$relTable}." . $this->toDb($f) . " = " . $this->pdo->quote($v);
|
||||
}
|
||||
}
|
||||
|
||||
$join .= " JOIN {$distantTable} ON {$distantTable}." . $this->toDb($foreignKey) . " = {$relTable}." . $this->toDb($distantKey)
|
||||
. " AND "
|
||||
. "{$distantTable}.deleted = " . $this->pdo->quote(0) . "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user