0

I get this error with the ATK 9 framework

class App\Modules\Auth\Module contains 1 abstract method and must therefore be declared abstract or implement the remaining methods

calling the below class:

abstract class Module
{
public static $module;

/** @var Atk $atk */
private $atk;

/** @var Menu $menu */
private $menu;

public function __construct(Atk $atk, Menu $menu)
{
    $this->atk = $atk;
    $this->menu = $menu;
}

protected function getMenu()
{
    return $this->menu;
}

protected function getAtk()
{
    return $this->atk;
}

abstract public function register();

public function boot()
{
    //noop
}

public function registerNode($nodeName, $nodeClass, $actions = null)
{
    $this->atk->registerNode(static::$module.'.'.$nodeName, $nodeClass, $actions);
}

public function addNodeToMenu($menuName, $nodeName, $action, $parent = 'main', $enable = null, $order = 0, $navbar = 'left')
{
    if ($enable === null) {
        $enable = [static::$module.'.'.$nodeName, $action];
    }
    $this->menu->addMenuItem($menuName, Tools::dispatch_url(static::$module.'.'.$nodeName, $action), $parent, $enable, $order, static::$module, '', $navbar);
}

public function addMenuItem($name = '', $url = '', $parent = 'main', $enable = 1)
{
    $this->menu->addMenuItem($name, $url, $parent, $enable, 0, static::$module);
}
}

this is the code i use to call the class Module:

class Module extends \Sintattica\Atk\Core\Module
{
static $module = 'auth';

public function boot()
{
    $this->registerNode('users', Users::class, ['admin', 'add', 'edit', 'delete']);
    $this->registerNode('groups', Groups::class, ['admin', 'add', 'edit', 'delete']);
    $this->registerNode('users_groups', UsersGroups::class);

    $this->addMenuItem('auth');
    $this->addNodeToMenu('users', 'users', 'admin', 'auth');
    $this->addNodeToMenu('groups', 'groups', 'admin', 'auth');
}
}

thanks

StackUseR
  • 884
  • 1
  • 11
  • 40
  • 3
    isn't `class App\Modules\Auth\Module contains 1 abstract method and must therefore be declared abstract or implement the remaining methods` clear enough? you must implement the `register` method. – Federkun Dec 02 '16 at 14:52
  • Possible duplicate of [How to work with PHP abstract?](http://stackoverflow.com/questions/7243175/how-to-work-with-php-abstract) – Alessandro Da Rugna Dec 02 '16 at 16:17

1 Answers1

0

You HAVE TO implement register method from \Sintattica\Atk\Core\Module Class in your Client Module Class.

When extending an Abstract class, ALL Abstract methods MUST be implemented in client(child class) code.

behkod
  • 2,647
  • 2
  • 18
  • 33