protected function findActiveVersionByLocator(LocatorInterface $locator)
    {
        $criteria = new Criteria();
        $criteria->where(
            $criteria->expr()->in(
                'status',
                [VersionStatuses::PUBLISHED, VersionStatuses::DEPUBLISHED]
            )
        );
        foreach ($locator->toArray() as $column => $value) {
            $criteria->andWhere($criteria->expr()->eq($column, $value));
        }
        $criteria->orderBy(['id' => Criteria::DESC]);
        $criteria->setMaxResults(1);

        $entities = $this->entityManger->getRepository($this->entityClassName)->matching($criteria)->toArray();

        if (isset($entities[0])) {
            return $entities[0];
        }

        return null;
    }
protected function findActiveVersionByLocator(LocatorInterface $locator)
    {
        $criteria = new Criteria();
        $criteria->where(
            $criteria->expr()->in(
                'status',
                [VersionStatuses::PUBLISHED, VersionStatuses::DEPUBLISHED]
            )
        );
        foreach ($locator->toArray() as $column => $value) {
            $criteria->andWhere($criteria->expr()->eq($column, $value));
        }
        $criteria->orderBy(['id' => Criteria::DESC]);
        $criteria->setMaxResults(1);

        $entities = $this->entityManger->getRepository($this->entityClassName)->matching($criteria)->toArray();

        if (isset($entities[0])) {
            return $entities[0];
        }

        return null;
    }
protected function findActiveVersionByLocator ( LocatorInterface $ locator ) { $ criteria = new Criteria ( ) ; $ criteria -> where ( $ criteria -> expr ( ) -> in ( 'status' , [ VersionStatuses :: PUBLISHED , VersionStatuses :: DEPUBLISHED ] ) ) ; foreach ( $ locator -> toArray ( ) as $ column => $ value ) { $ criteria -> andWhere ( $ criteria -> expr ( ) -> eq ( $ column , $ value ) ) ; } $ criteria -> orderBy ( [ 'id' => Criteria :: DESC ] ) ; $ criteria -> setMaxResults ( 1 ) ; $ entities = $ this -> entityManger -> getRepository ( $ this -> entityClassName ) -> matching ( $ criteria ) -> toArray ( ) ; if ( isset ( $ entities [ 0 ] ) ) { return $ entities [ 0 ] ; } return null ; }
Find the "active" version which means the most recent version that is either
"published" or "depublished" while ignoring "unpublished" versions

@param LocatorInterface $locator
@return VersionEntityInterface | null
Find the active version which means the most recent version that is either published or depublished while ignoring unpublished versions