Skip to content

Commit

Permalink
Code Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilov committed Mar 31, 2017
1 parent 3782e55 commit fce4b9e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
"twig/twig": "^1.26",
"symfony/http-foundation": "~2.8.13|~3.1.6|~3.2",
"glavweb/cms-rest-client": "~0.1",
"glavweb/cms-content-block": "~0.3",
"glavweb/cms-composite-object": "~0.1"

"glavweb/cms-content-block": "~1.0",
"glavweb/cms-composite-object": "~1.0"
},
"autoload": {
"psr-4": { "Glavweb\\CmsTwigExtension\\": "src/" }
Expand Down
53 changes: 26 additions & 27 deletions src/Extension/CmsTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

namespace Glavweb\CmsTwigExtension\Extension;

use Glavweb\CmsContentBlock\Service\OptionService;
use Glavweb\CmsContentBlock\Service\OptionServiceService;
use Glavweb\CmsCompositeObject\Manager\CompositeObjectManager;
use Glavweb\CmsContentBlock\Manager\OptionManager;
use Symfony\Component\HttpFoundation\Session\Session;
use Glavweb\CmsRestClient\CmsRestClient;
use Glavweb\CmsContentBlock\Service\ContentBlockService;
use Glavweb\CmsCompositeObject\Service\CompositeObjectService;
use Glavweb\CmsContentBlock\Manager\ContentBlockManager;

/**
* Class CmsTwigExtension
Expand All @@ -37,19 +36,19 @@ class CmsTwigExtension extends \Twig_Extension
private $cmsRestClient;

/**
* @var ContentBlockService
* @var ContentBlockManager
*/
private $contentBlockService;
private $contentBlockManager;

/**
* @var OptionService
* @var OptionManager
*/
private $optionService;
private $optionManager;

/**
* @var CompositeObjectService
* @var CompositeObjectManager
*/
private $compositeObjectService;
private $compositeObjectManager;

/**
* @var string
Expand All @@ -76,20 +75,20 @@ class CmsTwigExtension extends \Twig_Extension
*
* @param Session $session
* @param CmsRestClient $cmsRestClient
* @param ContentBlockService $contentBlockService
* @param OptionService $optionService
* @param CompositeObjectService $compositeObjectService
* @param ContentBlockManager $contentBlockManager
* @param OptionManager $optionManager
* @param CompositeObjectManager $compositeObjectManager
* @param string $cmsBaseUrl
* @param bool $editable
* @param bool $markupMode
*/
public function __construct(Session $session, CmsRestClient $cmsRestClient, ContentBlockService $contentBlockService, OptionService $optionService, CompositeObjectService $compositeObjectService, $cmsBaseUrl, $apiBaseUrl, $editable = false, $markupMode = false)
public function __construct(Session $session, CmsRestClient $cmsRestClient, ContentBlockManager $contentBlockManager, OptionManager $optionManager, CompositeObjectManager $compositeObjectManager, $cmsBaseUrl, $apiBaseUrl, $editable = false, $markupMode = false)
{
$this->session = $session;
$this->cmsRestClient = $cmsRestClient;
$this->contentBlockService = $contentBlockService;
$this->optionService = $optionService;
$this->compositeObjectService = $compositeObjectService;
$this->contentBlockManager = $contentBlockManager;
$this->optionManager = $optionManager;
$this->compositeObjectManager = $compositeObjectManager;
$this->cmsBaseUrl = $cmsBaseUrl;
$this->apiBaseUrl = $apiBaseUrl;
$this->editable = $editable;
Expand Down Expand Up @@ -152,9 +151,9 @@ public function content($category, $blockName, $default = null)
return $default;
}

$contentBlockService = $this->contentBlockService;
$contentBlockManager = $this->contentBlockManager;

return $contentBlockService->getContentBlock($category, $blockName, $default);
return $contentBlockManager->getContentBlock($category, $blockName, $default);
}

/**
Expand All @@ -168,10 +167,10 @@ public function editable($category, $blockName)
return '';
}

$contentBlockService = $this->contentBlockService;
$contentBlockManager = $this->contentBlockManager;

if ($this->isEditable()) {
return $contentBlockService->editable($category, $blockName);
return $contentBlockManager->editable($category, $blockName);
}

return '';
Expand All @@ -189,10 +188,10 @@ public function editableObject($id)
return '';
}

$compositeObjectService = $this->compositeObjectService;
$compositeObjectManager = $this->compositeObjectManager;

if ($this->isEditable()) {
return $compositeObjectService->editable($id);
return $compositeObjectManager->editable($id);
}

return '';
Expand All @@ -212,9 +211,9 @@ public function option($category, $optionName, $default = null)
return $default;
}

$optionService = $this->optionService;
$optionManager = $this->optionManager;

return $optionService->getOption($category, $optionName, $default);
return $optionManager->getOption($category, $optionName, $default);
}

/**
Expand All @@ -240,7 +239,7 @@ public function isEditable()
*/
public function getObjects($className)
{
return $this->compositeObjectService->getObjectsByClassName($className);
return $this->compositeObjectManager->getObjectsByClassName($className);
}

/**
Expand All @@ -263,7 +262,7 @@ public function spaceless($value)
public function cmsAsset($resource)
{
if ($this->markupMode) {
return '/' . $resource;
return $resource;
}

return $this->cmsBaseUrl . '/' . $resource;
Expand Down

0 comments on commit fce4b9e

Please sign in to comment.