-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0343c4c
commit cf98c55
Showing
21 changed files
with
422 additions
and
13 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
Content/Application/ContentDataMapper/DataMapper/WebspaceDataMapper.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentDataMapper\DataMapper; | ||
|
||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\WebspaceInterface; | ||
|
||
class WebspaceDataMapper implements DataMapperInterface | ||
{ | ||
public function map( | ||
DimensionContentInterface $unlocalizedDimensionContent, | ||
DimensionContentInterface $localizedDimensionContent, | ||
array $data | ||
): void { | ||
if (!$localizedDimensionContent instanceof WebspaceInterface) { | ||
return; | ||
} | ||
|
||
$this->setWebspaceData($localizedDimensionContent, $data); | ||
} | ||
|
||
/** | ||
* @param mixed[] $data | ||
*/ | ||
private function setWebspaceData(WebspaceInterface $dimensionContent, array $data): void | ||
{ | ||
if (\array_key_exists('mainWebspace', $data)) { | ||
$dimensionContent->setMainWebspace($data['mainWebspace']); | ||
} | ||
|
||
if (\array_key_exists('additionalWebspaces', $data)) { | ||
$dimensionContent->setAdditionalWebspaces($data['additionalWebspaces'] ?: []); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Content\Domain\Model; | ||
|
||
interface WebspaceInterface | ||
{ | ||
public function getMainWebspace(): ?string; | ||
|
||
public function setMainWebspace(?string $mainWebspace): void; | ||
|
||
public function getAdditionalWebspaces(): array; | ||
|
||
public function setAdditionalWebspaces(array $additionalWebspaces): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Content\Domain\Model; | ||
|
||
trait WebspaceTrait | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
protected $mainWebspace; | ||
|
||
/** | ||
* @var string[]|null | ||
*/ | ||
protected $additionalWebspaces; | ||
|
||
public function getMainWebspace(): ?string | ||
{ | ||
return $this->mainWebspace; | ||
} | ||
|
||
public function setMainWebspace(?string $mainWebspace): void | ||
{ | ||
$this->mainWebspace = $mainWebspace; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getAdditionalWebspaces(): array | ||
{ | ||
return $this->additionalWebspaces ?: []; | ||
} | ||
|
||
/** | ||
* @param string[] | ||
*/ | ||
public function setAdditionalWebspaces(array $additionalWebspaces): void | ||
{ | ||
$this->additionalWebspaces = $additionalWebspaces; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Content/Infrastructure/Sulu/Page/Select/WebspaceSelect.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Page\Select; | ||
|
||
use Sulu\Component\Webspace\Manager\WebspaceManagerInterface; | ||
|
||
class WebspaceSelect | ||
{ | ||
/** | ||
* @var WebspaceManagerInterface | ||
*/ | ||
private $webspaceManager; | ||
|
||
public function __construct(WebspaceManagerInterface $webspaceManager) | ||
{ | ||
$this->webspaceManager = $webspaceManager; | ||
} | ||
|
||
public function getValues(): array | ||
{ | ||
$values = []; | ||
foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) { | ||
$values[] = [ | ||
'name' => $webspace->getKey(), | ||
'title' => $webspace->getName(), | ||
]; | ||
} | ||
|
||
return $values; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" ?> | ||
<form xmlns="http://schemas.sulu.io/template/template" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/form-1.0.xsd" | ||
> | ||
<key>content_settings_webspace</key> | ||
|
||
<tag name="sulu_content.content_settings_form" instanceOf="Sulu\Bundle\ContentBundle\Content\Domain\Model\WebspaceInterface" priority="10"/> | ||
|
||
<properties> | ||
<section name="webspace"> | ||
<meta> | ||
<title>sulu_content.main_webspace</title> | ||
</meta> | ||
|
||
<properties> | ||
<property name="mainWebspace" type="single_select" colspan="6"> | ||
<meta> | ||
<title>sulu_content.main_webspace</title> | ||
</meta> | ||
|
||
<params> | ||
<param | ||
name="values" | ||
type="expression" | ||
value="service('sulu_content.webspace_select').getValues()" | ||
/> | ||
</params> | ||
</property> | ||
|
||
<property name="additionalWebspaces" type="select" colspan="6"> | ||
<meta> | ||
<title>sulu_content.additional_webspaces</title> | ||
</meta> | ||
|
||
<params> | ||
<param | ||
name="values" | ||
type="expression" | ||
value="service('sulu_content.webspace_select').getValues()" | ||
/> | ||
</params> | ||
</property> | ||
</properties> | ||
</section> | ||
</properties> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.