W3cubDocs

/Drupal 8

protected function ProxyBuilder::buildLazyLoadItselfMethod

protected ProxyBuilder::buildLazyLoadItselfMethod()

Generates the string for the method which loads the actual service.

Return value

string

File

core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php, line 179

Class

ProxyBuilder
Generates the string representation of the proxy service.

Namespace

Drupal\Component\ProxyBuilder

Code

protected function buildLazyLoadItselfMethod() {
  $output = <<<'EOS'
/**
 * Lazy loads the real service from the container.
 *
 * @return object
 *   Returns the constructed real service.
 */
protected function lazyLoadItself()
{
    if (!isset($this->service)) {
        $this->service = $this->container->get($this->drupalProxyOriginalServiceId);
    }

    return $this->service;
}

EOS;

  return $output;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!ProxyBuilder!ProxyBuilder.php/function/ProxyBuilder::buildLazyLoadItselfMethod/8.1.x