2015-08-03, 07:51 AM
(2015-08-03, 06:26 AM)Euan T Wrote: [ -> ]It'll still be possible to create plugins with a single file.
Yes and it will also be possible to create plugins with a nice structure too
(2015-08-03, 06:26 AM)Euan T Wrote: [ -> ]It'll still be possible to create plugins with a single file.
(2015-08-03, 06:47 AM)martec Wrote: [ -> ](2015-08-03, 06:26 AM)Euan T Wrote: [ -> ]It'll still be possible to create plugins with a single file, no idea where you got that from. We're still using a system like the hooks system, just cleaning it up and improving it (eg: multiple parameters for hook functions).
I think because of mybb 2.0 using framework need several files to create extension...
Too something like controller, routing for me only complicate than simplifcate... if not need controller or something like so ok...
(2015-08-03, 11:43 AM)Euan T Wrote: [ -> ]You can do it like that, or if it's a simple plugin you can simply use hooks. The only requirement is a main plugin class, which returns the plugins details and initializes any hooks. Other than that, developers are free to write their code as they wish.
$plugins->add_hook("global_start", "rot");
function rot () {
global $rand;
$rand = mt_rand("1","16");
}
(2015-08-03, 02:35 PM)martec Wrote: [ -> ]So it seems that will not be as simple as system 1.x then.
I understand that should add more feature like modifying existing function, more control over template etc.
But just hope it does not get that confused and laborious thing to make a simple plugin like in phpbb.
I understand that to make a complex plugin can be simpler with something more powerful, but to make simple thing looks like it will become more complicated.
(2015-08-03, 02:20 PM)martec Wrote: [ -> ](2015-08-03, 11:43 AM)Euan T Wrote: [ -> ]You can do it like that, or if it's a simple plugin you can simply use hooks. The only requirement is a main plugin class, which returns the plugins details and initializes any hooks. Other than that, developers are free to write their code as they wish.
so need put something like $plugins->add_hook('global_start', 'xxxxxxxx'); inside of class ?
what will change something like below (very very simple plugin)?
$plugins->add_hook("global_start", "rot"); function rot () { global $rand; $rand = mt_rand("1","16"); }
only will need change that i need put $plugins->add_hook("global_start", "rot"); inside of class? or something above not will work?
class MyPlugin extends \Mybb\Core\AbstractPlugin
{
public static function getInfo()
{
return [
'name' => 'My Plugin',
'description' => 'My plugins description...',
// etc.
];
}
public function register()
{
$this->events->on('global_start', function() {
global $rand;
$rand = mt_rand("1","16");
});
}
}
(2015-08-03, 03:05 PM)martec Wrote: [ -> ]I'm sorry for anything.
It's just fear.
When I saw the phpbb extension system made me quite scared.
(2015-08-03, 03:02 PM)Euan T Wrote: [ -> ]It'll be more like:
class MyPlugin extends \Mybb\Core\AbstractPlugin { public static function getInfo() { return [ 'name' => 'My Plugin', 'description' => 'My plugins description...', // etc. ]; } public function register() { $this->events->on('global_start', function() { global $rand; $rand = mt_rand("1","16"); }); } }
This leads to much better code, encapsulates your variables to prevent conflicts between plugins and makes it far easier to trace what is happening where.
As Will said, we have not yet implemented the plugin system, but when we have we will be releasing a full blog post and documentation describing how to implement both simple and more complex plugins with full code samples.
(2015-08-03, 03:10 PM)Euan T Wrote: [ -> ](2015-08-03, 03:05 PM)martec Wrote: [ -> ]I'm sorry for anything.
It's just fear.
When I saw the phpbb extension system made me quite scared.
We're still trying to keep it as simple as we can as we believe the best part about MyBB is how easy it is to customize. At the same time, we also want to make it powerful and modern, which is why we're taking the approach we are
As said, there will be a full set of documentation and examples made available at the same time as the first Alpha release. We'll also be taking community submissions to the documentation (as we do now) and examples to make it as easy as possible to start writing extensions and themes.