Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Drupal\block_content_test\Plugin\EntityReferenceSelection; use Drupal\Co..
Decoded Output download
<?php
namespace Drupallock_content_test\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
/**
* Test EntityReferenceSelection with conditions on the 'reusable' field.
*/
class TestSelection extends DefaultSelection {
/**
* The condition type.
*
* @var string
*/
protected $conditionType;
/**
* Whether to set the condition for reusable or non-reusable blocks.
*
* @var bool
*/
protected $isReusable;
/**
* Sets the test mode.
*
* @param string $condition_type
* The condition type.
* @param bool $is_reusable
* Whether to set the condition for reusable or non-reusable blocks.
*/
public function setTestMode($condition_type = NULL, $is_reusable = NULL) {
$this->conditionType = $condition_type;
$this->isReusable = $is_reusable;
}
/**
* {@inheritdoc}
*/
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
if ($this->conditionType) {
/** @var \Drupal\Core\Database\Query\ConditionInterface $add_condition */
$add_condition = NULL;
switch ($this->conditionType) {
case 'base':
$add_condition = $query;
break;
case 'group':
$group = $query->andConditionGroup()
->exists('type');
$add_condition = $group;
$query->condition($group);
break;
case "nested_group":
$query->exists('type');
$sub_group = $query->andConditionGroup()
->exists('type');
$add_condition = $sub_group;
$group = $query->andConditionGroup()
->exists('type')
->condition($sub_group);
$query->condition($group);
break;
}
if ($this->isReusable) {
$add_condition->condition('reusable', 1);
}
else {
$add_condition->condition('reusable', 0);
}
}
return $query;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Drupal\block_content_test\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
/**
* Test EntityReferenceSelection with conditions on the 'reusable' field.
*/
class TestSelection extends DefaultSelection {
/**
* The condition type.
*
* @var string
*/
protected $conditionType;
/**
* Whether to set the condition for reusable or non-reusable blocks.
*
* @var bool
*/
protected $isReusable;
/**
* Sets the test mode.
*
* @param string $condition_type
* The condition type.
* @param bool $is_reusable
* Whether to set the condition for reusable or non-reusable blocks.
*/
public function setTestMode($condition_type = NULL, $is_reusable = NULL) {
$this->conditionType = $condition_type;
$this->isReusable = $is_reusable;
}
/**
* {@inheritdoc}
*/
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
if ($this->conditionType) {
/** @var \Drupal\Core\Database\Query\ConditionInterface $add_condition */
$add_condition = NULL;
switch ($this->conditionType) {
case 'base':
$add_condition = $query;
break;
case 'group':
$group = $query->andConditionGroup()
->exists('type');
$add_condition = $group;
$query->condition($group);
break;
case "nested_group":
$query->exists('type');
$sub_group = $query->andConditionGroup()
->exists('type');
$add_condition = $sub_group;
$group = $query->andConditionGroup()
->exists('type')
->condition($sub_group);
$query->condition($group);
break;
}
if ($this->isReusable) {
$add_condition->condition('reusable', 1);
}
else {
$add_condition->condition('reusable', 0);
}
}
return $query;
}
}
Function Calls
None |
Stats
MD5 | c994286eed589d84c4ff0e71c44fe2b7 |
Eval Count | 0 |
Decode Time | 127 ms |