Skip to content

Commit

Permalink
Remove block deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 15, 2020
1 parent afe359f commit 3579782
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 22 deletions.
37 changes: 31 additions & 6 deletions src/Block/Service/AbstractCategoriesBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,39 @@ abstract class AbstractCategoriesBlockService extends AbstractClassificationBloc
private $categoryAdmin;

/**
* @param string $name
* @param string|Environment $twigOrDeprecatedName
* @param EngineInterface|ContextManagerInterface $contextManagerOrDeprecatedTemplating
* @param ContextManagerInterface|CategoryManagerInterface $categoryManagerOrDeprecatedContextManager
* @param CategoryManagerInterface|AdminInterface $categoryAdminOrDeprecatedCategoryManager
* @param AdminInterface|null $deprecatedCategoryAdmin
*/
public function __construct($name, EngineInterface $templating, ContextManagerInterface $contextManager, CategoryManagerInterface $categoryManager, AdminInterface $categoryAdmin)
public function __construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$categoryManagerOrDeprecatedContextManager,
$categoryAdminOrDeprecatedCategoryManager,
$deprecatedCategoryAdmin = null
)
{
parent::__construct($name, $templating, $contextManager);

$this->categoryManager = $categoryManager;
$this->categoryAdmin = $categoryAdmin;
// NEXT_MAJOR: remove the if block
if (\is_string($twigOrDeprecatedName)) {
parent::__construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$categoryManagerOrDeprecatedContextManager
);

$this->categoryManager = $categoryAdminOrDeprecatedCategoryManager;
$this->categoryAdmin = $deprecatedCategoryAdmin;
} else {
parent::__construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating
);

$this->categoryManager = $categoryManagerOrDeprecatedContextManager;
$this->categoryAdmin = $categoryAdminOrDeprecatedCategoryManager;
}
}

public function execute(BlockContextInterface $blockContext, Response $response = null)
Expand Down
22 changes: 18 additions & 4 deletions src/Block/Service/AbstractClassificationBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Sonata\ClassificationBundle\Model\ContextManagerInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\Form\FormBuilder;
use Twig\Environment;

/**
* @author Christian Gripp <[email protected]>
Expand All @@ -34,13 +35,26 @@ abstract class AbstractClassificationBlockService extends AbstractAdminBlockServ
protected $contextManager;

/**
* @param string $name
* @param string|Environment $twigOrDeprecatedName
* @param EngineInterface|ContextManagerInterface $contextManagerOrDeprecatedTemplating
* @param ContextManagerInterface|null $deprecatedContextManager
*/
public function __construct($name, EngineInterface $templating, ContextManagerInterface $contextManager)
public function __construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$deprecatedContextManager = null
)
{
parent::__construct($name, $templating);
// NEXT_MAJOR: remove the if block
if (\is_string($twigOrDeprecatedName)) {
parent::__construct($twigOrDeprecatedName, $contextManagerOrDeprecatedTemplating);

$this->contextManager = $contextManager;
$this->contextManager = $deprecatedContextManager;
} else {
parent::__construct($twigOrDeprecatedName);

$this->contextManager = $contextManagerOrDeprecatedTemplating;
}
}

/**
Expand Down
39 changes: 33 additions & 6 deletions src/Block/Service/AbstractCollectionsBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,41 @@ abstract class AbstractCollectionsBlockService extends AbstractClassificationBlo
private $collectionAdmin;

/**
* @param string $name
* AbstractCollectionsBlockService constructor.
*
* @param string|Environment $twigOrDeprecatedName
* @param EngineInterface|ContextManagerInterface $contextManagerOrDeprecatedTemplating
* @param ContextManagerInterface|CollectionManagerInterface $collectionManagerOrDeprecatedContextManager
* @param CollectionManagerInterface|AdminInterface $collectionManagerOrcollectionAdminOrDeprecatedCollectionManager
* @param AdminInterface|null $deprecatedCollectionAdmin
*/
public function __construct($name, EngineInterface $templating, ContextManagerInterface $contextManager, CollectionManagerInterface $collectionManager, AdminInterface $collectionAdmin)
public function __construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$collectionManagerOrDeprecatedContextManager,
$collectionManagerOrcollectionAdminOrDeprecatedCollectionManager,
$deprecatedCollectionAdmin = null
)
{
parent::__construct($name, $templating, $contextManager);

$this->collectionManager = $collectionManager;
$this->collectionAdmin = $collectionAdmin;
// NEXT_MAJOR: remove the if block
if (\is_string($twigOrDeprecatedName)) {
parent::__construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$collectionManagerOrDeprecatedContextManager
);

$this->collectionManager = $collectionManagerOrcollectionAdminOrDeprecatedCollectionManager;
$this->collectionAdmin = $deprecatedCollectionAdmin;
} else {
parent::__construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating
);

$this->collectionManager = $collectionManagerOrDeprecatedContextManager;
$this->collectionAdmin = $collectionManagerOrcollectionAdminOrDeprecatedCollectionManager;
}
}

public function execute(BlockContextInterface $blockContext, Response $response = null)
Expand Down
37 changes: 31 additions & 6 deletions src/Block/Service/AbstractTagsBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,39 @@ abstract class AbstractTagsBlockService extends AbstractClassificationBlockServi
private $tagAdmin;

/**
* @param string $name
* @param string|Environment $twigOrDeprecatedName
* @param EngineInterface|ContextManagerInterface $contextManagerOrDeprecatedTemplating
* @param ContextManagerInterface|TagManagerInterface| $tagManagerOrDeprecatedContextManager
* @param TagManagerInterface|AdminInterface $tagAdminOrDeprecatedTagManager
* @param AdminInterface|null $deprecatedTagAdmin
*/
public function __construct($name, EngineInterface $templating, ContextManagerInterface $contextManager, TagManagerInterface $tagManager, AdminInterface $tagAdmin)
public function __construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$tagManagerOrDeprecatedContextManager,
$tagAdminOrDeprecatedTagManager,
$deprecatedTagAdmin = null
)
{
parent::__construct($name, $templating, $contextManager);

$this->tagManager = $tagManager;
$this->tagAdmin = $tagAdmin;
// NEXT_MAJOR: remove the if block
if (\is_string($twigOrDeprecatedName)) {
parent::__construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$tagManagerOrDeprecatedContextManager
);

$this->tagManager = $tagAdminOrDeprecatedTagManager;
$this->tagAdmin = $deprecatedTagAdmin;
} else {
parent::__construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating
);

$this->tagManager = $tagManagerOrDeprecatedContextManager;
$this->tagAdmin = $tagAdminOrDeprecatedTagManager;
}
}

public function execute(BlockContextInterface $blockContext, Response $response = null)
Expand Down

0 comments on commit 3579782

Please sign in to comment.