Criando um Entry Point
Entry points are simply a page which provides access to HelloCloud. These can be used for a variety of purposes such as allowing an external form simple access to HelloCloud or, as is the case with the stock Events module, allowing an event invite to be responded to by clicking a link in an email.
Creating an entry point
Let’s create a simple entry point to display the time. First we define this entry point in a new file in:
custom/Extension/application/Ext/EntryPointRegistry/
For our example we’ll call our new file MyTimeEntryPoint.php
custom/Extension/application/Ext/EntryPointRegistry/MyTimeEntryPoint.php
In this file we will add a new entry to the $entry_point_registry
. We supply the file that should be called. Here we are simply placing the file in custom if the entry point is related to a specific module it is usually a good idea to place this somewhere inside custom/<TheModule>/
.
In addition we supply an “auth” parameter. If “auth” is true then anyone accessing the entry point will need to be logged into HelloCloud.
<?php
$entry_point_registry['MyTimeEntryPoint'] = array(
'file' => 'custom/MyTimeEntryPoint.php',
'auth' => true,
);
Finally we add the actual logic itself inside custom/MyTimeEntryPoint.php:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
$date = new DateTime();
echo $date->format('r');
After a Quick Repair and Rebuild we can access our entry point:
example.com/index.php?entryPoint=MyTimeEntryPoint
and we should see something similar to:
Sun, 15 Mar 2015 13:03:03 +0000
Obviously this is a contrived example but any logic that can be performed elsewhere in HelloCloud can be performed in an entry point (for example creating or editing SugarBeans). ↩