public function generateListBlogPostCriterion(Location $location, array $viewParameters, array $languages = array())
    {
        $criteria = array();
        $criteria[] = new Criterion\Visibility(Criterion\Visibility::VISIBLE);
        $criteria[] = new Criterion\Subtree($location->pathString);
        $criteria[] = new Criterion\ContentTypeIdentifier(array('blog_post'));
        $criteria[] = new Criterion\LanguageCode($languages);

        if (!empty($viewParameters)) {
            if (!empty($viewParameters['month']) && !empty($viewParameters['year'])) {
                // Generating the criterion for the given month/year
                $month = (int)$viewParameters['month'];
                $year = (int)$viewParameters['year'];

                $date = new DateTime("$year-$month-01");
                $date->setTime(00, 00, 00);

                $criteria[] = new Criterion\DateMetadata(
                    Criterion\DateMetadata::CREATED,
                    Criterion\Operator::BETWEEN,
                    array(
                        $date->getTimestamp(),
                        $date->add(new DateInterval('P1M'))->getTimestamp(),
                    )
                );
            }
        }

        return new Criterion\LogicalAnd($criteria);
    }
public function generateListBlogPostCriterion(Location $location, array $viewParameters, array $languages = array())
    {
        $criteria = array();
        $criteria[] = new Criterion\Visibility(Criterion\Visibility::VISIBLE);
        $criteria[] = new Criterion\Subtree($location->pathString);
        $criteria[] = new Criterion\ContentTypeIdentifier(array('blog_post'));
        $criteria[] = new Criterion\LanguageCode($languages);

        if (!empty($viewParameters)) {
            if (!empty($viewParameters['month']) && !empty($viewParameters['year'])) {
                // Generating the criterion for the given month/year
                $month = (int)$viewParameters['month'];
                $year = (int)$viewParameters['year'];

                $date = new DateTime("$year-$month-01");
                $date->setTime(00, 00, 00);

                $criteria[] = new Criterion\DateMetadata(
                    Criterion\DateMetadata::CREATED,
                    Criterion\Operator::BETWEEN,
                    array(
                        $date->getTimestamp(),
                        $date->add(new DateInterval('P1M'))->getTimestamp(),
                    )
                );
            }
        }

        return new Criterion\LogicalAnd($criteria);
    }
public function generateListBlogPostCriterion ( Location $ location , array $ viewParameters , array $ languages = array ( ) ) { $ criteria = array ( ) ; $ criteria [ ] = new Criterion \ Visibility ( Criterion \ Visibility :: VISIBLE ) ; $ criteria [ ] = new Criterion \ Subtree ( $ location -> pathString ) ; $ criteria [ ] = new Criterion \ ContentTypeIdentifier ( array ( 'blog_post' ) ) ; $ criteria [ ] = new Criterion \ LanguageCode ( $ languages ) ; if ( ! empty ( $ viewParameters ) ) { if ( ! empty ( $ viewParameters [ 'month' ] ) && ! empty ( $ viewParameters [ 'year' ] ) ) { // Generating the criterion for the given month/year $ month = ( int ) $ viewParameters [ 'month' ] ; $ year = ( int ) $ viewParameters [ 'year' ] ; $ date = new DateTime ( "$year-$month-01" ) ; $ date -> setTime ( 00 , 00 , 00 ) ; $ criteria [ ] = new Criterion \ DateMetadata ( Criterion \ DateMetadata :: CREATED , Criterion \ Operator :: BETWEEN , array ( $ date -> getTimestamp ( ) , $ date -> add ( new DateInterval ( 'P1M' ) ) -> getTimestamp ( ) , ) ) ; } } return new Criterion \ LogicalAnd ( $ criteria ) ; }
Generate criterion list to be used to list blog_posts.

@param \eZ\Publish\API\Repository\Values\Content\Location $location Location of the blog
@param array $viewParameters: View parameters of the blog view
@param string[] $languages Array of languages

@return \eZ\Publish\API\Repository\Values\Content\Query\Criterion
Generate criterion list to be used to list blog_posts .