Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

[Doc] Add phpdoc and some comments. #104

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Guardfile
phpunit.xml
/TestsProject/app/cache/
/TestsProject/app/log/
/vendor/
/vendor/
3 changes: 3 additions & 0 deletions DependencyInjection/Compiler/AddPagerfantasPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
class AddPagerfantasPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('white_october_pagerfanta.view_factory')) {
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/WhiteOctoberPagerfantaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class WhiteOctoberPagerfantaExtension extends Extension
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$processor = new Processor();
$configuration = new Configuration();
$processor = new Processor();

$config = $processor->processConfiguration($configuration, $configs);
$container->setParameter('white_october_pagerfanta.default_view', $config['default_view']);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('pagerfanta.xml');

if ($config['exceptions_strategy']['out_of_range_page'] == Configuration::EXCEPTION_STRATEGY_TO_HTTP_NOT_FOUND) {
Expand Down
23 changes: 0 additions & 23 deletions Resources/public/css/pagerfantaDefault.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,3 @@
border-color: #ccf;
color: #ccf;
}

/*

.pagerfanta a,
.pagerfanta span {
border-color: blue;
color: blue;
}

.pagerfanta a:hover {
background: #ccf;
}

.pagerfanta .current {
background: #ccf;
}

.pagerfanta .disabled {
border-color: #ccf;
color: #cf;
}

*/
2 changes: 1 addition & 1 deletion Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

$loader = require __DIR__.'/../vendor/autoload.php';
$loader = require __DIR__ . '/../vendor/autoload.php';
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,91 @@

class PagerfantaController extends Controller
{
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function defaultViewAction()
{
return $this->renderPagerfanta('defaultView');
}

/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function twitterBootstrapViewAction()
{
return $this->renderPagerfanta('twitterBootstrapView');
}

/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function twitterBootstrap3ViewAction()
{
return $this->renderPagerfanta('twitterBootstrap3View');
}

/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function viewWithOptionsAction()
{
return $this->renderPagerfanta('viewWithOptions');
}

/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function defaultTranslatedViewAction()
{
$this->setLocale('es');

return $this->renderPagerfanta('defaultTranslatedView');
}

/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function twitterBootstrapTranslatedViewAction()
{
$this->setLocale('es');

return $this->renderPagerfanta('twitterBootstrapTranslatedView');
}

/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function twitterBootstrap3TranslatedViewAction()
{
$this->setLocale('es');

return $this->renderPagerfanta('twitterBootstrap3TranslatedView');
}

/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function myView1Action()
{
return $this->renderPagerfanta('myView1');
}


/**
* @param null $test
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function viewWithRouteParamsAction($test = null)
{
return $this->renderPagerfanta('viewWithRouteParams');
}

/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function defaultWithRequestAction(Request $request)
{
$template = $this->buildTemplateName('defaultView');
Expand All @@ -73,6 +106,11 @@ public function defaultWithRequestAction(Request $request)
));
}

/**
* @param $name
*
* @return \Symfony\Component\HttpFoundation\Response
*/
private function renderPagerfanta($name)
{
$template = $this->buildTemplateName($name);
Expand All @@ -84,18 +122,29 @@ private function renderPagerfanta($name)

}

/**
* @param $name
*
* @return string
*/
private function buildTemplateName($name)
{
return sprintf('WhiteOctoberPagerfantaTestBundle:Pagerfanta:%s.html.twig', $name);
}

/**
* @return Pagerfanta
*/
private function createPagerfanta()
{
$adapter = $this->createAdapter();

return new Pagerfanta($adapter);
}

/**
* @return FixedAdapter
*/
private function createAdapter()
{
$nbResults = 100;
Expand All @@ -104,8 +153,12 @@ private function createAdapter()
return new FixedAdapter($nbResults, $results);
}

/**
* @param $locale
*/
private function setLocale($locale)
{
// getRequest method is deprecated since version 2.4, to be removed in 3.0
$this->getRequest()->setLocale($locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private function assertView($view, $html)
{
$client = static::createClient();

$crawler = $client->request('GET', $this->buildViewUrl($view));
$client->request('GET', $this->buildViewUrl($view));

$response = $client->getResponse();
$this->assertSame(200, $response->getStatusCode());
Expand Down
1 change: 1 addition & 0 deletions Twig/PagerfantaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private function createRouteGenerator($options = array())
$pagePropertyPath = new PropertyPath($options['pageParameter']);

return function($page) use($router, $routeName, $routeParams, $pagePropertyPath) {
// getPropertyAccessor method is deprecated since version 2.3, to be removed in 3.0
$propertyAccessor = PropertyAccess::getPropertyAccessor();
$propertyAccessor->setValue($routeParams, $pagePropertyPath, $page);

Expand Down
16 changes: 16 additions & 0 deletions View/DefaultTranslatedView.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,37 @@
*/
class DefaultTranslatedView extends TranslatedView
{
/**
* @return string
*/
protected function previousMessageOption()
{
return 'previous_message';
}

/**
* @return string
*/
protected function nextMessageOption()
{
return 'next_message';
}

/**
* @param string $text
*
* @return string
*/
protected function buildPreviousMessage($text)
{
return sprintf('&#171; %s', $text);
}

/**
* @param string $text
*
* @return string
*/
protected function buildNextMessage($text)
{
return sprintf('%s &#187;', $text);
Expand Down
6 changes: 6 additions & 0 deletions View/TranslatedView.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ private function nextMessage()
return $this->buildNextMessage($nextText);
}

/**
* @return string
*/
private function previousText()
{
return $this->translator->trans('previous', array(), 'pagerfanta');
}

/**
* @return string
*/
private function nextText()
{
return $this->translator->trans('next', array(), 'pagerfanta');
Expand Down
16 changes: 16 additions & 0 deletions View/TwitterBootstrapTranslatedView.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,37 @@
*/
class TwitterBootstrapTranslatedView extends TranslatedView
{
/**
* @return string
*/
protected function previousMessageOption()
{
return 'prev_message';
}

/**
* @return string
*/
protected function nextMessageOption()
{
return 'next_message';
}

/**
* @param string $text
*
* @return string
*/
protected function buildPreviousMessage($text)
{
return sprintf('&larr; %s', $text);
}

/**
* @param string $text
*
* @return string
*/
protected function buildNextMessage($text)
{
return sprintf('%s &rarr;', $text);
Expand Down