Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove block deprecations #488

Merged
merged 1 commit into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions src/Block/Service/AbstractCategoriesBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,38 @@ 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)
{
parent::__construct($name, $templating, $contextManager);

$this->categoryManager = $categoryManager;
$this->categoryAdmin = $categoryAdmin;
public function __construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$categoryManagerOrDeprecatedContextManager,
$categoryAdminOrDeprecatedCategoryManager,
$deprecatedCategoryAdmin = null
) {
// NEXT_MAJOR: remove the if block
if (\is_string($twigOrDeprecatedName)) {
parent::__construct(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need any deprecation warning here, because the parent class will trigger one.

$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
23 changes: 18 additions & 5 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,25 @@ 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)
{
parent::__construct($name, $templating);
public function __construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$deprecatedContextManager = null
) {
// NEXT_MAJOR: remove the if block
if (\is_string($twigOrDeprecatedName)) {
parent::__construct($twigOrDeprecatedName, $contextManagerOrDeprecatedTemplating);

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

$this->contextManager = $contextManager;
$this->contextManager = $contextManagerOrDeprecatedTemplating;
}
}

/**
Expand Down
40 changes: 33 additions & 7 deletions src/Block/Service/AbstractCollectionsBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,40 @@ 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 $collectionAdminOrDeprecatedCollectionManager
* @param AdminInterface|null $deprecatedCollectionAdmin
*/
public function __construct($name, EngineInterface $templating, ContextManagerInterface $contextManager, CollectionManagerInterface $collectionManager, AdminInterface $collectionAdmin)
{
parent::__construct($name, $templating, $contextManager);

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

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

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

public function execute(BlockContextInterface $blockContext, Response $response = null)
Expand Down
38 changes: 31 additions & 7 deletions src/Block/Service/AbstractTagsBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,38 @@ 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)
{
parent::__construct($name, $templating, $contextManager);

$this->tagManager = $tagManager;
$this->tagAdmin = $tagAdmin;
public function __construct(
$twigOrDeprecatedName,
$contextManagerOrDeprecatedTemplating,
$tagManagerOrDeprecatedContextManager,
$tagAdminOrDeprecatedTagManager,
$deprecatedTagAdmin = null
) {
// 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