DerDu/SPHERE-Framework

View on GitHub
Application/People/Group/Group.php

Summary

Maintainability
A
1 hr
Test Coverage
<?php
namespace SPHERE\Application\People\Group;

use SPHERE\Application\IApplicationInterface;
use SPHERE\Application\IModuleInterface;
use SPHERE\Application\Platform\Gatekeeper\Authorization\Consumer\Consumer;
use SPHERE\Common\Frontend\Icon\Repository\PersonGroup;
use SPHERE\Common\Main;
use SPHERE\Common\Window\Navigation\Link;
use SPHERE\System\Database\Link\Identifier;

/**
 * Class Group
 *
 * @package SPHERE\Application\People\Group
 */
class Group implements IApplicationInterface, IModuleInterface
{

    public static function registerApplication()
    {

        self::registerModule();

        /**
         * Register Navigation
         */
        Main::getDisplay()->addApplicationNavigation(
            new Link(new Link\Route(__NAMESPACE__), new Link\Name('Gruppen'),
                new Link\Icon(new PersonGroup())
            )
        );
    }

    public static function registerModule()
    {

        Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute(
            __NAMESPACE__, 'Frontend::frontendGroup'
        )
            ->setParameterDefault('Group', null)
        );
        Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute(
            __NAMESPACE__.'/Edit', __NAMESPACE__.'\Frontend::frontendEditGroup'
        )
            ->setParameterDefault('Id', null)
            ->setParameterDefault('Group', null)
        );
        Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute(
            __NAMESPACE__.'/Destroy', __NAMESPACE__.'\Frontend::frontendDestroyGroup'
        )
            ->setParameterDefault('Id', null)
            ->setParameterDefault('Confirm', false)
        );
        Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute(
            __NAMESPACE__.'/Person/Add', __NAMESPACE__.'\Frontend::frontendGroupPersonAdd'
        ));
        Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute(
            __NAMESPACE__.'/Custody', __NAMESPACE__.'\Frontend::frontendRelationshipCustody'
        ));
        Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute(
            __NAMESPACE__.'/Custody/Save', __NAMESPACE__.'\Frontend::frontendSaveRelationshipCustody'
        ));
    }

    /**
     * @return Service
     */
    public static function useService()
    {

        return new Service(
            new Identifier('People', 'Group', null, null, Consumer::useService()->getConsumerBySession()),
            __DIR__.'/Service/Entity', __NAMESPACE__.'\Service\Entity'
        );
    }

    /**
     * @return Frontend
     */
    public static function useFrontend()
    {

        return new Frontend();
    }
}