Skip to content

Code Functional Reference

Robert Spencer edited this page May 10, 2024 · 8 revisions

Functional References

Sometimes you just need a 10,000 foot "birds eye view" of what's going on inside the code. Here's the place.

Environment Variables (dto classes)

Beginning in 2.4.0, we began converting global variables to static classes. This gives us more flexibility and clarity when referring to these necessary variables.

If you find yourself tempted to add to the legacy Include/Functions.php file, please evaluate whether the function would be better placed in a static class.

  • SystemURLs

    • Document Root - The physical path of ChurchCRM on the server. i.e. /var/www/html/ChurchCRM
    • Root Path - The path of ChurchCRM relative to the current domain. i.e. http://www.domain.com**/churchCRM**
  • SystemConfig

    • Read / Write access to all of the system configuration options found in System Settings | General Settings

Object Model / SQL

  • We use PropelORM to provide a PHP object model for database entities
  • These classes are automatically generated at build time, and are located at src/ChurchCRM/model/*
  • As of 2.4.0, there is still a lot of legacy code that relies on direct calls to SQL. These should all be replaced by ORM calls

schema.xml is used to automatically generate the base model like this:

/propel/schema.xml ---> (/propel/propel.php) ----|---> /src/ChurchCRM/model/ChurchCRM/Base
                                                 |---> /src/ChurchCRM/model/ChurchCRM/Map

To debug the ORM queries, you can use syntax similar to the following:

$rawSql = (new BookQuery)::create()->filterById(25)->toString();

Source: Propel: Get Raw SQL from Query object?

Changes to the Database Schema

Any change to the database schema must increment the minor revision number by one. (i.e: 2.x.0.).

Schema changes must be applied to:

  • The UI pages that reference the changes
  • The Schema.xml document used to generate the ORM
  • The Install.sql file used for initial installation
  • The Upgrade.sql file to be used during the upgrade of existing installations
  • The ChurchCRM-Database.sql file in the demo directory for TravisCI tests to pass

Legacy Code

There is a lot of legacy code that obscures the line between logic and page rendering. Wherever possible, program / business logic should be separate from page rendering.

JavaScript

We have a window.CRM object: window.CRM.root represents the $sRootPath path as defined in Include/Config.php

Clone this wiki locally