0

I have an Acquia Cloud hosted site built on Drupal 8.4.3. Using Acquia Dev Desktop and Drush, I updated a local development environment to Drupal 8.4.5.

Immediately after Drush updated the site, I got this error in the Apache log and the dreaded white screen of death.

Service 'twig_extensions.twig.array' for consumer 'twig' does not implement Twig_ExtensionInterface. in /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php on line 164
0 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php(97): Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass->processServiceCollectorPass(Array, 'twig', Object(Drupal\Core\DependencyInjection\ContainerBuilder))
1 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/vendor/symfony/dependency-injection/Compiler/Compiler.php(120): Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass->process(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
2 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(573): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
3 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/core/lib/Drupal/Core/DrupalKernel.php(1307): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
4 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/core/lib/Drupal/Core/DrupalKernel.php(884): Drupal\Core\DrupalKernel->compileContainer()
5 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/core/lib/Drupal/Core/DrupalKernel.php(466): Drupal\Core\DrupalKernel->initializeContainer()
6 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/core/lib/Drupal/Core/DrupalKernel.php(656): Drupal\Core\DrupalKernel->boot()
7 /Users/iamtheghost/Sites/devdesktop/ukhealthcare-dev/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
8 {main}

I was trying to install the latest version of the Twig module. No change. TwigArray.php looks fine. Any help with this is greatly appreciated.

The content of the /core/modules/contrib/bamboo_twig/bamboo_twig_extensions/src/TwigArray.php file is the following.

namespace Drupal\bamboo_twig_extensions\TwigExtension;

/**
 * Provides bridge for Array functions and filters.
 *
 * Expose the features of Twig_Extensions_Extension_Array.
 */
class TwigArray extends \Twig_Extension {

  /**
   * List of all Twig functions.
   */
  public function getFilters() {
    return [
      new \Twig_SimpleFilter('bamboo_extensions_shuffle', [$this, 'shuffle']),
    ];
  }

  /**
   * Unique identifier for this Twig extension.
   */
  public function getName() {
    return 'bamboo_twig_extensions.twig.array';
  }

  /**
   * Shuffles an array.
   *
   * Can't use the Twig filter callback cause the shuffle function is
   * actually declared as a global function and not method of
   * Twig_Extensions_Extension_Array.
   *
   * @param array|\Traversable $iterator
   *   An array.
   *
   * @return array|bool
   *   The shuffled array; or FALSE on failure.
   */
  public function shuffle($iterator) {
    $extension = new \Twig_Extensions_Extension_Array();
    $filters = $extension->getFilters();

    foreach ($filters as $filter) {
      if ($filter->getName() == 'shuffle') {
        $callable = $filter->getCallable();
        return $callable($iterator);
      }
    }

    return FALSE;
  }

}
  • It probably means the maintainer of that module has moved the service class and your autoloader hasn't caught up (that error message is misleading, it actually means PHP can't find the class). Run composer dump-autoload then try again – Clive Mar 23 '18 at 16:34
  • @Clive I ran that but it doesn't appear to do anything. Here's the output from my terminal. Jordans-MacBook-Pro:docroot iamtheghost$ composer dump-autoload Generating autoload files > Drupal\Core\Composer\Composer::preAutoloadDump > Drupal\Core\Composer\Composer::ensureHtaccess – Jordan J. Mar 23 '18 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.