Collect all oids of the given types
@param $types The types to process
@note This is a callback method called on a matching work package @see BatchController::addWorkPackage()
347967
protected function collect($types) {
    $persistenceFacade = $this->getPersistenceFacade();
    $nodesPerCall = $this->getRequestValue('nodesPerCall');
    foreach ($types as $type) {
      $oids = $persistenceFacade->getOIDs($type);
      $oidLists = array_chunk($oids, self::OPTIMIZE_FREQ);
      for ($i=0, $count=sizeof($oidLists); $i<$count; $i++) {
        $this->addWorkPackage($this->getMessage()->getText('Indexing %0% %1% objects, starting from %2%., ', [sizeof($oids), $type, ($i*self::OPTIMIZE_FREQ+1)]),
                $nodesPerCall, $oidLists[$i], 'index');
        $this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
                1, [0], 'optimize');
      }
    }
  }
300532
public function addType(Type $type, $name = '')
    {
        if (!$name) {
            $name = (string)$type;
        }

        $this->types[$name] = $type;
    }
652076
function fetchAvailablePackages( $type = false )
    {
        $typeArray  = array();
        if ( $type )
            $typeArray['type'] = $type;

        $packageList = eZPackage::fetchPackages( array( 'db_available' => false ), $typeArray );

        return $packageList;
    }
569762
public function registerLookup($type, $lookups = [])
    {
        $lookups = (array) $lookups;

        $this->lookups[$type] = array_unique(array_merge($this->lookups[$type], $lookups));
    }
71415
protected function mergeAutoload($type, RootPackageInterface $root)
    {
        $getter = 'get' . ucfirst($type);
        $setter = 'set' . ucfirst($type);

        $autoload = $this->package->{$getter}();
        if (empty($autoload)) {
            return;
        }

        $unwrapped = self::unwrapIfNeeded($root, $setter);
        $unwrapped->{$setter}(array_merge_recursive(
            $root->{$getter}(),
            $this->fixRelativePaths($autoload)
        ));
    }
522170
public function setPackages(array $packages)
    {
        foreach ($packages as $name => $location) {
            if (is_array($location)) {
                if (array_key_exists('name', $location)
                    && array_key_exists('location', $location)) {
                        $name       = $location['name'];
                        $location   = $location['location'];
                    } else {
                        list($name, $location) = $location;
                    }
            }
            $this->addPackage($name, $location);
        }
    }
1082038
public function fromArray( $types )
	{
		$this->types			=& $types['types'];
		$this->attributes		=& $types['attributes'];
		$this->attributeGroups	=& $types['attributeGroups'];
		$this->elements			=& $types['elements'];
		$this->processedSchemas	=& $types['processedSchemas'];
		if ( isset( $types['typeIds'] ) )
		{
			$this->typeIds		=& $types['typeIds'];
		}

		// Prevent re-loading base types
		$this->baseTypesLoaded = true;

		return true;
	}
845286
protected function initImport($oids) {
    $message = $this->getMessage();

    // get document definition
    $type =  $this->getRequestValue('className');
    $docFile = $this->getRequestValue('uploadFile');
    $cacheSection = $this->getRequestValue('cacheSection');

    // get stats from cache
    $stats = $this->cache->get($cacheSection, self::CACHE_KEY_STATS);
    $this->getResponse()->setValue('stats', $stats);

    // oids are line numbers
    $oids = [];
    $file = new \SplFileObject($docFile);
    $file->seek(1); // skip header
    $eof = false;
    while (!$eof) {
      $content = $file->current();
      if (strlen(trim($content)) > 0) {
        $oids[] = $file->key();
      }
      $file->next();
      $eof = $file->eof();
    }

    // create work packages for nodes
    $nodesPerCall = $this->getRequestValue('nodesPerCall');
    $this->addWorkPackage(
            $message->getText('Importing %0%', [$type]),
            $nodesPerCall, $oids, 'importNodes');
  }
871766
public function process_children( $type ) {
		$this->struct[ $type ] = array_filter( $this->struct[ $type ], 'is_array' );
		foreach ( $this->struct[ $type ] as $sub_slug => $sub_structure ) {
			if ( ! empty( $sub_structure['id'] ) ) {
				$sub_slug = $sub_structure['id'];
			}

			$this->{$type}( $sub_slug, $sub_structure );
		}

	}
108894
public function addType(Type $type)
    {
        if ($type instanceof self) {
            foreach ($type->getTypes() as $subType) {
                $this->types[] = $subType;
            }

            return $this;
        }

        $this->types[] = $type;

        return $this;
    }
763929
public function getAllMethods($types = self::FULL_HIERARCHY) {
    if ($types & self::WITH_OWN) {
      $methods = clone $this->methods;
    } else {
      $methods = new GObjectCollection(array());
    }
    
    if ($types & self::WITH_PARENTS && $this->getParent() != NULL) {
      // treat duplicates (aka: overriden methods):
      $parentTypes = $types | self::WITH_OWN;
      foreach ($this->getParent()->getAllMethods($parentTypes) as $method) {
        if (!$methods->has($method)) {
          $methods->add($method);
        }
      }
    }

    $interfaceTypes = 0x000000;
    if ($types & self::WITH_INTERFACE) $interfaceTypes |= self::WITH_OWN;
    if ($types & self::WITH_PARENTS_INTERFACES) $interfaceTypes |= self::WITH_PARENTS;
    
    foreach ($this->getAllInterfaces($interfaceTypes) as $interface) {
      //$interface->elevateClass();
      // return only own interface methods, because we already have all interfaces from wohle hierarchy
      // or without parents, if we dont like to have the parents interfaces
      foreach ($interface->getMethods() as $method) { 
        if (!$methods->has($method)) {
          $methods->add($method);
        }
      }
    }
    
    return $methods->toArray();
  }
514682
public function getPackageDownloads($type)
    {
        $statsType = 'get' . ucfirst($type);
        if (($download = $this->getDownloads()) && $download instanceof \Packagist\Api\Result\Package\Downloads) {
            return $download->{$statsType}();
        }
    }
803475
public static function namesByType(array $types)
    {
        $names = array();

        foreach ($types as $type) {
            $names[] = self::nameByType($type);
        }

        return $names;
    }
435301
public function findNodesOfType(array $nodes, string $type): array
    {
        $collectedNodes = [];

        foreach ($nodes as $node) {
            if (is_array($node)) {
                $collectedNodes = array_merge(
                    $this->findNodesOfType($node, $type),
                    $collectedNodes
                );
            } elseif ($node instanceof Node) {
                if (is_a($node, $type, true)) {
                    $collectedNodes[] = $node;
                }

                $collectedNodes = array_merge(
                    $this->findNodesOfType(
                        AstHelper::getSubNodes($node),
                        $type
                    ),
                    $collectedNodes
                );
            }
        }

        return $collectedNodes;
    }
654270
public static function checkObjectTypeIs($o, $types)
    {
        foreach ($types as $type) {
            if ($o instanceof $type) {
                return;
            }
        }

        $oType = is_object($o) ? get_class($o) : gettype($o);
        throw new Exception("Invalid variable type '$oType', expected one of following: " . implode(', ', $types));
    }
206873
public function fetchAll($type = parent::FETCH_TYPE_NUM)
    {
        return array_map($this->_callback, $this->_statement->fetchAll($type));
    }
449701
public function addDuplicateLinks($type, array $packages)
    {
        if ( ! isset($this->duplicateLinks[$type])) {
            $this->duplicateLinks[$type] = [];
        }

        $this->duplicateLinks[$type] = array_merge(
            $this->duplicateLinks[$type],
            $packages
        );

        return $this;
    }