Skip to content
Code-Schnipsel Gruppen Projekte
Events.php 924 B
Newer Older
Henning Leutz's avatar
Henning Leutz committed
<?php

/**
 * This file contains \QUI\FAQ\Events
 */

namespace QUI\FAQ;

/**
 * FAQ Events
 *
 * @author www.pcsg.de (Henning Leutz)
 */

class Events
{
    /**
     * event on child create
     *
Henning Leutz's avatar
Henning Leutz committed
     * @param integer $newId
Henning Leutz's avatar
Henning Leutz committed
     * @param \QUI\Projects\Site\Edit $Parent
     */
    static function onChildCreate($newId, $Parent)
    {
        $type = $Parent->getAttribute( 'type' );

        if ( $type != 'quiqqer/faq:types/list' && $type != 'quiqqer/faq:types/category' ) {
            return;
        }

        $Project = $Parent->getProject();
        $Site    = new \QUI\Projects\Site\Edit( $Project, $newId );

        if ( $type == 'quiqqer/faq:types/list' ) {
            $Site->setAttribute( 'type', 'quiqqer/faq:types/category' );
        }

        if ( $type == 'quiqqer/faq:types/category' ) {
            $Site->setAttribute( 'type', 'quiqqer/faq:types/entry' );
        }

        $Site->save();
    }
}