AbstractInterface
Methods
public abstract addParameter( $name, $value)
 
Adds a parameter to the service locator that can be injected in a tag's factory method.

When calling a tag's "create" method we always check the signature for dependencies to inject. One way is to typehint a parameter in the signature so that we can use that interface or class name to inject a dependency (see {@see \addService()} for more information on that).

Another way is to check the name of the argument against the names in the Service Locator. With this method you can add a variable that will be inserted when a tag's create method is not typehinted and has a matching name.

Be aware that there are two reserved names:

  • name, representing the name of the tag.
  • body, representing the complete body of the tag.

These parameters are injected at the last moment and will override any existing parameter with those names.

  • return void
public abstract addService( $service)
 
Registers a service with the Service Locator using the FQCN of the class or the alias, if provided.

When calling a tag's "create" method we always check the signature for dependencies to inject. If a parameter has a typehint then the ServiceLocator is queried to see if a Service is registered for that typehint.

Because interfaces are regularly used as type-hints this method provides an alias parameter; if the FQCN of the interface is passed as alias then every time that interface is requested the provided service will be returned.

  • return void
public abstract create( $tagLine, ?phpDocumentor\Reflection\Types\Context $context = NULL)
 
Factory method responsible for instantiating the correct sub type.

public abstract registerTagHandler( $tagName, $handler)
 
Registers a handler for tags.

If you want to use your own tags then you can use this method to instruct the TagFactory to register the name of a tag with the FQCN of a 'Tag Handler'. The Tag handler should implement the {@see \Tag} interface (and thus the create method).

  • throws InvalidArgumentException if the tag name is not a string
  • throws InvalidArgumentException if the tag name is namespaced (contains backslashes) but does not start with a backslash
  • throws InvalidArgumentException if the handler is not a string
  • throws InvalidArgumentException if the handler is not an existing class
  • throws InvalidArgumentException if the handler does not implement the {@see \Tag} interface
  • return void
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only