Пример #1
0
 /**
  * Checks whether a property path represents some metadata property
  *
  * @param string $propertyPath
  *
  * @return bool
  */
 public function isMetadataProperty($propertyPath)
 {
     return ConfigUtil::isMetadataProperty($propertyPath);
 }
Пример #2
0
 /**
  * @param QueryBuilder $qb
  * @param array        $config
  *
  * @return Query
  */
 public function getQuery(QueryBuilder $qb, $config)
 {
     $query = $qb->getQuery();
     $this->queryHintResolver->resolveHints($query, ConfigUtil::getArrayValue($config, ConfigUtil::HINTS));
     return $query;
 }
Пример #3
0
 /**
  * @param mixed $fieldConfig
  *
  * @return bool
  */
 protected function isExcludedField($fieldConfig)
 {
     return null !== $fieldConfig && ConfigUtil::isExclude($fieldConfig);
 }
Пример #4
0
 /**
  * @param array $entityIds
  * @param array $mapping
  * @param array $config
  *
  * @return array [entityId => [field => value, ...], ...]
  */
 protected function loadRelatedItemsForSimpleEntity($entityIds, $mapping, $config)
 {
     $qb = $this->queryFactory->getToManyAssociationQueryBuilder($mapping, $entityIds);
     foreach (ConfigUtil::getArrayValue($config, ConfigUtil::ORDER_BY) as $field => $order) {
         $qb->addOrderBy(sprintf('r.%s', $field), $order);
     }
     $fields = $this->fieldAccessor->getFieldsToSerialize($mapping['targetEntity'], $config);
     foreach ($fields as $field) {
         $qb->addSelect(sprintf('r.%s', $field));
     }
     $items = $this->queryFactory->getQuery($qb, $config)->getArrayResult();
     $result = [];
     $entityClass = $mapping['targetEntity'];
     if (isset($config[ConfigUtil::POST_SERIALIZE])) {
         $callback = $config[ConfigUtil::POST_SERIALIZE];
         foreach ($items as $item) {
             $result[$item['entityId']][] = $this->postSerialize($this->serializeItem($item, $entityClass, $config), $callback);
         }
     } else {
         foreach ($items as $item) {
             $result[$item['entityId']][] = $this->serializeItem($item, $entityClass, $config);
         }
     }
     return $result;
 }