-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
ezobjectrelationlilst_content
operator
- Loading branch information
1 parent
17e27a5
commit 8829f79
Showing
4 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
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,32 @@ | ||
<?php | ||
namespace Swark\TemplateOperators; | ||
|
||
/** | ||
* Alternative for getting ezobjectrelationlist content as a list of nodes, instead of an array which does not have the nodes. | ||
* | ||
* Examples: | ||
* ```eztpl | ||
* {$data_map.my_ezobjectrelationlist_field|ezobjectrelationlist_content} => array(Node) | ||
* ``` | ||
* | ||
* Will return the node directly, if only one is related. | ||
*/ | ||
class EzObjectRelationListContent extends \SwarkOperator | ||
{ | ||
function __construct() | ||
{ | ||
parent::__construct('ezobjectrelationlist_content'); | ||
} | ||
|
||
static function execute($ezSelectionField, $namedParameters) | ||
{ | ||
$classContent = $ezSelectionField->attribute('content'); | ||
$relationList = $classContent['relation_list']; | ||
|
||
$nodeIds = array_map(function($node) { | ||
return $node['node_id']; | ||
}, $relationList); | ||
|
||
return \eZContentObjectTreeNode::fetch($nodeIds); | ||
} | ||
} |
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,37 @@ | ||
ezobjectrelationlist_content | ||
------------------- | ||
|
||
Summary | ||
~~~~~~~ | ||
Alternative for getting ezobjectrelationlist content as a list of nodes, instead of an array which does not have the nodes. | ||
|
||
Will return the node directly, if only one is related. | ||
|
||
Usage | ||
~~~~~ | ||
:: | ||
|
||
field|ezobjectrelationlist_content | ||
|
||
Parameters | ||
~~~~~~~~~~ | ||
.. list-table:: | ||
:header-rows: 1 | ||
|
||
* - Name | ||
- Description | ||
- Required | ||
- Default | ||
|
||
* - `field` | ||
- eZObjectRelationList field from data_map. Do note that we do not pass in the content, and instead the entire field. | ||
- Yes | ||
- | ||
|
||
Examples | ||
~~~~~~~~ | ||
:: | ||
|
||
{$data_map.my_ezobjectrelationlist_field|ezobjectrelationlist_content} | ||
|
||
Returns array of nodes, or the node directly: `array(eZContentObjectTreeNode)|eZContentObjectTreeNode`. |
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