original_string: public function isSmart(AdminInterface $admin, array $values = [])
      {
          // first : validate if elastica is asked in the configuration for this action
          $logicalControllerName = $admin->getRequest()->attributes->get('_controller');
          $currentAction = explode(':', $logicalControllerName);
          // remove Action from 'listAction'
          $currentAction = substr(end($currentAction), 0, -\strlen('Action'));
          // in case of batch|export action, no need to elasticsearch
          if (!\in_array($currentAction, $this->finderProvider->getActionsByAdmin($admin), true)) {
              return false;
          }
  
          // Get mapped field names
          $finderId = $this->finderProvider->getFinderIdByAdmin($admin);
  
          // Assume that finder id is composed like this 'fos_elastica.finder.<index name>.<type name>
          list($indexName, $typeName) = \array_slice(explode('.', $finderId), 2);
          $typeConfiguration = $this->configManager->getTypeConfiguration($indexName, $typeName);
          $mapping = $typeConfiguration->getMapping();
          $mappedFieldNames = array_keys($mapping['properties']);
  
          // Compare to the fields on wich the search apply
          $smart = true;
  
          foreach ($values as $key => $value) {
              if (!\is_array($value) || !isset($value['value'])) {
                  // This is not a filter field
                  continue;
              }
  
              if (!$value['value']) {
                  // No value set on the filter field
                  continue;
              }
  
              if (!\in_array($key, $mappedFieldNames, true)) {
                  /*
                   * We are in the case where a field is used as filter
                   * without being mapped in elastic search.
                   * An ugly case would be to have a custom field used in the filter
                   * without mapping in the model, we need to control that
                   */
                  $ret = $admin->getModelManager()->getParentMetadataForProperty(
                      $admin->getClass(),
                      $key,
                      $admin->getModelManager()
                  );
  
                  list($metadata, $propertyName, $parentAssociationMappings) = $ret;
                  //Case if a filter is used in the filter but not linked to the ModelManager ("mapped" = false ) case
                  if (!$metadata->hasField($key)) {
                      break;
                  }
                  // This filter field is not mapped in elasticsearch
                  // so we cannot use elasticsearch
                  $smart = false;
  
                  break;
              }
          }
  
          return $smart;
      }
code: public function isSmart(AdminInterface $admin, array $values = [])
      {
          // first : validate if elastica is asked in the configuration for this action
          $logicalControllerName = $admin->getRequest()->attributes->get('_controller');
          $currentAction = explode(':', $logicalControllerName);
          // remove Action from 'listAction'
          $currentAction = substr(end($currentAction), 0, -\strlen('Action'));
          // in case of batch|export action, no need to elasticsearch
          if (!\in_array($currentAction, $this->finderProvider->getActionsByAdmin($admin), true)) {
              return false;
          }
  
          // Get mapped field names
          $finderId = $this->finderProvider->getFinderIdByAdmin($admin);
  
          // Assume that finder id is composed like this 'fos_elastica.finder.<index name>.<type name>
          list($indexName, $typeName) = \array_slice(explode('.', $finderId), 2);
          $typeConfiguration = $this->configManager->getTypeConfiguration($indexName, $typeName);
          $mapping = $typeConfiguration->getMapping();
          $mappedFieldNames = array_keys($mapping['properties']);
  
          // Compare to the fields on wich the search apply
          $smart = true;
  
          foreach ($values as $key => $value) {
              if (!\is_array($value) || !isset($value['value'])) {
                  // This is not a filter field
                  continue;
              }
  
              if (!$value['value']) {
                  // No value set on the filter field
                  continue;
              }
  
              if (!\in_array($key, $mappedFieldNames, true)) {
                  /*
                   * We are in the case where a field is used as filter
                   * without being mapped in elastic search.
                   * An ugly case would be to have a custom field used in the filter
                   * without mapping in the model, we need to control that
                   */
                  $ret = $admin->getModelManager()->getParentMetadataForProperty(
                      $admin->getClass(),
                      $key,
                      $admin->getModelManager()
                  );
  
                  list($metadata, $propertyName, $parentAssociationMappings) = $ret;
                  //Case if a filter is used in the filter but not linked to the ModelManager ("mapped" = false ) case
                  if (!$metadata->hasField($key)) {
                      break;
                  }
                  // This filter field is not mapped in elasticsearch
                  // so we cannot use elasticsearch
                  $smart = false;
  
                  break;
              }
          }
  
          return $smart;
      }
code_tokens: public function isSmart ( AdminInterface $ admin , array $ values = [ ] ) { // first : validate if elastica is asked in the configuration for this action $ logicalControllerName = $ admin -> getRequest ( ) -> attributes -> get ( '_controller' ) ; $ currentAction = explode ( ':' , $ logicalControllerName ) ; // remove Action from 'listAction' $ currentAction = substr ( end ( $ currentAction ) , 0 , - \ strlen ( 'Action' ) ) ; // in case of batch|export action, no need to elasticsearch if ( ! \ in_array ( $ currentAction , $ this -> finderProvider -> getActionsByAdmin ( $ admin ) , true ) ) { return false ; } // Get mapped field names $ finderId = $ this -> finderProvider -> getFinderIdByAdmin ( $ admin ) ; // Assume that finder id is composed like this 'fos_elastica.finder.<index name>.<type name> list ( $ indexName , $ typeName ) = \ array_slice ( explode ( '.' , $ finderId ) , 2 ) ; $ typeConfiguration = $ this -> configManager -> getTypeConfiguration ( $ indexName , $ typeName ) ; $ mapping = $ typeConfiguration -> getMapping ( ) ; $ mappedFieldNames = array_keys ( $ mapping [ 'properties' ] ) ; // Compare to the fields on wich the search apply $ smart = true ; foreach ( $ values as $ key => $ value ) { if ( ! \ is_array ( $ value ) || ! isset ( $ value [ 'value' ] ) ) { // This is not a filter field continue ; } if ( ! $ value [ 'value' ] ) { // No value set on the filter field continue ; } if ( ! \ in_array ( $ key , $ mappedFieldNames , true ) ) { /*
                   * We are in the case where a field is used as filter
                   * without being mapped in elastic search.
                   * An ugly case would be to have a custom field used in the filter
                   * without mapping in the model, we need to control that
                   */ $ ret = $ admin -> getModelManager ( ) -> getParentMetadataForProperty ( $ admin -> getClass ( ) , $ key , $ admin -> getModelManager ( ) ) ; list ( $ metadata , $ propertyName , $ parentAssociationMappings ) = $ ret ; //Case if a filter is used in the filter but not linked to the ModelManager ("mapped" = false ) case if ( ! $ metadata -> hasField ( $ key ) ) { break ; } // This filter field is not mapped in elasticsearch // so we cannot use elasticsearch $ smart = false ; break ; } } return $ smart ; }
docstring: Returns true if this datagrid builder can process these values.
docstring_tokens: Returns true if this datagrid builder can process these values .