[Update 2024] - Take a look at Drupal at your fingertips. Lot's of great stuff there.
// Load file object
$file = File::load($fid);| const express = require('express'); | |
| const forum = express(); | |
| forum | |
| .get('/healthz', (req, res, next) => { | |
| res.send({ name: 'forum', status: 'healthy' }); | |
| next(); | |
| }) | |
| .get('/d/:id', (req, res, next) => { |
| /* Attribution: http://techslides.com/how-to-parse-and-search-json-in-javascript */ | |
| //return an array of objects according to key, value, or key and value matching | |
| function getObjects(obj, key, val) { | |
| var objects = []; | |
| for (var i in obj) { | |
| if (!obj.hasOwnProperty(i)) continue; | |
| if (typeof obj[i] == 'object') { | |
| objects = objects.concat(getObjects(obj[i], key, val)); | |
| } else |
[Update 2024] - Take a look at Drupal at your fingertips. Lot's of great stuff there.
// Load file object
$file = File::load($fid);See discussion at https://www.drupal.org/project/drupal/issues/937442
!! Use and improve the contrib module or its code instead of this older Gist !!
I've created https://www.drupal.org/project/devel_schema_change_helper because we needed these helpers again and again. We could also prepare the functionality there and move it over into core once it's finished to have a working solution in contrib.
| /** | |
| * Are all the values on p present on o | |
| * @param {Object} o object to search | |
| * @param {Object} p object of search values | |
| * @param {Boolean} [c] are loose equality matches ok? | |
| * @return {Boolean} whether there are partial matches | |
| */ | |
| const partialMatch = (o, p, c) => | |
| Object.keys(p).every(k => | |
| p[k] && o[k] |