Get the departments to migrate.

@return \Illuminate\Support\Collection|mixed
964579
protected function departments()
    {
        //Avoid using FOL because is a transversal department
        if ( ! $this->filtersAppliedToDepartments()) return $this->validateCollection(Department::whereNotIn('department_id', [3])->get());
        if ( ! is_numeric($this->filters[1]) )  throw new \InvalidArgumentException();
        return collect([Department::findOrFail(intval($this->filters[1]))]);
    }
163625
public function getChildren()
    {
        return $this->owner
            ->hasMany($this->ownerClassName, [ $this->parentIdField => $this->primaryKey ])
            ->orderBy([
                "$this->tableName.$this->sortField" => SORT_ASC,
                "$this->tableName.$this->primaryKey" => SORT_ASC,
            ]);
    }
59844
public function getCategoryIds()
    {
        return array_keys((new CmsCategoryRelationQuery)
                ->join('cms_category')->on('cms_category_id')
                ->whereObject()->equals($this->_object)
                ->andFieldObjectId()->equals($this->_objectId)
                ->findPairs('cms_category.id', 'cms_category.id'));
    }
28659
public function getCategoryCollection()
    {
        $collection = parent::getCategoryCollection();

        // Previous call to $this->getRootByIds() will exclude all other category trees but keep their root.
        // Now we exclude all root categories except root associated to the current one.
        if ($this->getCurrentCategory()) {
            $rootPath      = array_slice($this->getCurrentCategory()->getPathIds(), 0, 2);
            $pathCondition = implode('/', $rootPath) . '%';
            $collection->addFieldToFilter('path', ['like' => $pathCondition]);

            // We also exclude current category, to prevent inception.
            $collection->addFieldToFilter('entity_id', ['neq' => $this->getCurrentCategory()->getId()]);

            // Overwrite collection already set in parent call.
            $this->setData('category_collection', $collection);
        }

        return $collection;
    }
234829
public function getMigratedVersions()
    {
        $this->createMigrationCollection();

        $cursor = $this->getCollection()->find();
        $versions = [];
        foreach ($cursor as $record) {
            $versions[] = $record['v'];
        }

        return $versions;
    }
87386
public function getManagedAbilities(): Collection
    {
        $abilities = $this->isA('superadmin') ? app('cortex.auth.ability')->all() : $this->getAbilities();

        return $abilities->groupBy('entity_type')->map->pluck('title', 'id')->sortKeys();
    }
1300571
protected function getListCollection()
    {
        $conditions = $this->query_filter;
        $conditions['limit'] = $this->data_limit;

        return (array) $this->collection->getList($conditions);
    }
383145
public function getMapCategoriesByBranch() {
    $cid = __METHOD__;
    if ($cache = $this->cache->get($cid)) {
      return $cache->data;
    }

    $locations = $this->getLocations();
    $data = [];
    foreach ($locations as $location_id => $location_name) {
      $link = $this->getUrlFromOpenyProgramsSearchSettings('get_map_categories_by_branch_path', ['{{ branch_id }}' => $location_id]);
      $data[$location_id] = $this->scrapeCategoryList($link);
    }

    $this->cache->set($cid, $data);
    return $data;
  }
52481
protected function getApplyOperation()
    {
        if (!isset($this->applyOperation)) {
            $this->applyOperation = new \Tripod\Mongo\Jobs\ApplyOperation();
        }
        return $this->applyOperation;
    }
923084
protected function getNewMigrations()
    {
        $applied = [];

        foreach ($this->getMigrationHistory(null) as $version => $time) {
            $applied[substr($version, 1, 13)] = true;
        }

        $migrations = [];
        $handle = opendir($this->migrationPath);

        while (($file = readdir($handle)) !== false) {
            if ($file === '.' || $file === '..') {
                continue;
            }

            $path = $this->migrationPath . DIRECTORY_SEPARATOR . $file;

            if (preg_match('/^(m(\d{6}_\d{6})_.*?)\.php$/', $file, $matches)
                && !isset($applied[$matches[2]]) && is_file($path)) {
                $migrations[] = $matches[1];
            }
        }

        closedir($handle);
        sort($migrations);

        return $migrations;
    }
