Find Published Collection Page By Slug

Finds collection page by collection slug and page slug
@param  bool  $published Filter on published collection pages
@return mixed            Array | null
506572
public function findPublishedCollectionPageBySlug($collectionSlug, $pageSlug)
    {
        $this->makeCollectionPageSelect();
        $this->sql .= " and p.published_date <= '{$this->today()}'";
        $this->sql .= ' and c.slug = ? and p.slug = ?';

        $this->bindValues[] = $collectionSlug;
        $this->bindValues[] = $pageSlug;

        return $this->findRow();
    }
147420
public static function findPublishedByNews($newsId)
    {
        if (0 === \count($ids = Model::getRelatedValues('tl_news', 'categories', $newsId))) {
            return null;
        }

        $t = static::getTableAlias();
        $columns = ["$t.id IN (".\implode(',', \array_map('intval', \array_unique($ids))).')'];
        $values = [];

        if (!BE_USER_LOGGED_IN) {
            $columns[] = "$t.published=?";
            $values[] = 1;
        }

        return static::findBy($columns, $values, ['order' => "$t.sorting"]);
    }
633003
public function getPublishedOrderedChildren($perPage = null)
    {
        $children = $this->children()
            ->published();

        $this->determineChildrenSorting($children);

        return $this->determineChildrenPagination($perPage, $children);
    }
638513
public function findOneBy($filters, $inDeleted = false)
    {
        $qb = $this->db->createQueryBuilder();

        $qb->select($this->getSelect($this->profile))
            ->from($this->table, 't')
            ->where('1 = 1');

        $this->addJoins($qb, $this->getJoins($this->profile));
        $params = $this->addFilters($qb, $this->getFilters($this->profile));
        $params = array_merge($params, $this->addFilters($qb, $filters));

        return $this->getRow($qb, $params, $inDeleted);
    }
937438
public function getPublishedAt()
    {
        if ($this->status == PageStatus::PUBLISHED && $this->publishedAt === null) {
            $this->setPublishedAt($this->getCreatedAt());
        }

        return $this->publishedAt;
    }
109250
public function count($filter = null)
    {
        if (is_null($filter)) {
            return $this->_countObjectsInCollection();
        } else if (is_string($filter)) {
            json_decode($filter);
            $isJson = (json_last_error() === JSON_ERROR_NONE) ? true :false;
            if ($isJson) {
                $filter = new Filter($filter);
                return $this->_countObjectsInCollectionByFilter($filter);
            }
        } else if (is_object($filter) && $filter instanceof Filter) {
            return $this->_countObjectsInCollectionByFilter($filter);
        }
        return 0;
    }
971168
public static function findFirst(Filter ...$filters)
    {
        $results = static::find(...$filters);

        if (sizeof($results) == 0) {
            throw new RecordNotFoundException(get_called_class(), 0);
        }

        return $results[0];
    }
551177
public function findEntities(Request $request, $filters = array(), $addPagination = false)
    {
        $options = $this->getOptions($request, $filters, $addPagination);
        if (!$addPagination) {
            return array(
                'entities' => $this->getRepository()->getEntities($options),
                'options' => $options
            );
        }

        $entities = $this->getRepository()->getPaginatedEntities($options);
        $options['elements'] = $entities->count();
        $options['pages'] = (int)ceil($options['elements'] / $options['elementsPerPage']);

        return array(
            'entities' => $entities,
            'options' => $options
        );
    }
1187259
public function find($filter = NULL, array $options = NULL, $ttl = 0) {
		$sort=false;
		if ($this->dbsType!='sql') {
			// see if reordering is needed
			foreach($this->countFields?:[] as $counter) {
				if ($options && isset($options['order']) &&
					preg_match('/count_'.$counter.'\h+(asc|desc)/i',$options['order'],$match))
					$sort=true;
			}
			if ($sort) {
				// backup slice settings
				if (isset($options['limit'])) {
					$limit = $options['limit'];
					unset($options['limit']);
				}
				if (isset($options['offset'])) {
					$offset = $options['offset'];
					unset($options['offset']);
				}
			}
		}
		$this->_ttl=$ttl?:$this->rel_ttl;
		$result = $this->filteredFind($filter,$options,$ttl);
		if (empty($result))
			return false;
		foreach($result as &$record) {
			$record = $this->factory($record);
			unset($record);
		}
		// add counter for NoSQL engines
		foreach($this->countFields?:[] as $counter)
			foreach($result as &$mapper) {
				$cr=$mapper->get($counter);
				$mapper->virtual('count_'.$counter,$cr?count($cr):null);
				unset($mapper);
			}
		$cc = new CortexCollection();
		$cc->setModels($result);
		if($sort) {
			$cc->orderBy($options['order']);
			$cc->slice(isset($offset)?$offset:0,isset($limit)?$limit:NULL);
		}
		$this->clearFilter();
		return $cc;
	}
