get scope map from Metadata/scopes
This commit is contained in:
@@ -3,3 +3,9 @@ data/cache/*
|
||||
application/config.php
|
||||
/test.php
|
||||
/test2.php
|
||||
application/Espo/Metadata/scopes/CustomTest.json
|
||||
application/Espo/Metadata/customTest/*
|
||||
application/Espo/Layouts/customTest/*
|
||||
application/Modules/Crm/Metadata/customTest/*
|
||||
application/Modules/Crm/Layouts/customTest/*
|
||||
|
||||
|
||||
@@ -9,10 +9,9 @@ class Metadata extends Utils\Controllers\Controller
|
||||
|
||||
public function read($params, $data)
|
||||
{
|
||||
$metadata= new Utils\Metadata();
|
||||
$devMode= !$metadata->getObject('Configurator')->get('useCache');
|
||||
$metadata= new Utils\Metadata();
|
||||
|
||||
$data= $metadata->getMetadata(true, $devMode);
|
||||
$data= $metadata->getMetadata(true);
|
||||
|
||||
return array($data, 'Cannot reach metadata data');
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class BaseUtils
|
||||
/**
|
||||
* @var array - scope list
|
||||
*/
|
||||
protected $scopes= array();
|
||||
public $scopes= array();
|
||||
|
||||
|
||||
/**
|
||||
@@ -80,33 +80,15 @@ class BaseUtils
|
||||
return $this->scopes;
|
||||
}
|
||||
|
||||
$metadata = new Utils\Metadata();
|
||||
$metadataList = $metadata->getMetadataOnly(false);
|
||||
|
||||
$this->scopes = array(
|
||||
'customTest' => '',
|
||||
'Attachment' => '',
|
||||
'Comment' => '',
|
||||
'Attachment' => '',
|
||||
'EmailTemplate' => '',
|
||||
'Role' => '',
|
||||
'Team' => '',
|
||||
'User' => '',
|
||||
'Product' => 'Crm',
|
||||
'Account' => 'Crm',
|
||||
'Contact' => 'Crm',
|
||||
'Lead' => 'Crm',
|
||||
'Opportunity' => 'Crm',
|
||||
'Calendar' => 'Crm',
|
||||
'Meeting' => 'Crm',
|
||||
'Call' => 'Crm',
|
||||
'Task' => 'Crm',
|
||||
'Case' => 'Crm',
|
||||
'Prospect' => 'Crm',
|
||||
'Email' => 'Crm',
|
||||
'emailTemplate' => 'Crm',
|
||||
'inboundEmail' => 'Crm',
|
||||
);
|
||||
$scopes = array();
|
||||
foreach($metadataList['scopes'] as $name => $details) {
|
||||
$scopes[$name] = isset($details['module']) ? $details['module'] : '';
|
||||
}
|
||||
|
||||
return $this->scopes;
|
||||
return $this->scopes = $scopes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ class FileManager extends BaseUtils
|
||||
* @param string $configParams - ["name", "cachePath", "corePath", "customPath"]
|
||||
* @param bool $recursively - Note: only for first level of sub directory, other levels of sub directories will be ignored
|
||||
*
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
public function uniteFiles($configParams, $recursively=false)
|
||||
{
|
||||
|
||||
@@ -17,22 +17,30 @@ class Metadata extends FileManager
|
||||
* Get Metadata context
|
||||
*
|
||||
* @param $isJSON
|
||||
* @param bool $reload
|
||||
*
|
||||
* @return json | array
|
||||
*/
|
||||
//HERE --- ADD CREATING DOCTRINE METADATA
|
||||
function getMetadata($isJSON=true, $reload=false)
|
||||
public function getMetadata($isJSON=true, $reload=false)
|
||||
{
|
||||
$config= $this->getConfig();
|
||||
|
||||
if (!file_exists($config->cacheFile) || $reload) {
|
||||
$result= $this->uniteFiles($config, true);
|
||||
if (!$this->getObject('Configurator')->get('useCache')) {
|
||||
$reload = true;
|
||||
}
|
||||
|
||||
if ($result===false) {
|
||||
$this->getObject('Log')->add('FATAL', 'Metadata:getMetadata() - metadata unite file cannot be created');
|
||||
if (!file_exists($config->cacheFile) || $reload) {
|
||||
$data= $this->getMetadataOnly(false, true);
|
||||
if ($data === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//save medatada to cache files
|
||||
$this->setContentPHP($data, $this->getConfig()->cacheFile);
|
||||
|
||||
$this->getObject('Log')->add('Debug', 'Metadata:getMetadata() - converting to doctrine metadata');
|
||||
if ($this->convertToDoctrine($this->getContent($config->cacheFile))) {
|
||||
if ($this->convertToDoctrine($data)) {
|
||||
$this->getObject('Log')->add('Debug', 'Metadata:getMetadata() - database rebuild');
|
||||
|
||||
try{
|
||||
@@ -43,19 +51,49 @@ class Metadata extends FileManager
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($config->cacheFile)) {
|
||||
$data= $this->getContent($config->cacheFile);
|
||||
if ($isJSON) {
|
||||
$data= $this->getObject('JSON')->encode($data);
|
||||
}
|
||||
return $this->getMetadataOnly($isJSON, false);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
|
||||
/**
|
||||
* Get Metadata only without saving it to the a file and database sync
|
||||
*
|
||||
* @param $isJSON
|
||||
* @param bool $reload
|
||||
*
|
||||
* @return json | array
|
||||
*/
|
||||
|
||||
public function getMetadataOnly($isJSON=true, $reload=false)
|
||||
{
|
||||
$config= $this->getConfig();
|
||||
|
||||
if (!$this->getObject('Configurator')->get('useCache')) {
|
||||
$reload = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
$data = false;
|
||||
if (!file_exists($config->cacheFile) || $reload) {
|
||||
$data= $this->uniteFiles($config, true);
|
||||
|
||||
if ($data === false) {
|
||||
$this->getObject('Log')->add('FATAL', 'Metadata:getMetadata() - metadata unite file cannot be created');
|
||||
}
|
||||
}
|
||||
else if (file_exists($config->cacheFile)) {
|
||||
$data= $this->getContent($config->cacheFile);
|
||||
}
|
||||
|
||||
if ($isJSON) {
|
||||
$data= $this->getObject('JSON')->encode($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set Metadata data
|
||||
* Ex. $type= menu, $scope= Account then will be created a file metadataFolder/menu/Account.json
|
||||
@@ -199,7 +237,7 @@ class Metadata extends FileManager
|
||||
* @param string $configParams - ["name", "cachePath", "corePath", "customPath"]
|
||||
* @param bool $recursively - Note: only for first level of sub directory, other levels of sub directories will be ignored
|
||||
*
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
function uniteFiles($configParams, $recursively=false)
|
||||
{
|
||||
@@ -217,16 +255,11 @@ class Metadata extends FileManager
|
||||
foreach($dirList as $dirName) {
|
||||
$curPath= str_replace('{*}', $dirName, $configParams->customPath);
|
||||
$content= $this->merge($content, $this->uniteFilesSingle($curPath, $configParams->name, $recursively, $dirName));
|
||||
|
||||
//print_r($content );
|
||||
}
|
||||
}
|
||||
|
||||
//END: merge matadata files
|
||||
|
||||
//save medatada to cache files
|
||||
return $this->setContentPHP($content, $this->getConfig()->cacheFile);
|
||||
//END: save medatada to cache files
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user