AllToolKits.com Posted June 10, 2015 Report Posted June 10, 2015 Hi, In a plugin i have below code public function getEvents() { return array( array( 'event' => "Services.add", 'callback' => array("this", "myAction") ) ); } public function myAction($event) { $params = $event->getParams(); echo "<pre>"; print_r($params); } This code is calling when a new service is added. $params do have many details like service id and many other info. I need package details too here. When adding a package i am giving few informations under module options, but i can't see that in $params . How i can get those package details in the function myAction?
Tyson Posted June 11, 2015 Report Posted June 11, 2015 The service event includes information specific to the service, but does not include package info. See the Event Handlers docs for data that may be included.
AllToolKits.com Posted June 11, 2015 Author Report Posted June 11, 2015 From the Services.add section in the page http://docs.blesta.com/display/dev/Event+Handlers it has below information configoptions - An array of key/value pairs of package options where the key is the package option ID and the value is the option value (any other service field data passed to the module) But that part is missing in the $params. Everything else is there. everything else is there.
Tyson Posted June 11, 2015 Report Posted June 11, 2015 configoptions are only included if they are given when the service is created. The same is true for other fields as well. You shouldn't assume that every field will be given. vars - An array of input data which may include: ... configoptions - An array of key/value pairs of package options where the key is the package option ID and the value is the option value (any other service field data passed to the module) ...
AllToolKits.com Posted June 11, 2015 Author Report Posted June 11, 2015 I got what i want now $params = $event->getParams(); $service_id = (int) $params['service_id']; Loader::loadModels($this, array("Services", "Packages")); $details = $this->Services->get( $service_id); $package_id = (int) $details->package->id; $p_details = $this->Packages->get($package_id); $meta_array = array(); $meta_array = $p_details->meta; serge, Tikweb and Blesta Addons 3
Tikweb Posted March 6, 2017 Report Posted March 6, 2017 On 6/11/2015 at 6:34 PM, AllToolKits.com said: I got what i want now $params = $event->getParams(); $service_id = (int) $params['service_id']; Loader::loadModels($this, array("Services", "Packages")); $details = $this->Services->get( $service_id); $package_id = (int) $details->package->id; $p_details = $this->Packages->get($package_id); $meta_array = array(); $meta_array = $p_details->meta; Expand Thank you AllToolKits.com, I have got a big solution from your code. Blesta doesn't give package id in Invoice. i go to service class then get package id.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now