Jump to content

Developer Documentation

Misc. Changes

PHP Traits

Invision Community 4.2 has introduced the usage of PHP Traits. While Traits are a fairly standard feature in PHP, due to the way our autoloader and monkey patching works for plugins, the class_uses() function will not work properly. As such, if you need to check if a specific class uses a trait, then you should use \IPS\IPS::classUsesTrait() instead - this will check all classes in the extension chain.

	/**
	 * Small utility function to check if a class has a trait as PHP doesn't have an operator
	 * for this and the monkey patching means we can't use class_uses() directly
	 *
	 * @param	string|object	$class 	The class
	 * @param	string			$trait	Trait name to look for
	 * @return	bool
	 */
	public static function classUsesTrait( $class, $trait )

Widget Errors

Widgets can return now custom error messages in the event their content cannot be displayed. This is useful if, for example, the content of a widget can only be seen by Guests, and that the user should log out to see the content.

$this->errorMessage = 'my_custom_error_lang_key';

 

Edited by Ryan Ashbrook

  Report Document


×
×
  • Create New...