public function transform() { /* @var $condSet UserDependentContentConditionSet */ $condSet = $this->getServiceObject(UserDependentContentConditionSet::class); if ($condSet->conditionMatches($this->getContext(), $this->getAttribute('condition'), $this->getAttribute('options'))) { return parent::transform(); } return ''; }
public function transform() { // Re-map desired model to content data attribute to ease expression and template definition. // Most likely, the model will be a parent document's data attribute. $model = ExpressionEvaluator::evaluate($this->getParentObject(), $this->getRequiredAttribute('content-mapping')); $this->setData('content', $model); // Calculate result to match against condition $result = ExpressionEvaluator::evaluate($this, $this->getRequiredAttribute('expression')); // The condition defines whether or not the content is displayed. Can be overwritten // by the "condition" attribute according to the TemplateCondition capabilities. $condition = $this->getAttribute('condition', 'notEmpty()'); if (!TemplateCondition::applies($condition, $result)) { return ''; } // Mark template for creating output directly as condition matches. $this->transformOnPlace(); return parent::transform(); }