Skip to content

Latest commit

 

History

History
109 lines (48 loc) · 2.9 KB

light-execute-notation.md

File metadata and controls

109 lines (48 loc) · 2.9 KB

Light execute notation

2020-08-14 -> 2021-03-23

The light execute notation allows for plugin authors to use a syntax to call methods from php classes and/or light services.

Examples:

  • @kit_editor->getDuelistEngine()
  • @zobruk->getTail(hello, [apple, banana])
  • \Ling\Planet007\Util035::exampleStaticMethod()
  • \Ling\Planet007\Util035->nonStaticExampleMethod222(yoshimitsu)

The notation must have one of the following format:

  • $class::$method

  • $class::$method ( $args )

  • $class->$method

  • $class->$method ( $args )

  • @$service->$method

  • @$service->$method ( $args )

With:

  • $class: the full class name (example: Ling\Bat)
  • $method: the name of the method to execute
  • $args: a list of arguments written with smartCode notation. Note: we can use regular php notation as it's a subset of the smartCode notation.
  • $service: the name of the service to call. The special name "container" is reserved to access the container itself (i.e. useful if you need to access the "has" method of the container for instance).

Note: if the class (i.e. not a service) needs to be instantiated, we just call the class constructor without arguments.

A tool to interpret this notation is:

See the related tools section for more tools.

light execute notation with light pmp wrapper

2020-12-03

When there is a potential interpretation conflict with other notations, the light execute notation is often wrapped inside what we call the light pmp wrapper. The light pmp wrapper is a pmp wrapper with a double colon identifier (::).

So, for instance:

  • ::( $class->$method ( $args ) )::

You'll find this notation in configuration files for instance.

Note: in the above example I added extra whitespace for reading clarity, but usually you'll use a more compact form without any whitespace, although both forms are functionally equivalent.

By convention, the double colon identifier inside configuration files is reserved for the light execute notation; other plugins might use different notations with different pmp wrapper identifiers.

Using the notation in configuration files

2020-11-27 -> 2020-12-03

See the light execute notation with light pmp wrapper section.

Related tools

2020-08-14