Back to OnGetApiRelation class

Method __construct

public
__construct
(mixed $name, array $arguments = array())
Constructor.
Parameters
  • string $name The event name.
  • array $arguments The event arguments.
Since
  • 4.0.0
-
  • \BadMethodCallException

Method __construct - Source code

/**
 * Constructor.
 *
 * Mandatory arguments:
 * model        mixed           The model being used to render the resource.
 * field        string          The field name we wish to obtain a relationship for.
 * context      string          The content type of the api resource.
 *
 * @param   string  $name       The event name.
 * @param   array   $arguments  The event arguments.
 *
 * @since   4.0.0
 * @throws  \BadMethodCallException
 */
public function __construct($name, array $arguments = array())
{
    if (!\array_key_exists('model', $arguments)) {
        throw new \BadMethodCallException("Argument 'model' is required for event {$name}");
    }
    if (!\array_key_exists('field', $arguments)) {
        throw new \BadMethodCallException("Argument 'field' is required for event {$name}");
    }
    if (!\array_key_exists('context', $arguments)) {
        throw new \BadMethodCallException("Argument 'context' is required for event {$name}");
    }
    parent::__construct($name, $arguments);
}