understanding entityAutoComplete code

I have an objective to create a custom FormElement, referencing EntityAutoComplete element.

Reason is: i like to build something similiar like EntityAutoComplete, but source of data is diffrent (from my own database source - not related with Drupal DB)

so to achieve that, i decide to make custom element, based on EntityAutoComplete.

I have a couple questions:

  1. in the process function we see this:

// Store the selection settings in the key/value store and pass a hashed key in the route parameters. $selection_settings = isset($element['#selection_settings']) ? $element['#selection_settings'] : []; $data = serialize($selection_settings) . $element['#target_type'] . $element['#selection_handler']; $selection_settings_key = Crypt::hmacBase64($data, Settings::getHashSalt()); $key_value_storage = \Drupal::keyValue('element_autocomplete'); if (!$key_value_storage->has($selection_settings_key)) { $key_value_storage->set($selection_settings_key, $selection_settings); }

what is the purpose of: $selection_settings ?

  1. in route class we see:

    public function __construct(EntityAutocompleteMatcher $matcher, KeyValueStoreInterface $key_value) { $this->matcher = $matcher; $this->keyValue = $key_value; }

I don't need EntityAutocompleteMatcher because that class is a class to get the entity which i'm going to replace with my own class but i still need KeyValueStoreInterface to match with the key that stored in the key store (point 1.)

question: how is the _contruct for base controller work? because if i modified the parameter it'll giving me the error

  1. and last question: in route class we have:

public static function create(ContainerInterface $container) { return new static( $container->get('entity.autocomplete_matcher'), $container->get('keyvalue')->get('element_autocomplete') ); } what is this create function generally for?

Thank you


Category: 8 Time: 2016-07-29 Views: 0
Tags: autocomplete

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.102 (s). 12 q(s)