예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function processRequest(Request $request, RouteMatchInterface $route_match, SerializerInterface $serializer)
 {
     $entity_type_id = $this->getDerivativeId();
     $start = 0;
     $limit = 30;
     if ($request->query->has('start') && is_numeric($request->query->get('start'))) {
         $start = $request->query->get('start');
     }
     if ($request->query->has('limit') && is_numeric($request->query->get('limit'))) {
         $limit = $request->query->get('limit');
     }
     $result = $this->queryFactory->get($entity_type_id, 'AND')->range($start, $limit)->execute();
     $map_function = function ($id) use($entity_type_id) {
         return $this->entityTypeManager->getStorage($entity_type_id)->load($id)->label();
     };
     return array_map($map_function, $result);
 }
예제 #2
0
 /**
  * Splices variant IDs into a list of migration IDs.
  *
  * IDs which match the template_id:* pattern are shorthand for every variant
  * of template_id. This method queries for those variant IDs and splices them
  * into the original list.
  *
  * @param string[] $ids
  *   A set of migration IDs.
  *
  * @return string[]
  *   The expanded list of IDs.
  */
 public function getVariantIds(array $ids)
 {
     // Re-index the array numerically, since we need to limit the loop by size.
     $ids = array_values($ids);
     $index = 0;
     while ($index < count($ids)) {
         if (substr($ids[$index], -2) == ':*') {
             $template_id = substr($ids[$index], 0, -2);
             $variants = $this->queryFactory->get($this->entityType, 'OR')->condition('id', $template_id)->condition('template', $template_id)->execute();
             array_splice($ids, $index, 1, $variants);
             $index += count($variants);
         } else {
             $index++;
         }
     }
     return $ids;
 }
예제 #3
0
 /**
  * Expands template dependencies.
  *
  * Migration dependencies which match the template_id:* pattern are a signal
  * that the migration depends on every variant of template_id. This method
  * queries for those variant IDs and splices them into the list of
  * dependencies.
  *
  * @param array $dependencies
  *   The original migration dependencies (with template IDs), organized by
  *   group (required, optional, etc.)
  *
  * @return array
  *   The expanded list of dependencies, organized by group.
  */
 protected function expandDependencies(array $dependencies)
 {
     $expanded_dependencies = [];
     foreach (array_keys($dependencies) as $group) {
         $expanded_dependencies[$group] = [];
         foreach ($dependencies[$group] as $dependency_id) {
             if (substr($dependency_id, -2) == ':*') {
                 $template_id = substr($dependency_id, 0, -2);
                 $variants = $this->queryFactory->get($this->entityType, 'OR')->condition('id', $template_id)->condition('template', $template_id)->execute();
                 $expanded_dependencies[$group] = array_merge($expanded_dependencies[$group], $variants);
             } else {
                 $expanded_dependencies[$group][] = $dependency_id;
             }
         }
     }
     return $expanded_dependencies;
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 protected function exists($value)
 {
     // Plugins are cached so for every run we need a new query object.
     return $this->entityQueryFactory->get($this->configuration['entity_type'], 'AND')->condition($this->configuration['field'], $value)->count()->execute();
 }