public function testPutOverridesGetCallback() { $pool = new MemoryPool(); $result = $pool->get('foo', function () { return 1; }); $this->assertEquals(1, $result); $pool->put('foo', 2); $result = $pool->get('foo', function () { return 3; }); $this->assertEquals(2, $result); }
/** * Returns an \ElggPlugin object with the path $path. * * @param string $plugin_id The id (dir name) of the plugin. NOT the guid. * @return \ElggPlugin|null */ function get($plugin_id) { return $this->plugins_by_id->get($plugin_id, function () use($plugin_id) { $plugin_id = sanitize_string($plugin_id); $db_prefix = get_config('dbprefix'); $options = array('type' => 'object', 'subtype' => 'plugin', 'joins' => array("JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"), 'selects' => array("oe.title", "oe.description"), 'wheres' => array("oe.title = '{$plugin_id}'"), 'limit' => 1, 'distinct' => false); $plugins = elgg_get_entities($options); if ($plugins) { return $plugins[0]; } return null; }); }