| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /**
- * @author Open Mind
- * @date 21/06/2018
- * @time 12:34
- */
- namespace OpenMind\System;
- /**
- * Interface IPluginStrategy
- * Main interface for plugin system, it use Strategy Pattern.
- *
- * @package OpenMind\System
- */
- interface IPluginStrategy
- {
- public function __construct();
- /**
- * Class version
- * @return string
- */
- public function getVersion(): string;
- /**
- * Class name
- * @return string
- */
- public function getName(): string;
- /**
- * Set method route
- *
- * @param array|string $pattern
- * @param string $handler
- * @return mixed
- */
- public function AddRoute($pattern, string $handler);
- }
- /**
- * Class PluginStrategy
- * Basically every plugin must extend this class to work
- *
- */
- class PluginStrategy implements IPluginStrategy
- {
- public function __construct()
- {
- throw new \Exception("Plugin " . $this->getName() . ' doesn\'t have a __constructor() function. Please provide one.');
- }
- /**
- * Return default version for plugins that doesn't have one
- *
- * @return string
- */
- public function getVersion(): string
- {
- return '1.0';
- }
- /**
- * Return Class name, usefull when a list of installed plugins is need
- *
- * @return string
- */
- public function getName(): string
- {
- return get_class($this);
- }
- public function AddRoute($pattern, string $handler)
- {
- \F3::route($pattern, $handler, 0); // TTL 60s
- }
- }
|