970297
private function getCategoryCollection()
    {
        $categoryCollection = null;

        $suggestedTerms = $this->getSuggestedTerms();
        $terms          = [$this->queryFactory->get()->getQueryText()];

        if (!empty($suggestedTerms)) {
            $terms = array_merge($terms, $suggestedTerms);
        }

        $categoryCollection = $this->categoryCollectionFactory->create();
        $categoryCollection->addAttributeToSelect("is_active");
        $categoryCollection->setSearchQuery($terms);
        $categoryCollection->setPageSize($this->getResultsPageSize());

        return $categoryCollection;
    }
685289
protected function getMigrationFiles()
    {
        $directoryIterator = new \DirectoryIterator($this->directory);
        $migrationFiles = [];
        foreach ($directoryIterator as $fileInfo) {
            /** @var \SplFileInfo $fileInfo */
            if ($fileInfo->isFile()) {
                if (preg_match($this->filePattern, $fileInfo->getRealPath())) {
                    $migrationFiles[] = $fileInfo->getRealPath();
                } else {
                    $context = [
                        'path' => $fileInfo->getRealPath(),
                    ];

                    $this->getLogger()->notice(
                        self::MESSAGE__FOUND_UNSUPPORTED_FILE__PATH,
                        $context
                    );
                }
            }
        }
        sort($migrationFiles);

        if (empty($migrationFiles)) {
            $context = [
                'path' => $this->directory,
                'pattern' => $this->filePattern,
            ];

            $this->getLogger()->warning(
                self::MESSAGE__THERE_IS_NOTHING_MATCHING_PATTERN__PATH_PATTERN,
                $context
            );
        }

        $this->getLogger()->info(
            self::MESSAGE__FOUND_MIGRATION_FILES__COUNT_PATH_PATTERN,
            [
                'count' => count($migrationFiles),
                'path' => $this->directory,
                'pattern' => $this->filePattern,
            ]
        );

        return $migrationFiles;
    }
1340327
public function getCategories()
    {
        // Set method and action
        $method = 'import';
        $action = 'getSupplierCategories';

        // Set data
        $data = array();

        // Send request and retrieve response
        $result = Dispatcher::send($method, $action, $data);

        return $result;
    }
981712
public function getMigrations( )
    {
        $migrations = array();
        
        $dir = opendir( $this->migrationPath );
        
        while ( ( $file = readdir( $dir ) ) !== FALSE )
        {
            if ( '.' !== $file && '..' !== $file )
            {
                $migrations[] = str_replace( '.php', '', $file );
            }
        }
        
        closedir( $dir );
        
        usort( $migrations, array( $this, '_sortMigrations' ) );
        
        return $this->filter( self::ON_GET_MIGRATIONS_FILTER, $migrations );
    }
87167
public function getObjects()
    {
        $objects = array();
        foreach ($this->resourceManager->getCollectionsByStorage($this) as $collection) {
            $objects = array_merge($objects, $this->getObjectsByCollection($collection));
        }

        return $objects;
    }
646365
public function getCollection()
    {
        if ($this->parent) {
            return $this->parent->getCollection();
        }

        if (!is_object($this->_collection)) {
            $action = $this->controller->action;
            if ($action instanceof self) {
                $scenario = $action->getScenario();
            } else {
                $scenario = $action->id;
            }

            $this->_collection = Yii::createObject(ArrayHelper::merge([
                'class' => Collection::class,
                'model' => $this->controller->newModel(['scenario' => $scenario]),
                'scenario' => $scenario,
                'queryOptions' => $this->queryOptions,
            ], (array) $this->_collection));
        }

        return $this->_collection;
    }
47933
protected function getCollection(): Collection
    {
        $conn = $this->connPool->getConnection();
        $database = $conn->defaultDatabase;
        $collection = $this->schema->collection;

        return $conn->getRawConnection()->$database->$collection;
    }