Hot answers tagged

3

The direct answer is quoting the Symfony documentation: In the service container, all services are shared by default. This means that each time you retrieve the service, you’ll get the same instance. This is usually the behavior you want, but in some cases, you might want to always get a new instance. In order to always get a new instance, set the shared ...


2

drupal_build_css_cache() is a Drupal 7 function that was removed very early in the Drupal 8 development cycle. The change notices back then weren't very good, so simply searching for that function name won't find anything. (Change notices may be found at https://www.drupal.org/list-changes). The relevant change notice is Pluggable CSS & JS preprocessing (...


2

It seems ultimately to be down to this code in EntityFormDisplay::processForm(): // Assign the weights configured in the form display. foreach ($this->getComponents() as $name => $options) { if (isset($element[$name])) { $element[$name]['#weight'] = $options['weight']; } } This method is a #process callback for the form which runs after form ...


2

Entity reference fields expect an entity ID, so unless you want to extend the field type (which could get unnecessarily messy), you'll need to get the ID of the target content. One method to do this is EntityStorageBase::loadByProperties(), e.g. $target_nodes = \Drupal::entityTypeManager()->getStorage('node') ->loadByProperties(['title' => 'CUN', '...


2

That wont do it. You either need to create a test module that has YAML configs to do this, or script in the changes in the test setup method. The latter method is longer, but frees you from having to maintain copies of YAML configs in an additional module(s). Here is an example. public function setUp() { parent::setUp(); $this->entityTypeManager ...


1

I don't think this is possible with concat in a single pipe, because you need to define two sources for concat, and AFAIK you can't fill the source partly with the result from the previous section and partly with a completely new value. Workaround: Use the str_replace plugin instead, which is a wrapper for PHP's preg_replace. preg_replace will detect if ...


Only top voted, non community-wiki answers of a minimum length are eligible