Пример #1
0
 public function getIndexItems($resource, Metadata $metadata, $properties = null)
 {
     $indexItems = [];
     $accessor = PropertyAccess::createPropertyAccessor();
     //walk over each field of the property that should get indexed
     foreach ($metadata->getProperties() as $propertyNode) {
         //get the right indexType
         $type = $this->collector->getType($propertyNode->getType());
         //get the IndexItems of the right IndexType
         $newIndexItems = $type->index($accessor->getValue($resource, $propertyNode->getProperty()), $propertyNode->getOptions(), $properties);
         if ($newIndexItems) {
             foreach ($newIndexItems as $indexItem) {
                 //set fieldname
                 if ((empty($properties) || in_array('fieldName', $properties)) && $indexItem->getFieldName() == null) {
                     $indexItem->setFieldName($metadata->getHumanizedBundleName() . '_' . strtolower($metadata->getEntityName() . '_' . strtolower($propertyNode->getProperty())));
                 }
                 $indexItems[] = $indexItem;
             }
         }
     }
     return $indexItems;
 }
Пример #2
0
 /**
  * Return the Type
  *
  * @param $type
  * @return TypeInterface
  */
 protected function getType($type)
 {
     return $this->collector->getType($type);
 }