1334251
public function findByUnique($criteria)
    {
        if (!isset($criteria['slug'])) {
            return null;
        }

        return $this->_em->createQueryBuilder()
            ->select('p')
            ->from('VeonikBlogBundle:AbstractPost', 'p')
            ->where('p.slug = :slug')
            ->setParameter('slug', $criteria['slug'])
            ->getQuery()
            ->getResult();
    }
1301319
private function getPublishedCampaigns($campaignId = null)
    {
        if (!$this->publishedCampaigns) {
            foreach ($this->campaignModel->getPublishedCampaigns(true) as $campaign) {
                $this->publishedCampaigns[$campaign['id']] = $campaign['name'];
            }
        }

        if ($campaignId) {
            return isset($this->publishedCampaigns[$campaignId]) ? $this->publishedCampaigns[$campaignId] : null;
        } else {
            return $this->publishedCampaigns;
        }
    }
1275139
public function getPost( $slug ) {

		// Supported post names (ie. slugs)
		$supported = array_keys( $this->supported );
		if ( ! in_array( $slug, $supported, true ) ) {
			return false;
		}

		$args = [
			'name' => $slug,
			'post_type' => 'custom-style',
			'posts_per_page' => 1,
			'post_status' => 'publish',
			'orderby' => 'modified',
			'no_found_rows' => true,
			'cache_results' => true,
		];

		$q = new \WP_Query();
		$results = $q->query( $args );

		if ( empty( $results ) ) {
			return false;
		}

		return $results[0];
	}
49453
public function withFilter(Filter $filter)
    {
        if ($this->value->isNull()) {
            return null;
        }

        return $this->applyFilter($filter);
    }
180776
private function getCriteria(array $archives, $featured, ModuleNewsList $module)
    {
        try {
            $criteria = $this->searchBuilder->getCriteriaForListModule($archives, $featured, $module);
        } catch (CategoryNotFoundException $e) {
            throw new PageNotFoundException($e->getMessage());
        }

        return $criteria;
    }
1063411
public function listTemplates($filter = null)
    {
        $files = [];

        $name = $filter ? Glob::toRegex($filter, false, false) : '/^[a-zA-Z0-9]\V+\.twig$/';

        /** @var Finder|FileInterface[] $finder */
        $finder = $this->templatesDir->find()
            ->files()
            ->notName('/^_/')
            ->exclude(['node_modules', 'bower_components', '.sass-cache'])
            ->depth('<4')
            ->path($name)
            ->sortByName()
        ;

        foreach ($finder as $file) {
            $name = Str::replaceFirst($file->getFullPath(), $this->templatesDir->getFullPath(), '');
            $files[$name] = $name;
        }

        // Check: Have we defined names for any of the matched templates?
        foreach ((array) $this->themeTemplateSelect as $templateFile) {
            if (!empty($templateFile['name']) && !empty($templateFile['filename']) && in_array($templateFile['filename'], $files)) {
                $files[$templateFile['filename']] = $templateFile['name'];
            }
        }

        return $files;
    }
934165
public function search(AdminInterface $admin, $term, $page = 0, $offset = 20)
    {
        $datagrid = $admin->getDatagrid();

        $found = false;
        foreach ($datagrid->getFilters() as $filter) {
            /** @var $filter FilterInterface */
            if ($filter->getOption('global_search', false)) {
                $filter->setOption('case_sensitive', $this->caseSensitive);
                $filter->setCondition(FilterInterface::CONDITION_OR);
                $datagrid->setValue($filter->getFormName(), null, $term);
                $found = true;
            }
        }

        if (!$found) {
            return false;
        }

        $datagrid->buildPager();

        $pager = $datagrid->getPager();
        $pager->setPage($page);
        $pager->setMaxPerPage($offset);
        $pager->init();

        return $pager;
    }
316259
public function findPublishedPageBySlug($pageSlug)
    {
        $this->makeSelect();

        if (is_string($pageSlug)) {
            $this->sql .= ' and collection_id is null and slug = ?';
            $this->bindValues[] = $pageSlug;
        } else {
            throw new Exception('Unknown page identifier type');
        }

        $this->sql .= " and published_date <= '{$this->today()}'";

        return $this->findRow();
    }