Skip to content

Instantly share code, notes, and snippets.

@lussoluca
Created July 2, 2015 07:32
Show Gist options
  • Save lussoluca/f1a8b00e2d2de30e4970 to your computer and use it in GitHub Desktop.
Save lussoluca/f1a8b00e2d2de30e4970 to your computer and use it in GitHub Desktop.
/**
* {@inheritdoc}
*
* Uses late static binding to create an instance of this class with
* injected dependencies.
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('weatherService'),
$container->get('config.factory'),
$container->get('state')
);
}
/**
* @param array $configuration
* @param string $plugin_id
* @param mixed $plugin_definition
* @param \Drupal\weather\WeatherServiceInterface $weatherService
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* @param \Drupal\Core\State\StateInterface $state
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, WeatherServiceInterface $weatherService, ConfigFactoryInterface $configFactory, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->weatherService = $weatherService;
$this->configFactory = $configFactory;
$this->state = $state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment