mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-27 22:46:04 +00:00
dev
This commit is contained in:
8
application/Espo/Controllers/Attachment.php
Normal file
8
application/Espo/Controllers/Attachment.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
class Attachment extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
@@ -158,7 +158,6 @@ abstract class Record extends Base
|
||||
|
||||
$ids = $request->get('ids');
|
||||
$where = $request->get('where');
|
||||
|
||||
|
||||
if (!empty($ids)) {
|
||||
$where = array(
|
||||
|
||||
@@ -25,7 +25,6 @@ class HookManager
|
||||
'afterSave',
|
||||
);
|
||||
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
@@ -42,7 +41,6 @@ class HookManager
|
||||
return $this->container->get('fileManager');
|
||||
}
|
||||
|
||||
|
||||
protected function loadHooks()
|
||||
{
|
||||
if ($this->getConfig()->get('useCache') && file_exists($this->cacheFile)) {
|
||||
@@ -82,7 +80,7 @@ class HookManager
|
||||
{
|
||||
if (class_exists($className)) {
|
||||
$hook = new $className();
|
||||
$dependencies = $hook::$dependencies;
|
||||
$dependencies = $hook->getDependencyList();
|
||||
foreach ($dependencies as $name) {
|
||||
$hook->inject($name, $this->container->get($name));
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace Espo\Core\Hooks;
|
||||
|
||||
class Base
|
||||
use \Espo\Core\Interfaces\Injectable;
|
||||
|
||||
class Base implements Injectable
|
||||
{
|
||||
static public $dependencies = array();
|
||||
protected $dependencies = array();
|
||||
|
||||
protected $injections = array(
|
||||
'entityManager',
|
||||
@@ -14,13 +16,32 @@ class Base
|
||||
'user',
|
||||
);
|
||||
|
||||
public static $order = 9;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
{
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
{
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
public function inject($name, $object)
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
public static $order = 9;
|
||||
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->injections['entityManager'];
|
||||
|
||||
11
application/Espo/Core/Interfaces/Injectable.php
Normal file
11
application/Espo/Core/Interfaces/Injectable.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Core\Interfaces;
|
||||
|
||||
interface Injectable
|
||||
{
|
||||
public function getDependencyList();
|
||||
|
||||
public function inject($name, $object);
|
||||
}
|
||||
|
||||
@@ -137,16 +137,17 @@ class Repository extends \Espo\ORM\Repository
|
||||
$emailAddressOld = $emailAddressRepository->where(array('lower' => strtolower($emailOld)))->findOne();
|
||||
$this->unrelate($entity, 'emailAddresses', $emailAddressOld);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleSpecifiedRelations(Entity $entity)
|
||||
{
|
||||
foreach ($entity->getRelations() as $name => $defs) {
|
||||
if ($defs['type'] == $entity::HAS_MANY || $defs['type'] == $entity::MANY_MANY) {
|
||||
$relationTypes = array($entity::HAS_MANY, $entity::MANY_MANY, $entity::HAS_CHILDREN);
|
||||
foreach ($entity->getRelations() as $name => $defs) {
|
||||
if (in_array($defs['type'], $relationTypes)) {
|
||||
$fieldName = $name . 'Ids';
|
||||
if ($entity->has($fieldName)) {
|
||||
if ($entity->has($fieldName)) {
|
||||
$specifiedIds = $entity->get($fieldName);
|
||||
if (is_array($specifiedIds)) {
|
||||
$toRemoveIds = array();
|
||||
@@ -172,5 +173,6 @@ class Repository extends \Espo\ORM\Repository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class ServiceFactory
|
||||
{
|
||||
if (class_exists($className)) {
|
||||
$service = new $className();
|
||||
$dependencies = $service::$dependencies;
|
||||
$dependencies = $service->getDependencyList();
|
||||
foreach ($dependencies as $name) {
|
||||
$service->inject($name, $this->container->get($name));
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace Espo\Core\Services;
|
||||
|
||||
abstract class Base
|
||||
use \Espo\Core\Interfaces\Injectable;
|
||||
|
||||
abstract class Base implements Injectable
|
||||
{
|
||||
static public $dependencies = array();
|
||||
protected $dependencies = array();
|
||||
|
||||
protected $injections = array();
|
||||
|
||||
@@ -12,5 +14,24 @@ abstract class Base
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
{
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
{
|
||||
return $this->dependencies;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use \PDO;
|
||||
|
||||
class Activities extends \Espo\Core\Services\Base
|
||||
{
|
||||
static public $dependencies = array(
|
||||
protected $dependencies = array(
|
||||
'entityManager',
|
||||
'user',
|
||||
'metadata',
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
"type": "int",
|
||||
"min": 0
|
||||
},
|
||||
"extension": {
|
||||
"type": "varchar",
|
||||
"maxLength": 10
|
||||
},
|
||||
"parent": {
|
||||
"type": "linkParent"
|
||||
},
|
||||
@@ -23,17 +19,9 @@
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
},
|
||||
"modifiedAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
},
|
||||
"createdBy": {
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
},
|
||||
"modifiedBy": {
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
@@ -41,10 +29,6 @@
|
||||
"type": "belongsTo",
|
||||
"entity": "User"
|
||||
},
|
||||
"modifiedBy": {
|
||||
"type": "belongsTo",
|
||||
"entity": "User"
|
||||
},
|
||||
"parent": {
|
||||
"type": "belongsToParent",
|
||||
"foreign": "attachments"
|
||||
|
||||
30
application/Espo/Services/Attachment.php
Normal file
30
application/Espo/Services/Attachment.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Services;
|
||||
|
||||
class Attachment extends Record
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->dependencies[] = 'fileManager';
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->getInjection('fileManager');
|
||||
}
|
||||
|
||||
public function createEntity($data)
|
||||
{
|
||||
$entity = parent::createEntity($data);
|
||||
|
||||
list($prefix, $contents) = explode(',', $data['file']);
|
||||
|
||||
if (!empty($entity->id)) {
|
||||
$this->getFileManager()->setContent(base64_decode($contents), 'data/upload/' . $entity->id);
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use \Espo\Core\Utils\Util;
|
||||
|
||||
class Record extends \Espo\Core\Services\Base
|
||||
{
|
||||
static public $dependencies = array(
|
||||
protected $dependencies = array(
|
||||
'entityManager',
|
||||
'user',
|
||||
'metadata',
|
||||
@@ -147,6 +147,11 @@ class Record extends \Espo\Core\Services\Base
|
||||
|
||||
return $selectManager;
|
||||
}
|
||||
|
||||
protected function storeEntity(Entity $entity)
|
||||
{
|
||||
return $this->getRepository()->save($entity);
|
||||
}
|
||||
|
||||
public function createEntity($data)
|
||||
{
|
||||
@@ -155,7 +160,7 @@ class Record extends \Espo\Core\Services\Base
|
||||
|
||||
$entity->set($data);
|
||||
|
||||
if ($this->getRepository()->save($entity)) {
|
||||
if ($this->storeEntity($entity)) {
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@@ -173,8 +178,11 @@ class Record extends \Espo\Core\Services\Base
|
||||
|
||||
$entity->set($data);
|
||||
|
||||
$this->getRepository()->save($entity);
|
||||
return $entity;
|
||||
if ($this->storeEntity($entity)) {
|
||||
return $entity;
|
||||
}
|
||||
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
public function deleteEntity($id)
|
||||
|
||||
@@ -7,7 +7,7 @@ use \Espo\Core\Exceptions\NotFound;
|
||||
|
||||
class Stream extends \Espo\Core\Services\Base
|
||||
{
|
||||
static public $dependencies = array(
|
||||
protected $dependencies = array(
|
||||
'entityManager',
|
||||
'user',
|
||||
'metadata',
|
||||
|
||||
9
data/upload/52d7f79f200b8
Normal file
9
data/upload/52d7f79f200b8
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
19
data/upload/52d7f7a1b3927
Normal file
19
data/upload/52d7f7a1b3927
Normal file
@@ -0,0 +1,19 @@
|
||||
git remote add upstream git@github.com:sugarcrm/Mango.git
|
||||
git checkout -t -b caramel upstream/caramel
|
||||
git checkout -b caramel
|
||||
|
||||
git fetch upstream
|
||||
git checkout caramel
|
||||
git merge upstream/caramel
|
||||
|
||||
git add --all
|
||||
git commit -m 'comment'
|
||||
git push origin caramel
|
||||
|
||||
|
||||
git push -f origin HEAD^:master // remove last push from remote
|
||||
git reset --soft HEAD^
|
||||
|
||||
git stash
|
||||
git stash apply
|
||||
git stash drop
|
||||
9
data/upload/52d7f7de5e7fa
Normal file
9
data/upload/52d7f7de5e7fa
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
19
data/upload/52d7f7e06a2e8
Normal file
19
data/upload/52d7f7e06a2e8
Normal file
@@ -0,0 +1,19 @@
|
||||
git remote add upstream git@github.com:sugarcrm/Mango.git
|
||||
git checkout -t -b caramel upstream/caramel
|
||||
git checkout -b caramel
|
||||
|
||||
git fetch upstream
|
||||
git checkout caramel
|
||||
git merge upstream/caramel
|
||||
|
||||
git add --all
|
||||
git commit -m 'comment'
|
||||
git push origin caramel
|
||||
|
||||
|
||||
git push -f origin HEAD^:master // remove last push from remote
|
||||
git reset --soft HEAD^
|
||||
|
||||
git stash
|
||||
git stash apply
|
||||
git stash drop
|
||||
9
data/upload/52d7f80cbeeaf
Normal file
9
data/upload/52d7f80cbeeaf
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
19
data/upload/52d7f80f8878f
Normal file
19
data/upload/52d7f80f8878f
Normal file
@@ -0,0 +1,19 @@
|
||||
git remote add upstream git@github.com:sugarcrm/Mango.git
|
||||
git checkout -t -b caramel upstream/caramel
|
||||
git checkout -b caramel
|
||||
|
||||
git fetch upstream
|
||||
git checkout caramel
|
||||
git merge upstream/caramel
|
||||
|
||||
git add --all
|
||||
git commit -m 'comment'
|
||||
git push origin caramel
|
||||
|
||||
|
||||
git push -f origin HEAD^:master // remove last push from remote
|
||||
git reset --soft HEAD^
|
||||
|
||||
git stash
|
||||
git stash apply
|
||||
git stash drop
|
||||
9
data/upload/52d7f9c5e00de
Normal file
9
data/upload/52d7f9c5e00de
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
19
data/upload/52d7f9c7cacc9
Normal file
19
data/upload/52d7f9c7cacc9
Normal file
@@ -0,0 +1,19 @@
|
||||
git remote add upstream git@github.com:sugarcrm/Mango.git
|
||||
git checkout -t -b caramel upstream/caramel
|
||||
git checkout -b caramel
|
||||
|
||||
git fetch upstream
|
||||
git checkout caramel
|
||||
git merge upstream/caramel
|
||||
|
||||
git add --all
|
||||
git commit -m 'comment'
|
||||
git push origin caramel
|
||||
|
||||
|
||||
git push -f origin HEAD^:master // remove last push from remote
|
||||
git reset --soft HEAD^
|
||||
|
||||
git stash
|
||||
git stash apply
|
||||
git stash drop
|
||||
9
data/upload/52d7fa8f1256f
Normal file
9
data/upload/52d7fa8f1256f
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
19
data/upload/52d7fa90cf95c
Normal file
19
data/upload/52d7fa90cf95c
Normal file
@@ -0,0 +1,19 @@
|
||||
git remote add upstream git@github.com:sugarcrm/Mango.git
|
||||
git checkout -t -b caramel upstream/caramel
|
||||
git checkout -b caramel
|
||||
|
||||
git fetch upstream
|
||||
git checkout caramel
|
||||
git merge upstream/caramel
|
||||
|
||||
git add --all
|
||||
git commit -m 'comment'
|
||||
git push origin caramel
|
||||
|
||||
|
||||
git push -f origin HEAD^:master // remove last push from remote
|
||||
git reset --soft HEAD^
|
||||
|
||||
git stash
|
||||
git stash apply
|
||||
git stash drop
|
||||
9
data/upload/52d8007335b05
Normal file
9
data/upload/52d8007335b05
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
9
data/upload/52d80204bad7a
Normal file
9
data/upload/52d80204bad7a
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
9
data/upload/52d803585a5f5
Normal file
9
data/upload/52d803585a5f5
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
19
data/upload/52d8039b1fc34
Normal file
19
data/upload/52d8039b1fc34
Normal file
@@ -0,0 +1,19 @@
|
||||
git remote add upstream git@github.com:sugarcrm/Mango.git
|
||||
git checkout -t -b caramel upstream/caramel
|
||||
git checkout -b caramel
|
||||
|
||||
git fetch upstream
|
||||
git checkout caramel
|
||||
git merge upstream/caramel
|
||||
|
||||
git add --all
|
||||
git commit -m 'comment'
|
||||
git push origin caramel
|
||||
|
||||
|
||||
git push -f origin HEAD^:master // remove last push from remote
|
||||
git reset --soft HEAD^
|
||||
|
||||
git stash
|
||||
git stash apply
|
||||
git stash drop
|
||||
9
data/upload/52d8039dd386a
Normal file
9
data/upload/52d8039dd386a
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
38
data/upload/52d803a610aad
Normal file
38
data/upload/52d803a610aad
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
class cacheExampe
|
||||
{
|
||||
private $espoMetadata;
|
||||
|
||||
public function getOrmMetadata()
|
||||
{
|
||||
if (!empty($this->espoMetadata)) {
|
||||
return $this->espoMetadata;
|
||||
}
|
||||
|
||||
$espoMetadataFile = Util::concatPath($this->getConfig()->get('cachePath'), 'ormMetadata.php');
|
||||
|
||||
if (!file_exists($espoMetadataFile) || !$this->getConfig()->get('useCache')) {
|
||||
$this->getConverter()->process();
|
||||
}
|
||||
|
||||
$this->espoMetadata = $this->getFileManager()->getContent($espoMetadataFile);
|
||||
|
||||
return $this->espoMetadata;
|
||||
}
|
||||
|
||||
public function setOrmMetadata(array $espoMetadata)
|
||||
{
|
||||
$result = $this->getFileManager()->setContentPHP($espoMetadata, $this->getConfig()->get('cachePath'), 'ormMetadata.php');
|
||||
if ($result == false) {
|
||||
$GLOBALS['log']->add('EXCEPTION', 'Metadata::setOrmMetadata() - Cannot save ormMetadata to a file');
|
||||
throw new \Espo\Core\Exceptions\Error();
|
||||
}
|
||||
|
||||
$this->espoMetadata = $espoMetadata;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
9
data/upload/52d804b39c181
Normal file
9
data/upload/52d804b39c181
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Link
|
||||
Icon[en_US]=gnome-panel-launcher
|
||||
URL=/var/www
|
||||
Name[en_US]=www
|
||||
Name=www
|
||||
Icon=gnome-panel-launcher
|
||||
19
data/upload/52d804b6726e6
Normal file
19
data/upload/52d804b6726e6
Normal file
@@ -0,0 +1,19 @@
|
||||
git remote add upstream git@github.com:sugarcrm/Mango.git
|
||||
git checkout -t -b caramel upstream/caramel
|
||||
git checkout -b caramel
|
||||
|
||||
git fetch upstream
|
||||
git checkout caramel
|
||||
git merge upstream/caramel
|
||||
|
||||
git add --all
|
||||
git commit -m 'comment'
|
||||
git push origin caramel
|
||||
|
||||
|
||||
git push -f origin HEAD^:master // remove last push from remote
|
||||
git reset --soft HEAD^
|
||||
|
||||
git stash
|
||||
git stash apply
|
||||
git stash drop
|
||||
BIN
data/upload/52d804bab19d4
Normal file
BIN
data/upload/52d804bab19d4
Normal file
Binary file not shown.
Reference in New Issue
Block a user