Answers.Body: <p>Thanks to Lindsey D's comment to my first answer, I had a closer look at <a href="http://buildwithcraft.com/docs/plugins/hooks-and-events#hooks" rel="nofollow">custom hooks</a> and found out that this is indeed the better solution to do this.</p>
  
  <p>MyPlugin_myServiceService.php</p>
  
  <pre><code>public function setTest()
  {
      $test = true;
  
      craft()-&gt;plugins-&gt;call('modifyTest', array(&amp;$test));  
  
      return $test;
  }
  </code></pre>
  
  <p>MyOtherPluginPlugin.php</p>
  
  <pre><code>public function modifyTest(&amp;$test)
  {
      $test = false;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-31T08:00:55.233Z
Answers.LastActivityDate: 2015-07-31T08:00:55.233Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>It looks like it doesn't updated the variables passed to the event directly (referenced) and you have to access the value from the <code>$event</code> object.</p>
  
  <pre><code>public function setTest()
  {
      // ...
  
      $test = $event-&gt;params['test']
  
      return $test;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T19:15:20.233Z
Answers.Text: Sounds like you may need a custom **hook**, instead of an event. Generally speaking, events aren't supposed to modify the data which triggered it.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-31T08:02:57.700Z
Answers.Text: Totally right, a hook is really the better solution to do this. Thank you!
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T16:02:32.853Z
Answers.LastActivityDate: 2015-07-30T16:10:56.157Z
Answers.LastEditDate: 2015-07-30T16:10:56.157Z
Answers.UserDisplayName: carlcs
Body: <p>I'm having problems setting up an event. It gets triggered and I can access the event's params array, but I can't override the value like I can with Craft's default events.</p>
  
  <p>MyPlugin_myServiceService.php</p>
  
  <pre><code>public function setTest()
  {
      $test = true;
  
      $event = new Event($this, array(
          'test' =&gt; $test
      ));
  
      $this-&gt;onAfterSetTest($event);
  
      return $test;
  }
  
  public function onAfterSetTest(Event $event)
  {
      $this-&gt;raiseEvent('onAfterSetTest', $event);
  }
  </code></pre>
  
  <p>MyOtherPluginPlugin.php</p>
  
  <pre><code>craft()-&gt;on('myPlugin_myService.afterSetTest', function(Event $event)
  {  
      $event-&gt;params['test'] = false;
  });
  </code></pre>
  
  <p>Not sure what I'm doing wrong but 
  <code>craft()-&gt;myPlugin_myService-&gt;setTest()</code> returns <code>true</code>.</p>
  
Tags: <plugin-development><events>
Title: Override an event's param array?
ThreadText: # Override an event's param array?
  
  (Asked by: username_0 on 2015-07-30)
  
  I'm having problems setting up an event. It gets triggered and I can access the event's params array, but I can't override the value like I can with Craft's default events.
  
  MyPlugin\_myServiceService.php
  
  ```
  public function setTest()
  {
      $test = true;
  
      $event = new Event($this, array(
          'test' => $test
      ));
  
      $this->onAfterSetTest($event);
  
      return $test;
  }
  
  public function onAfterSetTest(Event $event)
  {
      $this->raiseEvent('onAfterSetTest', $event);
  }
  
  ```
  
  MyOtherPluginPlugin.php
  
  ```
  craft()->on('myPlugin_myService.afterSetTest', function(Event $event)
  {  
      $event->params['test'] = false;
  });
  
  ```
  
  Not sure what I'm doing wrong but
  `craft()->myPlugin_myService->setTest()` returns `true`.
  
  **Tags:** plugin-development, events
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-07-31. Score: 1 | Accepted answer
  
  Thanks to username_1's comment to my first answer, I had a closer look at [custom hooks](http://buildwithcraft.com/docs/plugins/hooks-and-events#hooks) and found out that this is indeed the better solution to do this.
  
  MyPlugin\_myServiceService.php
  
  ```
  public function setTest()
  {
      $test = true;
  
      craft()->plugins->call('modifyTest', array(&$test));  
  
      return $test;
  }
  
  ```
  
  MyOtherPluginPlugin.php
  
  ```
  public function modifyTest(&$test)
  {
      $test = false;
  }
  
  ```
  
  
  ---
  
  ### Answer by username_0 on 2015-07-30. Score: 2
  
  It looks like it doesn't updated the variables passed to the event directly (referenced) and you have to access the value from the `$event` object.
  
  ```
  public function setTest()
  {
      // ...
  
      $test = $event->params['test']
  
      return $test;
  }
  
  ```
  
  > **Comments:**
  > **username_1**: Sounds like you may need a custom **hook**, instead of an event. Generally speaking, events aren't supposed to modify the data which triggered it.  
  > **username_0**: Totally right, a hook is really the better solution to do this. Thank you!  
  
  ---
  
  