-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
205 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ Tests/Resources/app/logs | |
bin/ | ||
composer.lock | ||
vendor/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
* file that was distributed with this source code. | ||
*/ | ||
|
||
|
||
namespace Symfony\Cmf\Bundle\BlogBundle\Admin; | ||
|
||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
|
@@ -18,7 +17,7 @@ | |
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin; | ||
|
||
/** | ||
* Blog Admin | ||
* Blog Admin. | ||
* | ||
* @author Daniel Leech <[email protected]> | ||
*/ | ||
|
@@ -28,7 +27,7 @@ class BlogAdmin extends Admin | |
protected $blogRoot; | ||
|
||
/** | ||
* Constructor | ||
* Constructor. | ||
* | ||
* @param string $code | ||
* @param string $class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
* file that was distributed with this source code. | ||
*/ | ||
|
||
|
||
namespace Symfony\Cmf\Bundle\BlogBundle\Admin; | ||
|
||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
|
@@ -18,7 +17,7 @@ | |
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin; | ||
|
||
/** | ||
* Post Admin | ||
* Post Admin. | ||
* | ||
* @author Daniel Leech <[email protected]> | ||
*/ | ||
|
@@ -28,7 +27,7 @@ class PostAdmin extends Admin | |
protected $blogClass; | ||
|
||
/** | ||
* Constructor | ||
* Constructor. | ||
* | ||
* @param string $code | ||
* @param string $class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,25 +9,16 @@ | |
* file that was distributed with this source code. | ||
*/ | ||
|
||
|
||
namespace Symfony\Cmf\Bundle\BlogBundle\Controller; | ||
|
||
use Knp\Component\Pager\Paginator; | ||
use Symfony\Cmf\Bundle\BlogBundle\Model\Post; | ||
use Symfony\Cmf\Bundle\BlogBundle\Model\Blog; | ||
use Symfony\Cmf\Bundle\BlogBundle\Repository\PostRepository; | ||
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishWorkflowChecker; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
use Symfony\Component\Security\Core\SecurityContextInterface; | ||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | ||
use FOS\RestBundle\View\ViewHandlerInterface; | ||
use FOS\RestBundle\View\View; | ||
|
||
/** | ||
* Base Controller | ||
* | ||
* @author Daniel Leech <[email protected]> | ||
* Base Controller. | ||
*/ | ||
abstract class BaseController | ||
{ | ||
|
@@ -47,11 +38,11 @@ abstract class BaseController | |
protected $viewHandler; | ||
|
||
/** | ||
* Constructor | ||
* Constructor. | ||
* | ||
* @param EngineInterface $templating | ||
* @param EngineInterface $templating | ||
* @param SecurityContextInterface $securityContext | ||
* @param ViewHandlerInterface $viewHandler | ||
* @param ViewHandlerInterface $viewHandler | ||
*/ | ||
public function __construct( | ||
EngineInterface $templating, | ||
|
@@ -68,6 +59,7 @@ protected function renderResponse($contentTemplate, $params) | |
if ($this->viewHandler) { | ||
$view = new View($params); | ||
$view->setTemplate($contentTemplate); | ||
|
||
return $this->viewHandler->handle($view); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
* file that was distributed with this source code. | ||
*/ | ||
|
||
|
||
namespace Symfony\Cmf\Bundle\BlogBundle\Controller; | ||
|
||
use Symfony\Cmf\Bundle\BlogBundle\Model\Blog; | ||
|
@@ -19,9 +18,10 @@ | |
use Symfony\Component\Security\Core\SecurityContextInterface; | ||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | ||
use FOS\RestBundle\View\ViewHandlerInterface; | ||
use Knp\Component\Pager\Paginator; | ||
|
||
/** | ||
* Blog Controller | ||
* Blog Controller. | ||
* | ||
* @author Daniel Leech <[email protected]> | ||
*/ | ||
|
@@ -38,7 +38,7 @@ class BlogController extends BaseController | |
protected $postRepository; | ||
|
||
/** | ||
* @var \Knp\Component\Pager\Paginator | ||
* @var Paginator | ||
*/ | ||
protected $paginator; | ||
|
||
|
@@ -53,7 +53,7 @@ public function __construct( | |
ViewHandlerInterface $viewHandler = null, | ||
BlogRepository $blogRepository, | ||
PostRepository $postRepository, | ||
$paginator = null, | ||
Paginator $paginator = null, | ||
$postsPerPage = 0 | ||
) { | ||
parent::__construct($templating, $securityContext, $viewHandler); | ||
|
@@ -64,7 +64,7 @@ public function __construct( | |
} | ||
|
||
/** | ||
* List blogs | ||
* List blogs. | ||
*/ | ||
public function listAction(Request $request) | ||
{ | ||
|
@@ -77,7 +77,7 @@ public function listAction(Request $request) | |
} | ||
|
||
/** | ||
* Blog detail - list posts in a blog, optionally paginated | ||
* Blog detail - list posts in a blog, optionally paginated. | ||
*/ | ||
public function detailAction(Request $request, Blog $contentDocument, $contentTemplate = null) | ||
{ | ||
|
@@ -87,16 +87,15 @@ public function detailAction(Request $request, Blog $contentDocument, $contentTe | |
'blogId' => $blog->getId(), | ||
)); | ||
|
||
$pager = false; | ||
if ($this->postsPerPage) { | ||
$pager = $posts = $this->paginator->paginate( | ||
$posts = $this->paginator->paginate( | ||
$posts, | ||
$request->query->get('page', 1), | ||
$this->postsPerPage | ||
); | ||
} | ||
|
||
$templateFilename = $pager ? 'detailPaginated' : 'detail'; | ||
$templateFilename = $this->postsPerPage ? 'detailPaginated' : 'detail'; | ||
$contentTemplate = $this->getTemplateForResponse( | ||
$request, | ||
$contentTemplate ?: sprintf('CmfBlogBundle:Blog:%s.{_format}.twig', $templateFilename) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.