<?php
/**
 * @brief		Content Listener
 * @author		<a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
 * @copyright	(c) Invision Power Services, Inc.
 * @license		https://www.invisioncommunity.com/legal/standards/
 * @package		Invision Community
{subpackage}
 * @since		{date}
 */

namespace IPS\{app}\listeners;

/* To prevent PHP errors (extending class does not exist) revealing path */

use IPS\Content as ContentClass;
use IPS\Content\Comment as CommentClass;
use IPS\Content\Item as ItemClass;
use IPS\Events\ListenerType\ContentListenerType;
use IPS\Node\Model;
use function defined;

if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
	header(($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0') . ' 403 Forbidden');
	exit;
}

/**
 * Content Listener
 */
class {filename} extends ContentListenerType
{
 	/**
 	 * @brief	[Required] The class that is handled by this listener
 	 * @var string
 	 */
 	public static string $class = {class};

    /**
     * Fired when the item/comment is initialized (in constructFromData).
     * Useful for loading additional tables or properties
     *
     * @param ContentClass $object
     * @return void
     */
    public function onLoad( ContentClass $object ) : void
    {

    }

    /**
     * Fired before an item is created/edited
     *
     * @note    This event is NOT fired for comments.
     * @param ContentClass $object
     * @param array $values
     * @param bool $new     TRUE when fired before create; FALSE when fired before edit
     * @return void
     */
    public function onBeforeCreateOrEdit( ContentClass $object, array $values, bool $new = FALSE ) : void
    {

    }

    /**
     * Fired after an item/comment is created/edited
     *
     * @param ContentClass $object
     * @param array $values
     * @param bool $new     TRUE when fired before create; FALSE when fired before edit
     * @return void
     */
    public function onCreateOrEdit( ContentClass $object, array $values, bool $new = FALSE ) : void
    {

    }

    /**
     * Fired when an item/comment is deleted
     *
     * @param ContentClass $object
     * @return void
     */
    public function onDelete( ContentClass $object ) : void
    {

    }

    /**
     * Fired when an action is taken on a particular item/comment.
     * Example: pin, unpin, hide, unhide
     * Note: merge is handled with a separate event
     *
     * @param ContentClass $object
     * @param string $action
     * @return void
     */
    public function onStatusChange( ContentClass $object, string $action ) : void
    {

    }

    /***
     * Fired when items/comments are merged
     * Note: this is fired AFTER the merge is complete.
     *
     * @param ContentClass $object
     * @param array $items  Old items/comments merged into this one
     * @return void
     */
    public function onMerge( ContentClass $object, array $items ) : void
    {

    }

	/**
	 * Fired when an item is moved.
	 * Note: this is fired AFTER the move is complete.
	 *
	 * @param ItemClass $item
	 * @param Model $oldContainer   Previous node
	 * @param bool $keepLink
	 * @return void
	 */
	public function onItemMove( ItemClass $item, Model $oldContainer, bool $keepLink = FALSE ) : void
	{

	}

	/**
	 * Fired when a comment is moved.
	 * Note: this is fired AFTER the move is complete.
	 *
	 * @param CommentClass $comment
	 * @param ItemClass $oldItem
	 * @param bool $skip
	 * @return void
	 */
	public function onCommentMove( CommentClass $comment, ItemClass $oldItem, bool $skip = FALSE ) : void
	{

	}

    /***
     * Fired when an item is viewed, and runs updateViews() via the ViewUpdates trait
     *
     * @param ItemClass $item
     * @return void
     */
    public function onItemView( ItemClass $item ) : void
    {

    }
}