Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8467929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:47:17+00:00 2026-06-10T15:47:17+00:00

When reading YIi guide at this link: http://www.yiiframework.com/wiki/327/events-explained/ , I have see this line:

  • 0

When reading YIi guide at this link: http://www.yiiframework.com/wiki/327/events-explained/, I have see this line:

…So earlier before raising the event we should have called, maybe inside the initialization method of the component, something like this:

$myComponent->onForestRan = array(new SomeOtherClass, 'eventHandler1');

I understand that this code will attach a handler to event, and the array on the left-hand side is a PHP callback function. However, what I really don’t understand is its syntax, does it call a onforestRan() function (which is previously defined on $component–> see the Yii link above), if so it will not valid as it lack of $event argument. Or, if it is a callback, then I have never seen a way of using callback like this (if it is a callback where is call_user_func() or usort()..). Its syntax is really odd to me.
Could some one help me with this?
Thank so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:47:18+00:00Added an answer on June 10, 2026 at 3:47 pm

    It’s not a callback perse, but you’re telling Yii what action (i.e. what function) to perform on the event.

    In the example given, when onForestRan happens, the eventHandler1 function from SomeOtherClass will be triggered.

    When that page describes a callback, it’s saying that whatever you assign to $myComponent->onForestRan needs to be a callback function. The callback isn’t executed at that point, you’re just letting Yii know which callback(s) to use when the event occurs.

    More details:

    onForestRan is a special property of $myComponent, as documented here. More details can be seen in CComponent. You can search the CComponent source for lines similar to line 113, where you can see the beginning of the logic for the special property. This is very similar to action* methods in the controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading this list of Chrome match patterns: http://code.google.com/chrome/extensions/match_patterns.html How do I specify a match
Reading through the CKEditor documentation , I see that they have an option to
reading this https://developers.google.com/in-app-payments/docs/tutorial Quoted from the above page: Because you sign the JWT using
I'm reading the Yii blog tutorial . What does this code do foreach($models as
Reading this: http://guides.rubyonrails.org/routing.html#adding-more-restful-actions What does it mean to add a 'member route'? or do
Reading manual about Sling http://sling.apache.org/site/46-line-blog.html added folder blog and blog.html to destination: \launchpad\content\src\main\resources\content\ but
Reading the Scala by Example book and there is this example when Martin explains
Reading through this excellent article about safe construction techniques by Brain Goetz, I got
Reading about the Dispose pattern , I see the documentation repeatedly refer to cleaning
Reading source code of my current project, I see: [self retain] in one class,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.