Comments

internetdevels’s picture

Status: Active » Needs review
StatusFileSize
new2.53 KB

Let's see...

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
  1. @@ -25,6 +25,7 @@ class Php extends ConditionPluginBase {
       public function buildForm(array $form, array &$form_state) {
    +    $account = \Drupal::request()->attributes->get('_account');
    

    This should have Request $request = NULL in the method signature

  2. @@ -48,7 +48,8 @@ public function buildOptionsForm(&$form, &$form_state) {
    -    return user_access('use PHP for settings');
    +    $account = \Drupal::request()->attributes->get('_account');
    

    This can be injected

  3. @@ -47,7 +47,8 @@ public function buildOptionsForm(&$form, &$form_state) {
    -    return user_access('use PHP for settings');
    +    $account = \Drupal::request()->attributes->get('_account');
    

    As can this.

andypost’s picture

Priority: Minor » Normal

@Tim, the question here what kind of service needs injection: current_user or request?

sidharthap’s picture

Status: Needs work » Needs review
StatusFileSize
new2.1 KB

Corrected with Drupal::currentUser()

andypost’s picture

Status: Needs review » Needs work
+++ b/core/modules/php/lib/Drupal/php/Plugin/Condition/Php.php
@@ -35,7 +35,7 @@ public function buildForm(array $form, array &$form_state) {
+      '#access' => Drupal::currentUser()->hasPermission('use PHP for settings')

+++ b/core/modules/php/lib/Drupal/php/Plugin/views/argument_default/Php.php
@@ -48,7 +48,7 @@ public function buildOptionsForm(&$form, &$form_state) {
+    return Drupal::currentUser()->hasPermission('use PHP for settings');

+++ b/core/modules/php/lib/Drupal/php/Plugin/views/argument_validator/Php.php
@@ -47,7 +47,7 @@ public function buildOptionsForm(&$form, &$form_state) {
+    return Drupal::currentUser()->hasPermission('use PHP for settings');

This calls in the namespace so \Drupal, seems no tests for that

tim.plunkett’s picture

h3rj4n’s picture

Status: Needs work » Needs review
Issue tags: -CodeSprintCIS

Where did this module go (php module)? I searched for 'class Php' but I'm not able to find it.

tim.plunkett’s picture

Status: Needs review » Closed (duplicate)