CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Almost created a simple report extension
Pages: [1]

Author Topic: Almost created a simple report extension  (Read 1412 times)

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Almost created a simple report extension
July 31, 2013, 07:10:43 pm
I thought I was going to celebrate figuring out how to create a report extension to make a simple change to a report: http://forum.civicrm.org/index.php/topic,29568.0.html .
Unfortunately, I hit a snag ... http://forum.civicrm.org/index.php/topic,29569.0.html .

The issue seems to be pretty clear, ie need to change the class to include "_Form" in the name ... however, when I change the name, the extension fails (no error, just a 500 error.)  I thought I needed to match the Info.xml key to the class name, but any time I change it at all from what civix generated (ie. class com_shawnholt_newreport extends CRM_Report_Form_Event ) the extension fails :(. 
To create the extension I simply ran:
civix generate:report --copy=CRM_Report_Form_Event_ParticipantListing CRM_Report_Form_Event_PartCust CiviEvent

I changed the info.xml to some reasonable values (leaving extension key="com.shawnholt.newreport" type="report")

Why can't I change the class name? even tried extension key="com.shawnholt.newreport_Form" and class com_shawnholt_newreport_Form extends CRM_Report_Form_Event and that didn't work.

Each time I tested I uninstalled the previous version.

So much pretending to be a programmer :).

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Almost created a simple report extension
August 01, 2013, 11:46:34 am
It might help if you could post a link to the code.

Some general thoughts:

1. It is (unfortunately) possible to create a report extension in two different ways, and civix supports both, but the forum post includes some hints that some up aspects of the two techniques are getting mixed-up. The two techniques are:

 * Create a specialized extension of type "report" (The class name would often look the com_shawnholt_newreport.) The corresponding civix command is "civix generate:report-ext". There's a chunk of metadata in the info.xml. This is the older style (Civi 3.x), but it's less flexible.

 * Create a generic extension of type "module" and add in some reports. (The class name would often look like CRM_Report_Form_Foo_Bar".) The corresponding civix commands are "civix generate:module" and then "civix generate:report". There's a chunk of metadata in a file like "CRM/Report/Form/Foo/Bar.mgd.php".

2. When renaming a class or function, it's usually good to search the entire code-base for extra references to the old name. (e.g. in unix "grep -r CRM_Old_Class /path/to/my/extension".

3. If I were you, I'd try making a new, skeletal extension with civix and make sure the skeleton works. (Since the goal is to have "_Form" in the name, use "civix generate:module" + "civix generate:report" to make the new skeleton.) Then copy the code from your old PHP class into the new PHP class.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Almost created a simple report extension

This forum was archived on 2017-11-26.