Back to ApiApplication class

Method __construct

public
__construct
(\Joomla\Input\Json $input = null, \Joomla\Registry\Registry $config = null, \Joomla\Application\Web\WebClient $client = null, \Joomla\DI\Container $container = null)
Class constructor.
Parameters
  • \Joomla\Input\Json $input An optional argument to provide dependency injection for the application's input object. If the argument is a JInput object that object will become the application's input object, otherwise a default input object is created.
  • \Joomla\Registry\Registry $config An optional argument to provide dependency injection for the application's config object. If the argument is a Registry object that object will become the application's config object, otherwise a default config object is created.
  • \Joomla\Application\Web\WebClient $client An optional argument to provide dependency injection for the application's client object. If the argument is a WebClient object that object will become the application's client object, otherwise a default client object is created.
  • \Joomla\DI\Container $container Dependency injection container.
Since
  • 4.0.0

Method __construct - Source code

/**
 * Class constructor.
 *
 * @param   JInputJson  $input      An optional argument to provide dependency injection for the application's input
 *                                  object.  If the argument is a JInput object that object will become the
 *                                  application's input object, otherwise a default input object is created.
 * @param   Registry    $config     An optional argument to provide dependency injection for the application's config
 *                                  object.  If the argument is a Registry object that object will become the
 *                                  application's config object, otherwise a default config object is created.
 * @param   WebClient   $client     An optional argument to provide dependency injection for the application's client
 *                                  object.  If the argument is a WebClient object that object will become the
 *                                  application's client object, otherwise a default client object is created.
 * @param   Container   $container  Dependency injection container.
 *
 * @since   4.0.0
 */
public function __construct(JInputJson $input = null, Registry $config = null, WebClient $client = null, Container $container = null)
{
    // Register the application name
    $this->name = 'api';
    // Register the client ID
    $this->clientId = 3;
    // Execute the parent constructor
    parent::__construct($input, $config, $client, $container);
    $this->addFormatMap('application/json', 'json');
    $this->addFormatMap('application/vnd.api+json', 'jsonapi');
    // Set the root in the URI based on the application name
    Uri::root(null, str_ireplace('/' . $this->getName(), '', Uri::base(true)));
}