Picture of Jorge Castrillo
Re: Error: Already found extension article attribute with key ...
by Jorge Castrillo - Thursday, 13 December 2018, 7:53 PM
 

Can someone explain to me exactly what this function does and why my error originates?

I changed this part of the code...

if(typeObj[key] &&_.intersection(Object.keys(typeObj[key]), keys).length>0) {
returneachCallback(newError(`Already found ${pluginType}${key} attribute with key ${keys[0]} (${schema.name})`));
} elseif(!typeObj) {
memo.contentModelData[pluginType] =typeObj= {};
}
 
.. because of this and my AT seems to work normally, however, it is not clear to me if what I am doing is fine ...
 
 if(!typeObj) {
memo.contentModelData[pluginType] =typeObj= {};
}
 
Someone help me please
 
function processPluginLocations(pPluginType, schema, memo, callback) {
varpluginType=pPluginType.type;
try {
varschemaPluginLocations=schema.properties.pluginLocations.properties;
} catch(e) { // handle undefined pluginLocations
if(!_.isEmpty(schema.properties)) { // in case we have an empty pluginLocations
deleteschema.properties.pluginLocations;
memo.schemas[schema[pluginType]] =schema;
}
returncallback();
}
async.each(Object.keys(schemaPluginLocations), function(key, eachCallback) {
varprops=schemaPluginLocations[key].properties;
if (!props) {
returneachCallback();
}
varkeys=Object.keys(props);
// NOTE we need a single top-level object
if(keys.length>1) {
returneachCallback(newError(`Expected 1 property, found ${keys.length}`));
}
vartypeObj=memo.contentModelData[pluginType];
// don't overwrite an existing attribute
if(typeObj[key] &&_.intersection(Object.keys(typeObj[key]), keys).length>0) {
returneachCallback(newError(`Already found ${pluginType}${key} attribute with key ${keys[0]} (${schema.name})`));
} elseif(!typeObj) {
memo.contentModelData[pluginType] =typeObj= {};
}
// NOTE this is needed to check against applied menu/theme in schemas.js
props[keys[0]].name=schema.name;

typeObj[key] =_.extend({}, typeObj[key], props);
eachCallback();

}, function(error) {
if(error) returncallback(error);
// remove pluginLocations and store plugin schema
deleteschema.properties.pluginLocations;
if(!_.isEmpty(schema.properties)) {
memo.schemas[schema[pluginType]] =schema;
}
callback();
});
}