Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minimum PHP Version?
#14
(2015-08-08, 09:10:50)shawn_a Wrote: It breaks extend..

An easy to use config file wrapper for plugins is easy with 3.4, if you want to make one go ahead ill add it to 3.4
The problem without plugin classes, is you have to throw the plugin id around, there is no way to know which plugin is trying to do stuff.

( we register hooks and use debugg_backtrace to log the file and stuff, but this is being removed in 3.4 as it is inefficient and unecessary, so it cannot be used, it is also a non production function )

only register_plugin knows what the plugin id is at runtime, hmm

Maybe a interesting back portable class could be reachable by old plugins.






Code:
$myplugin = getPlugin($thisfile);
$config = $myplugin->getConfig();
$config->addConfig('color','red');
$config->save;

of course making stuff like that plugin useful might be neat

configdatatype extends class plugin.config
plugin.config.adddatatype($configid);
datatype wysiwyg

Are you saying that the 5.2 closure stuff breaks extend, or removing the your_plugin.php file?

As for throwing the ID around, that is where anonymous functions could help. You'd create a collection of "curried" functions, and then pass the plugin's id into the curried function in the plugin loading loop:

PHP Code:
$register_plugin = function($id, ...) {
 
 return function (...) use ($id) { ... };
};

$add_hook = function($id, ...) {
 
 return function (...) use ($id) { ... };
};

$get_config  function($id, ...) {
 
 return function (...) use ($id) { ... };
};

...

foreach (
$plugins as $id => $file) {
 
 $register $register_plugin($id);
 
 $hook     $add_hook($id);
 
 $config   $get_config($id);
 
 ...

 
 // Closure to protect variables declared within the function
 
 // Import the above local functions into said closure
 
 call_user_func(function() use ($file$register$hook$config, ...) {
 
   include $file;
 
 });

Reply


Messages In This Thread
Minimum PHP Version? - by Angryboy - 2015-07-30, 17:28:50
RE: Minimum PHP Version? - by shawn_a - 2015-07-30, 23:08:20
RE: Minimum PHP Version? - by Angryboy - 2015-07-31, 01:10:36
RE: Minimum PHP Version? - by Tyblitz - 2015-08-02, 08:23:25
RE: Minimum PHP Version? - by shawn_a - 2015-08-02, 09:36:35
RE: Minimum PHP Version? - by Angryboy - 2015-08-02, 11:41:22
RE: Minimum PHP Version? - by shawn_a - 2015-08-02, 13:28:03
RE: Minimum PHP Version? - by shawn_a - 2015-08-02, 13:31:09
RE: Minimum PHP Version? - by Angryboy - 2015-08-02, 15:12:22
RE: Minimum PHP Version? - by shawn_a - 2015-08-02, 23:33:54
RE: Minimum PHP Version? - by Tyblitz - 2015-08-03, 04:25:26
RE: Minimum PHP Version? - by Angryboy - 2015-08-08, 07:34:07
RE: Minimum PHP Version? - by shawn_a - 2015-08-08, 09:10:50
RE: Minimum PHP Version? - by Angryboy - 2015-08-08, 16:19:39
RE: Minimum PHP Version? - by shawn_a - 2015-08-09, 01:08:55



Users browsing this thread: 1 Guest(s)