2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* The `Model` class represents a local data resource. It provides methods to
|
|
|
|
* persist changes via the API.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
*/
|
2015-04-25 20:58:39 +08:00
|
|
|
export default class Model {
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* @param {Object} data A resource object from the API.
|
|
|
|
* @param {Store} store The data store that this model should be persisted to.
|
|
|
|
* @public
|
|
|
|
*/
|
2015-10-13 14:27:18 +08:00
|
|
|
constructor(data = {}, store = null) {
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* The resource object from the API.
|
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
this.data = data;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The time at which the model's data was last updated. Watching the value
|
|
|
|
* of this property is a fast way to retain/cache a subtree if data hasn't
|
|
|
|
* changed.
|
|
|
|
*
|
|
|
|
* @type {Date}
|
|
|
|
* @public
|
|
|
|
*/
|
2015-04-25 20:58:39 +08:00
|
|
|
this.freshness = new Date();
|
2015-07-15 12:30:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the resource exists on the server.
|
|
|
|
*
|
|
|
|
* @type {Boolean}
|
|
|
|
* @public
|
|
|
|
*/
|
2015-04-25 20:58:39 +08:00
|
|
|
this.exists = false;
|
2015-07-15 12:30:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The data store that this resource should be persisted to.
|
|
|
|
*
|
|
|
|
* @type {Store}
|
|
|
|
* @protected
|
|
|
|
*/
|
2015-04-25 20:58:39 +08:00
|
|
|
this.store = store;
|
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Get the model's ID.
|
|
|
|
*
|
|
|
|
* @return {Integer}
|
|
|
|
* @public
|
|
|
|
* @final
|
|
|
|
*/
|
2015-07-04 10:54:48 +08:00
|
|
|
id() {
|
2015-07-15 12:30:11 +08:00
|
|
|
return this.data.id;
|
2015-07-04 10:54:48 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Get one of the model's attributes.
|
|
|
|
*
|
|
|
|
* @param {String} attribute
|
|
|
|
* @return {*}
|
|
|
|
* @public
|
|
|
|
* @final
|
|
|
|
*/
|
2015-07-07 13:59:21 +08:00
|
|
|
attribute(attribute) {
|
2015-07-15 12:30:11 +08:00
|
|
|
return this.data.attributes[attribute];
|
2015-07-07 13:59:21 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Merge new data into this model locally.
|
|
|
|
*
|
|
|
|
* @param {Object} data A resource object to merge into this model
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
pushData(data) {
|
|
|
|
// Since most of the top-level items in a resource object are objects
|
|
|
|
// (e.g. relationships, attributes), we'll need to check and perform the
|
|
|
|
// merge at the second level if that's the case.
|
|
|
|
for (const key in data) {
|
|
|
|
if (typeof data[key] === 'object') {
|
|
|
|
this.data[key] = this.data[key] || {};
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
// For every item in a second-level object, we want to check if we've
|
|
|
|
// been handed a Model instance. If so, we will convert it to a
|
|
|
|
// relationship data object.
|
2015-08-14 11:20:39 +08:00
|
|
|
for (const innerKey in data[key]) {
|
|
|
|
if (data[key][innerKey] instanceof Model) {
|
Major refactor and improvements
- Reorganised all namespaces and class names for consistency and structure. Following PSR bylaws (Abstract prefix, Interface/Trait suffix).
- Move models into root of Core, because writing `use Flarum\Core\Discussion` is nice. Namespace the rest by type. (Namespacing by entity was too arbitrary.)
- Moved some non-domain stuff out of Core: Database, Formatter, Settings.
- Renamed config table and all references to "settings" for consistency.
- Remove Core class and add url()/isInstalled()/inDebugMode() as instance methods of Foundation\Application.
- Cleanup, docblocking, etc.
- Improvements to HTTP architecture
- API and forum/admin Actions are now actually all the same thing (simple PSR-7 Request handlers), renamed to Controllers.
- Upgrade to tobscure/json-api 0.2 branch.
- Where possible, moved generic functionality to tobscure/json-api (e.g. pagination links). I'm quite happy with the backend balance now re: #262
- Improvements to other architecture
- Use Illuminate's Auth\Access\Gate interface/implementation instead of our old Locked trait. We still use events to actually determine the permissions though. Our Policy classes are actually glorified event subscribers.
- Extract model validation into Core\Validator classes.
- Make post visibility permission stuff much more efficient and DRY.
- Renamed Flarum\Event classes for consistency. ref #246
- `Configure` prefix for events dedicated to configuring an object.
- `Get` prefix for events whose listeners should return something.
- `Prepare` prefix when a variable is passed by reference so it can be modified.
- `Scope` prefix when a query builder is passed.
- Miscellaneous improvements/bug-fixes. I'm easily distracted!
- Increase default height of post composer.
- Improve post stream redraw flickering in Safari by keying loading post placeholders with their IDs. ref #451
- Use a PHP JavaScript minification library for minifying TextFormatter's JavaScript, instead of ClosureCompilerService (can't rely on external service!)
- Use UrlGenerator properly in various places. closes #123
- Make Api\Client return Response object. closes #128
- Allow extensions to specify custom icon images.
- Allow external API/admin URLs to be optionally specified in config.php. If the value or "url" is an array, we look for the corresponding path inside. Otherwise, we append the path to the base URL, using the corresponding value in "paths" if present. closes #244
2015-10-08 11:58:02 +08:00
|
|
|
data[key][innerKey] = {data: Model.getIdentifier(data[key][innerKey])};
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
2015-08-14 11:20:39 +08:00
|
|
|
this.data[key][innerKey] = data[key][innerKey];
|
2015-07-04 10:54:48 +08:00
|
|
|
}
|
2015-04-25 20:58:39 +08:00
|
|
|
} else {
|
2015-07-15 12:30:11 +08:00
|
|
|
this.data[key] = data[key];
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
// Now that we've updated the data, we can say that the model is fresh.
|
|
|
|
// This is an easy way to invalidate retained subtrees etc.
|
2015-04-25 20:58:39 +08:00
|
|
|
this.freshness = new Date();
|
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Merge new attributes into this model locally.
|
|
|
|
*
|
|
|
|
* @param {Object} attributes The attributes to merge.
|
|
|
|
* @public
|
|
|
|
*/
|
2015-07-04 10:54:48 +08:00
|
|
|
pushAttributes(attributes) {
|
2015-07-15 12:30:11 +08:00
|
|
|
this.pushData({attributes});
|
2015-07-04 10:54:48 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Merge new attributes into this model, both locally and with persistence.
|
|
|
|
*
|
|
|
|
* @param {Object} attributes The attributes to save. If a 'relationships' key
|
|
|
|
* exists, it will be extracted and relationships will also be saved.
|
2015-10-20 10:18:26 +08:00
|
|
|
* @param {Object} [options]
|
2015-07-15 12:30:11 +08:00
|
|
|
* @return {Promise}
|
|
|
|
* @public
|
|
|
|
*/
|
2015-10-20 10:18:26 +08:00
|
|
|
save(attributes, options = {}) {
|
2015-07-15 12:30:11 +08:00
|
|
|
const data = {
|
|
|
|
type: this.data.type,
|
|
|
|
id: this.data.id,
|
2015-07-04 10:54:48 +08:00
|
|
|
attributes
|
|
|
|
};
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
// If a 'relationships' key exists, extract it from the attributes hash and
|
|
|
|
// set it on the top-level data object instead. We will be sending this data
|
|
|
|
// object to the API for persistence.
|
2015-07-04 10:54:48 +08:00
|
|
|
if (attributes.relationships) {
|
|
|
|
data.relationships = {};
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
for (const key in attributes.relationships) {
|
|
|
|
const model = attributes.relationships[key];
|
|
|
|
|
|
|
|
data.relationships[key] = {
|
|
|
|
data: model instanceof Array
|
Major refactor and improvements
- Reorganised all namespaces and class names for consistency and structure. Following PSR bylaws (Abstract prefix, Interface/Trait suffix).
- Move models into root of Core, because writing `use Flarum\Core\Discussion` is nice. Namespace the rest by type. (Namespacing by entity was too arbitrary.)
- Moved some non-domain stuff out of Core: Database, Formatter, Settings.
- Renamed config table and all references to "settings" for consistency.
- Remove Core class and add url()/isInstalled()/inDebugMode() as instance methods of Foundation\Application.
- Cleanup, docblocking, etc.
- Improvements to HTTP architecture
- API and forum/admin Actions are now actually all the same thing (simple PSR-7 Request handlers), renamed to Controllers.
- Upgrade to tobscure/json-api 0.2 branch.
- Where possible, moved generic functionality to tobscure/json-api (e.g. pagination links). I'm quite happy with the backend balance now re: #262
- Improvements to other architecture
- Use Illuminate's Auth\Access\Gate interface/implementation instead of our old Locked trait. We still use events to actually determine the permissions though. Our Policy classes are actually glorified event subscribers.
- Extract model validation into Core\Validator classes.
- Make post visibility permission stuff much more efficient and DRY.
- Renamed Flarum\Event classes for consistency. ref #246
- `Configure` prefix for events dedicated to configuring an object.
- `Get` prefix for events whose listeners should return something.
- `Prepare` prefix when a variable is passed by reference so it can be modified.
- `Scope` prefix when a query builder is passed.
- Miscellaneous improvements/bug-fixes. I'm easily distracted!
- Increase default height of post composer.
- Improve post stream redraw flickering in Safari by keying loading post placeholders with their IDs. ref #451
- Use a PHP JavaScript minification library for minifying TextFormatter's JavaScript, instead of ClosureCompilerService (can't rely on external service!)
- Use UrlGenerator properly in various places. closes #123
- Make Api\Client return Response object. closes #128
- Allow extensions to specify custom icon images.
- Allow external API/admin URLs to be optionally specified in config.php. If the value or "url" is an array, we look for the corresponding path inside. Otherwise, we append the path to the base URL, using the corresponding value in "paths" if present. closes #244
2015-10-08 11:58:02 +08:00
|
|
|
? model.map(Model.getIdentifier)
|
|
|
|
: Model.getIdentifier(model)
|
2015-06-12 15:11:13 +08:00
|
|
|
};
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
2015-07-04 10:54:48 +08:00
|
|
|
|
|
|
|
delete attributes.relationships;
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
// Before we update the model's data, we should make a copy of the model's
|
|
|
|
// old data so that we can revert back to it if something goes awry during
|
|
|
|
// persistence.
|
2015-11-05 13:47:00 +08:00
|
|
|
const oldData = this.copyData();
|
2015-05-27 14:55:44 +08:00
|
|
|
|
2015-04-25 20:58:39 +08:00
|
|
|
this.pushData(data);
|
|
|
|
|
2016-03-11 10:14:18 +08:00
|
|
|
const request = {data};
|
|
|
|
if (options.meta) request.meta = options.meta;
|
|
|
|
|
2015-10-20 10:18:26 +08:00
|
|
|
return app.request(Object.assign({
|
2015-07-04 10:54:48 +08:00
|
|
|
method: this.exists ? 'PATCH' : 'POST',
|
2015-07-29 19:30:09 +08:00
|
|
|
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
2016-03-11 10:14:18 +08:00
|
|
|
data: request
|
2015-10-20 10:18:26 +08:00
|
|
|
}, options)).then(
|
2015-07-15 12:30:11 +08:00
|
|
|
// If everything went well, we'll make sure the store knows that this
|
|
|
|
// model exists now (if it didn't already), and we'll push the data that
|
|
|
|
// the API returned into the store.
|
|
|
|
payload => {
|
2015-08-14 11:20:39 +08:00
|
|
|
this.store.data[payload.data.type] = this.store.data[payload.data.type] || {};
|
2015-07-15 12:30:11 +08:00
|
|
|
this.store.data[payload.data.type][payload.data.id] = this;
|
|
|
|
return this.store.pushPayload(payload);
|
|
|
|
},
|
|
|
|
|
|
|
|
// If something went wrong, though... good thing we backed up our model's
|
|
|
|
// old data! We'll revert to that and let others handle the error.
|
|
|
|
response => {
|
|
|
|
this.pushData(oldData);
|
2015-09-22 15:53:28 +08:00
|
|
|
m.lazyRedraw();
|
2015-07-15 12:30:11 +08:00
|
|
|
throw response;
|
|
|
|
}
|
|
|
|
);
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Send a request to delete the resource.
|
|
|
|
*
|
|
|
|
* @param {Object} data Data to send along with the DELETE request.
|
2015-10-20 10:18:26 +08:00
|
|
|
* @param {Object} [options]
|
2015-07-15 12:30:11 +08:00
|
|
|
* @return {Promise}
|
|
|
|
* @public
|
|
|
|
*/
|
2015-10-20 10:18:26 +08:00
|
|
|
delete(data, options = {}) {
|
2015-07-15 12:30:11 +08:00
|
|
|
if (!this.exists) return m.deferred.resolve().promise;
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-10-20 10:18:26 +08:00
|
|
|
return app.request(Object.assign({
|
2015-04-25 20:58:39 +08:00
|
|
|
method: 'DELETE',
|
2015-07-29 19:30:09 +08:00
|
|
|
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
2015-07-15 12:30:11 +08:00
|
|
|
data
|
2015-10-20 10:18:26 +08:00
|
|
|
}, options)).then(() => {
|
2015-07-31 18:46:47 +08:00
|
|
|
this.exists = false;
|
|
|
|
this.store.remove(this);
|
|
|
|
});
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
|
2015-07-29 19:30:09 +08:00
|
|
|
/**
|
|
|
|
* Construct a path to the API endpoint for this resource.
|
|
|
|
*
|
|
|
|
* @return {String}
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
apiEndpoint() {
|
|
|
|
return '/' + this.data.type + (this.exists ? '/' + this.data.id : '');
|
|
|
|
}
|
|
|
|
|
2015-11-05 13:47:00 +08:00
|
|
|
copyData() {
|
|
|
|
return JSON.parse(JSON.stringify(this.data));
|
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Generate a function which returns the value of the given attribute.
|
|
|
|
*
|
|
|
|
* @param {String} name
|
|
|
|
* @param {function} [transform] A function to transform the attribute value
|
|
|
|
* @return {*}
|
|
|
|
* @public
|
|
|
|
*/
|
2015-07-04 10:54:48 +08:00
|
|
|
static attribute(name, transform) {
|
2015-04-25 20:58:39 +08:00
|
|
|
return function() {
|
2015-07-31 18:46:47 +08:00
|
|
|
const value = this.data.attributes && this.data.attributes[name];
|
2015-07-15 12:30:11 +08:00
|
|
|
|
|
|
|
return transform ? transform(value) : value;
|
|
|
|
};
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Generate a function which returns the value of the given has-one
|
|
|
|
* relationship.
|
|
|
|
*
|
|
|
|
* @param {String} name
|
|
|
|
* @return {Model|Boolean|undefined} false if no information about the
|
|
|
|
* relationship exists; undefined if the relationship exists but the model
|
|
|
|
* has not been loaded; or the model if it has been loaded.
|
|
|
|
* @public
|
|
|
|
*/
|
2015-07-04 10:54:48 +08:00
|
|
|
static hasOne(name) {
|
2015-04-25 20:58:39 +08:00
|
|
|
return function() {
|
2015-07-15 12:30:11 +08:00
|
|
|
if (this.data.relationships) {
|
|
|
|
const relationship = this.data.relationships[name];
|
|
|
|
|
2015-07-28 16:58:31 +08:00
|
|
|
if (relationship) {
|
|
|
|
return app.store.getById(relationship.data.type, relationship.data.id);
|
|
|
|
}
|
2015-05-30 12:28:21 +08:00
|
|
|
}
|
2015-07-28 15:45:09 +08:00
|
|
|
|
|
|
|
return false;
|
2015-07-15 12:30:11 +08:00
|
|
|
};
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Generate a function which returns the value of the given has-many
|
|
|
|
* relationship.
|
|
|
|
*
|
|
|
|
* @param {String} name
|
|
|
|
* @return {Array|Boolean} false if no information about the relationship
|
|
|
|
* exists; an array if it does, containing models if they have been
|
|
|
|
* loaded, and undefined for those that have not.
|
|
|
|
* @public
|
|
|
|
*/
|
2015-07-04 10:54:48 +08:00
|
|
|
static hasMany(name) {
|
2015-04-25 20:58:39 +08:00
|
|
|
return function() {
|
2015-07-15 12:30:11 +08:00
|
|
|
if (this.data.relationships) {
|
|
|
|
const relationship = this.data.relationships[name];
|
|
|
|
|
2015-07-28 16:58:31 +08:00
|
|
|
if (relationship) {
|
|
|
|
return relationship.data.map(data => app.store.getById(data.type, data.id));
|
|
|
|
}
|
2015-05-30 12:28:21 +08:00
|
|
|
}
|
2015-07-28 15:45:09 +08:00
|
|
|
|
|
|
|
return false;
|
2015-07-15 12:30:11 +08:00
|
|
|
};
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* Transform the given value into a Date object.
|
|
|
|
*
|
|
|
|
* @param {String} value
|
|
|
|
* @return {Date|null}
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
static transformDate(value) {
|
|
|
|
return value ? new Date(value) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
Major refactor and improvements
- Reorganised all namespaces and class names for consistency and structure. Following PSR bylaws (Abstract prefix, Interface/Trait suffix).
- Move models into root of Core, because writing `use Flarum\Core\Discussion` is nice. Namespace the rest by type. (Namespacing by entity was too arbitrary.)
- Moved some non-domain stuff out of Core: Database, Formatter, Settings.
- Renamed config table and all references to "settings" for consistency.
- Remove Core class and add url()/isInstalled()/inDebugMode() as instance methods of Foundation\Application.
- Cleanup, docblocking, etc.
- Improvements to HTTP architecture
- API and forum/admin Actions are now actually all the same thing (simple PSR-7 Request handlers), renamed to Controllers.
- Upgrade to tobscure/json-api 0.2 branch.
- Where possible, moved generic functionality to tobscure/json-api (e.g. pagination links). I'm quite happy with the backend balance now re: #262
- Improvements to other architecture
- Use Illuminate's Auth\Access\Gate interface/implementation instead of our old Locked trait. We still use events to actually determine the permissions though. Our Policy classes are actually glorified event subscribers.
- Extract model validation into Core\Validator classes.
- Make post visibility permission stuff much more efficient and DRY.
- Renamed Flarum\Event classes for consistency. ref #246
- `Configure` prefix for events dedicated to configuring an object.
- `Get` prefix for events whose listeners should return something.
- `Prepare` prefix when a variable is passed by reference so it can be modified.
- `Scope` prefix when a query builder is passed.
- Miscellaneous improvements/bug-fixes. I'm easily distracted!
- Increase default height of post composer.
- Improve post stream redraw flickering in Safari by keying loading post placeholders with their IDs. ref #451
- Use a PHP JavaScript minification library for minifying TextFormatter's JavaScript, instead of ClosureCompilerService (can't rely on external service!)
- Use UrlGenerator properly in various places. closes #123
- Make Api\Client return Response object. closes #128
- Allow extensions to specify custom icon images.
- Allow external API/admin URLs to be optionally specified in config.php. If the value or "url" is an array, we look for the corresponding path inside. Otherwise, we append the path to the base URL, using the corresponding value in "paths" if present. closes #244
2015-10-08 11:58:02 +08:00
|
|
|
* Get a resource identifier object for the given model.
|
2015-07-15 12:30:11 +08:00
|
|
|
*
|
|
|
|
* @param {Model} model
|
|
|
|
* @return {Object}
|
|
|
|
* @protected
|
|
|
|
*/
|
Major refactor and improvements
- Reorganised all namespaces and class names for consistency and structure. Following PSR bylaws (Abstract prefix, Interface/Trait suffix).
- Move models into root of Core, because writing `use Flarum\Core\Discussion` is nice. Namespace the rest by type. (Namespacing by entity was too arbitrary.)
- Moved some non-domain stuff out of Core: Database, Formatter, Settings.
- Renamed config table and all references to "settings" for consistency.
- Remove Core class and add url()/isInstalled()/inDebugMode() as instance methods of Foundation\Application.
- Cleanup, docblocking, etc.
- Improvements to HTTP architecture
- API and forum/admin Actions are now actually all the same thing (simple PSR-7 Request handlers), renamed to Controllers.
- Upgrade to tobscure/json-api 0.2 branch.
- Where possible, moved generic functionality to tobscure/json-api (e.g. pagination links). I'm quite happy with the backend balance now re: #262
- Improvements to other architecture
- Use Illuminate's Auth\Access\Gate interface/implementation instead of our old Locked trait. We still use events to actually determine the permissions though. Our Policy classes are actually glorified event subscribers.
- Extract model validation into Core\Validator classes.
- Make post visibility permission stuff much more efficient and DRY.
- Renamed Flarum\Event classes for consistency. ref #246
- `Configure` prefix for events dedicated to configuring an object.
- `Get` prefix for events whose listeners should return something.
- `Prepare` prefix when a variable is passed by reference so it can be modified.
- `Scope` prefix when a query builder is passed.
- Miscellaneous improvements/bug-fixes. I'm easily distracted!
- Increase default height of post composer.
- Improve post stream redraw flickering in Safari by keying loading post placeholders with their IDs. ref #451
- Use a PHP JavaScript minification library for minifying TextFormatter's JavaScript, instead of ClosureCompilerService (can't rely on external service!)
- Use UrlGenerator properly in various places. closes #123
- Make Api\Client return Response object. closes #128
- Allow extensions to specify custom icon images.
- Allow external API/admin URLs to be optionally specified in config.php. If the value or "url" is an array, we look for the corresponding path inside. Otherwise, we append the path to the base URL, using the corresponding value in "paths" if present. closes #244
2015-10-08 11:58:02 +08:00
|
|
|
static getIdentifier(model) {
|
2015-07-15 12:30:11 +08:00
|
|
|
return {
|
|
|
|
type: model.data.type,
|
|
|
|
id: model.data.id
|
|
|
|
};
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|
|
|
|
}
|