Skip to content

Instantly share code, notes, and snippets.

@miteshmap
Last active February 19, 2020 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miteshmap/15bfc8be851465f7a39e054ed9d9fb82 to your computer and use it in GitHub Desktop.
Save miteshmap/15bfc8be851465f7a39e054ed9d9fb82 to your computer and use it in GitHub Desktop.
Drupal 8: Service Decorators: OriginalServiceOverride.php
<?php
namespace Drupal\custom_decorator_override;
use Drupal\custom_decorator_base\OriginalService;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Class OriginalServiceOverride
*/
class OriginalServiceOverride extends OriginalService {
/**
* Original service object.
*
* @var \Drupal\custom_decorator_base\OriginalService
*/
protected $originalService;
/**
* OriginalServiceOverride constructor.
*
* @param \Drupal\custom_decorator_base\OriginalService $original_service
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
*/
public function __construct(OriginalService $original_service, RequestStack $request_stack) {
$this->originalService = $original_service;
parent::__construct($request_stack);
}
public function helper() {
return t('Overridden helper');
}
public function newPublicFunction() {
return t('use of new available function');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment