Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Using The Event Notification System With The Api? Rate Topic   - - - - -

 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 07 September 2020 - 07:28 AM #1

Hi, I'm trying to extend the functionality of the API for 'Reset Password' similar to what the normal CS-Cart system does. But I get an error whenever I put

 $event_dispatcher = Tygh::$app['event.dispatcher'];

The error being:

Class 'Tygh\Api\Entities\Tygh' not found

Does this mean I can't use the event system through the API? If I can and I'm just doing something wrong, how do I solve this problem?



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11791 posts

Posted 07 September 2020 - 08:00 PM #2

*
POPULAR

Try using: 

$event_dispatcher = \Tygh::$app['event.dispatcher'];

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 08 September 2020 - 12:26 AM #3

It worked! Thank you so much! Could I use the mailer in the same way? 

Meaning:
 

$mailer = \Tygh::$app['mailer']


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11791 posts

Posted 08 September 2020 - 05:49 PM #4

You only need to escape the class when it is nested inside another file that has a 'use' clause that conflicts with the base classes.  So if you find that it's looking for the Tygh class inside of another class, use the escape.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 09 September 2020 - 01:43 AM #5

Noted, thank you very much!