Skip to content

Commit

Permalink
Remove everything related to target
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Jul 24, 2022
1 parent 60fb7bc commit 37fe83e
Show file tree
Hide file tree
Showing 14 changed files with 6 additions and 342 deletions.
25 changes: 1 addition & 24 deletions src/Command/CloneSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$output->writeln('Fixing page parents and targets');
$output->writeln('Fixing page parents');
foreach ($pageClones as $page) {
if ($page->getParent()) {
if (\array_key_exists($page->getParent()->getId(), $pageClones)) {
Expand All @@ -155,29 +155,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

//NEXT_MAJOR: Remove this target condition block.
if ($page->getTarget()) {
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

if (\array_key_exists($page->getTarget()->getId(), $pageClones)) {
$output->writeln(
sprintf(
'new target: % 4s - % -70s - % 4s',
$page->getId(),
$page->getTitle(),
$page->getParent() ? $page->getParent()->getId() : ''
)
);
$page->setTarget($pageClones[$page->getTarget()->getId()]);
} else {
$page->setTarget(null);
}
}

$this->pageManager->save($page, true);
}

Expand Down
20 changes: 0 additions & 20 deletions src/DependencyInjection/SonataPageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,26 +332,6 @@ private function registerSonataDoctrineMapping(array $config): void
])
);

$collector->addAssociation(
$config['class']['page'],
'mapOneToMany',
OptionsBuilder::createOneToMany('sources', $config['class']['page'])
->mappedBy('target')
);

$collector->addAssociation(
$config['class']['page'],
'mapManyToOne',
OptionsBuilder::createManyToOne('target', $config['class']['page'])
->cascade(['persist'])
->inversedBy('sources')
->addJoin([
'name' => 'target_id',
'referencedColumnName' => 'id',
'onDelete' => 'CASCADE',
])
);

$collector->addAssociation(
$config['class']['block'],
'mapOneToMany',
Expand Down
11 changes: 0 additions & 11 deletions src/Entity/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ public function create(PageInterface $page)
$snapshot->setParentId($page->getParent()->getId());
}

//NEXT_MAJOR: Remove this "if" condition block.
if ($page->getTarget()) {
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);
$snapshot->setTargetId($page->getTarget()->getId());
}

$content = [];
$content['id'] = $page->getId();
$content['name'] = $page->getName();
Expand All @@ -100,7 +90,6 @@ public function create(PageInterface $page)
$content['updated_at'] = $page->getUpdatedAt()->format('U');
$content['slug'] = $page->getSlug();
$content['parent_id'] = $page->getParent() ? $page->getParent()->getId() : null;
$content['target_id'] = $page->getTarget() ? $page->getTarget()->getId() : null; //NEXT_MAJOR: Remove this line.

$content['blocks'] = [];
foreach ($page->getBlocks() as $block) {
Expand Down
34 changes: 0 additions & 34 deletions src/Model/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,6 @@ abstract class Page implements PageInterface
*/
protected $parents;

/**
* @var PageInterface|null
*
* NEXT_MAJOR: Remove this property
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
protected $target;

/**
* @var Collection<array-key, PageInterface>
*/
Expand Down Expand Up @@ -434,38 +425,13 @@ public function setSnapshots($snapshots): void
$this->snapshots = $snapshots;
}

public function getTarget()
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

return $this->target;
}

public function addSnapshot(SnapshotInterface $snapshot): void
{
$this->snapshots[] = $snapshot;

$snapshot->setPage($this);
}

/**
* @param PageInterface $target
*/
public function setTarget(?PageInterface $target = null): void
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

$this->target = $target;
}

public function addBlocks(PageBlockInterface $block): void
{
$block->setPage($this);
Expand Down
18 changes: 0 additions & 18 deletions src/Model/PageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,24 +200,6 @@ public function addBlocks(PageBlockInterface $block);
*/
public function getBlocks();

/**
* @param PageInterface|null $target
*
* NEXT_MAJOR: Remove this method
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function setTarget(?self $target = null);

/**
* @return PageInterface|null
*
* NEXT_MAJOR: Remove this method
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function getTarget();

/**
* @param PageInterface|null $parent
*/
Expand Down
106 changes: 0 additions & 106 deletions src/Model/Snapshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,6 @@ abstract class Snapshot implements SnapshotInterface
*/
protected $sources;

/**
* @var PageInterface|null
*
* NEXT_MAJOR: Remove this method and remember to remove the field definition at "src/Resources/config/doctrine/BaseSnapshot.orm.xml"
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
protected $target;

/**
* @var int|null
*
* NEXT_MAJOR: Remove this method
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
protected $targetId;

/**
* @var SiteInterface|null
*/
Expand Down Expand Up @@ -303,94 +285,6 @@ public function getParentId()
return $this->parentId;
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/page-bundle 2.4 and will be removed in 4.0
*/
public function setSources($sources): void
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', \E_USER_DEPRECATED);

$this->sources = $sources;
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/page-bundle 2.4 and will be removed in 4.0
*/
public function getSource()
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', \E_USER_DEPRECATED);

return $this->sources;
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function setTarget($target): void
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

$this->target = $target;
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function getTarget()
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

return $this->target;
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function setTargetId($targetId): void
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

$this->targetId = $targetId;
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function getTargetId()
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

return $this->targetId;
}

public function setUrl($url): void
{
$this->url = $url;
Expand Down
4 changes: 0 additions & 4 deletions src/Model/SnapshotInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* @method int|null getId()
* @method int|null getTargetId() NEXT_MAJOR: Remove this line.
* @method void setTargetId(?int $targetId) NEXT_MAJOR: Remove this line.
* @method PageInterface|null getTarget(): NEXT_MAJOR: Remove this line.
* @method void setTarget(?PageInterface $target) NEXT_MAJOR: Remove this line.
* @method int|null getParent()
* @method void setParentId(?int $parentId)
*/
Expand Down
55 changes: 0 additions & 55 deletions src/Model/SnapshotPageProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ final class SnapshotPageProxy implements SnapshotPageProxyInterface

private ?PageInterface $page = null;

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
private ?PageInterface $target = null;

/**
* @var PageInterface[]|null
*/
Expand Down Expand Up @@ -143,54 +136,6 @@ public function getBlocks()
return $this->getPage()->getBlocks();
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function setTarget(?PageInterface $target = null): void
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

$this->target = $target;
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since 3.27 and it will be removed on 4.0
*/
public function getTarget()
{
@trigger_error(
'target page is deprecate since sonata-project/page-bundle 3.27.0'.
', and it will be removed in 4.0',
\E_USER_DEPRECATED
);

if (null === $this->target) {
$content = $this->snapshot->getContent();

if (isset($content['target_id'])) {
$target = $this->manager->findEnableSnapshot([
'pageId' => $content['target_id'],
]);

if ($target) {
$this->setTarget(new self($this->manager, $this->transformer, $target));
} else {
$this->setTarget(null);
}
}
}

return $this->target ?: null;
}

public function getParent($level = -1)
{
$parents = $this->getParents();
Expand Down
Loading

0 comments on commit 37fe83e

Please sign in to comment.