public function typeAction($type)
    {
        $contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);

        if (!$contentType) {
            throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type));
        }

        $queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createQueryBuilder('c')
            ->select('c', 'vs', 'v', 'a')
            ->leftJoin('c.valueSet', 'vs')
            ->leftJoin('vs.values', 'v')
            ->leftJoin('v.attribute', 'a');

        $source = new Entity($this->getParameter('opifer_content.content_class'));
        $source->initQueryBuilder($queryBuilder);
        $tableAlias = $source->getTableAlias();
        $source->manipulateQuery(function ($query) use ($tableAlias, $contentType) {
            $query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType);
            $query->andWhere($tableAlias . '.layout = :layout')->setParameter('layout', false);
        });

        $designAction = new RowAction('button.design', 'opifer_content_contenteditor_design');
        $designAction->setRouteParameters(['id', 'owner' => 'content']);
        $designAction->setRouteParametersMapping(['id' => 'ownerId']);

        $detailsAction = new RowAction('button.details', 'opifer_content_content_edit');
        $detailsAction->setRouteParameters(['id']);

        //$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete');
        //$deleteAction->setRouteParameters(['id']);

        /* @var $grid \APY\DataGridBundle\Grid\Grid */
        $grid = $this->get('grid');
        $grid->setId('content')
            ->setSource($source)
            ->addRowAction($detailsAction)
            ->addRowAction($designAction);
            //->addRowAction($deleteAction)

        foreach ($contentType->getSchema()->getAttributes() as $attribute) {
            $name = $attribute->getName();
            $column = new AttributeColumn([
                'id' => $name,
                'field' => 'valueSet.values.value',
                'title' => $attribute->getDisplayName(),
                'visible' => false,
                'attribute' => $name,
                'source' => true
            ]);
            $column->manipulateRenderCell(
                function ($value, $row, $router) use ($name) {
                    $value = $row->getEntity()->getAttributes()[$name];

                    return $value;
                }
            );
            $grid->addColumn($column);
        }

        return $grid->getGridResponse($this->getParameter('opifer_content.content_type_view'), [
            'content_type' => $contentType,
            'grid' => $grid,
        ]);
    }
public function typeAction($type)
    {
        $contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);

        if (!$contentType) {
            throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type));
        }

        $queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createQueryBuilder('c')
            ->select('c', 'vs', 'v', 'a')
            ->leftJoin('c.valueSet', 'vs')
            ->leftJoin('vs.values', 'v')
            ->leftJoin('v.attribute', 'a');

        $source = new Entity($this->getParameter('opifer_content.content_class'));
        $source->initQueryBuilder($queryBuilder);
        $tableAlias = $source->getTableAlias();
        $source->manipulateQuery(function ($query) use ($tableAlias, $contentType) {
            $query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType);
            $query->andWhere($tableAlias . '.layout = :layout')->setParameter('layout', false);
        });

        $designAction = new RowAction('button.design', 'opifer_content_contenteditor_design');
        $designAction->setRouteParameters(['id', 'owner' => 'content']);
        $designAction->setRouteParametersMapping(['id' => 'ownerId']);

        $detailsAction = new RowAction('button.details', 'opifer_content_content_edit');
        $detailsAction->setRouteParameters(['id']);

        //$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete');
        //$deleteAction->setRouteParameters(['id']);

        /* @var $grid \APY\DataGridBundle\Grid\Grid */
        $grid = $this->get('grid');
        $grid->setId('content')
            ->setSource($source)
            ->addRowAction($detailsAction)
            ->addRowAction($designAction);
            //->addRowAction($deleteAction)

        foreach ($contentType->getSchema()->getAttributes() as $attribute) {
            $name = $attribute->getName();
            $column = new AttributeColumn([
                'id' => $name,
                'field' => 'valueSet.values.value',
                'title' => $attribute->getDisplayName(),
                'visible' => false,
                'attribute' => $name,
                'source' => true
            ]);
            $column->manipulateRenderCell(
                function ($value, $row, $router) use ($name) {
                    $value = $row->getEntity()->getAttributes()[$name];

                    return $value;
                }
            );
            $grid->addColumn($column);
        }

        return $grid->getGridResponse($this->getParameter('opifer_content.content_type_view'), [
            'content_type' => $contentType,
            'grid' => $grid,
        ]);
    }
public function typeAction ( $ type ) { $ contentType = $ this -> get ( 'opifer.content.content_type_manager' ) -> getRepository ( ) -> find ( $ type ) ; if ( ! $ contentType ) { throw $ this -> createNotFoundException ( sprintf ( 'Content Type with ID %d could not be found.' , $ type ) ) ; } $ queryBuilder = $ this -> get ( 'opifer.content.content_manager' ) -> getRepository ( ) -> createQueryBuilder ( 'c' ) -> select ( 'c' , 'vs' , 'v' , 'a' ) -> leftJoin ( 'c.valueSet' , 'vs' ) -> leftJoin ( 'vs.values' , 'v' ) -> leftJoin ( 'v.attribute' , 'a' ) ; $ source = new Entity ( $ this -> getParameter ( 'opifer_content.content_class' ) ) ; $ source -> initQueryBuilder ( $ queryBuilder ) ; $ tableAlias = $ source -> getTableAlias ( ) ; $ source -> manipulateQuery ( function ( $ query ) use ( $ tableAlias , $ contentType ) { $ query -> andWhere ( $ tableAlias . '.contentType = :contentType' ) -> setParameter ( 'contentType' , $ contentType ) ; $ query -> andWhere ( $ tableAlias . '.layout = :layout' ) -> setParameter ( 'layout' , false ) ; } ) ; $ designAction = new RowAction ( 'button.design' , 'opifer_content_contenteditor_design' ) ; $ designAction -> setRouteParameters ( [ 'id' , 'owner' => 'content' ] ) ; $ designAction -> setRouteParametersMapping ( [ 'id' => 'ownerId' ] ) ; $ detailsAction = new RowAction ( 'button.details' , 'opifer_content_content_edit' ) ; $ detailsAction -> setRouteParameters ( [ 'id' ] ) ; //$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete'); //$deleteAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $ grid = $ this -> get ( 'grid' ) ; $ grid -> setId ( 'content' ) -> setSource ( $ source ) -> addRowAction ( $ detailsAction ) -> addRowAction ( $ designAction ) ; //->addRowAction($deleteAction) foreach ( $ contentType -> getSchema ( ) -> getAttributes ( ) as $ attribute ) { $ name = $ attribute -> getName ( ) ; $ column = new AttributeColumn ( [ 'id' => $ name , 'field' => 'valueSet.values.value' , 'title' => $ attribute -> getDisplayName ( ) , 'visible' => false , 'attribute' => $ name , 'source' => true ] ) ; $ column -> manipulateRenderCell ( function ( $ value , $ row , $ router ) use ( $ name ) { $ value = $ row -> getEntity ( ) -> getAttributes ( ) [ $ name ] ; return $ value ; } ) ; $ grid -> addColumn ( $ column ) ; } return $ grid -> getGridResponse ( $ this -> getParameter ( 'opifer_content.content_type_view' ) , [ 'content_type' => $ contentType , 'grid' => $ grid , ] ) ; }
Index view of content by type

@param int $type
@return Response
Index view of content by type