Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • ActionMetaData
  • ActionText
  • Admin
  • AmorphousModel
  • ApiHook
  • APIModel
  • ChartSetting
  • ContactForm
  • ContactList
  • Credentials
  • Criteria
  • Dropdowns
  • Events
  • EventsData
  • Fields
  • FormLayout
  • Imports
  • InlineEmail
  • LeadRouting
  • Locations
  • LoginForm
  • Maps
  • Modules
  • Notes
  • Notification
  • PhoneNumber
  • Profile
  • Record
  • Relationships
  • Roles
  • RoleToPermission
  • RoleToUser
  • RoleToWorkflow
  • Rules
  • Session
  • SessionLog
  • Social
  • Tags
  • TempFile
  • Tips
  • Tours
  • TrackEmail
  • TriggerLog
  • URL
  • ViewLog
  • Widgets
  • X2List
  • X2ListCriterion
  • X2ListItem
  • X2Model
  • Overview
  • Package
  • Class
  • Tree

Class ApiHook

Handles External API subscriptions (for pushing data).

This model record is for managing "subscriptions" to events in X2Engine. The purpose behind this all is to allow a means to enact changes to other systems in response to events in X2Engine without the need for polling.

Each time X2Flow::trigger() is called, all hooks matching the name of the triggering event will also be called. Then, POST requests will be sent to the URL specified by the "target_url" attribute, and the payload will be either arbitrary data, or a URL within the REST API at which to retrieve the payload (if the payload is an instance of X2Model). Each record of this model type is thus in effect a request to either send data to a remote service, or notify that remote service that it needs to fetch data from X2Engine at a given resource location.

CComponent
Extended by CModel implements IteratorAggregate, ArrayAccess
Extended by CActiveRecord
Extended by ApiHook
Package: application\models
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/models/ApiHook.php
Methods summary
public array
# attributeLabels( )

Returns the attribute labels. Attribute labels are mainly used in error messages of validation. By default an attribute label is generated using CModel::generateAttributeLabel(). This method allows you to explicitly specify attribute labels.

Returns the attribute labels. Attribute labels are mainly used in error messages of validation. By default an attribute label is generated using CModel::generateAttributeLabel(). This method allows you to explicitly specify attribute labels.

Note, in order to inherit labels defined in the parent class, a child class needs to merge the parent labels with child labels using functions like array_merge().

Returns

array
attribute labels (name=>label)

See

CModel::generateAttributeLabel()

Overrides

CModel::attributeLabels()
public boolean
# beforeDelete( )

Sends a deletion request to the "subscription" URL

Sends a deletion request to the "subscription" URL

Returns

boolean
whether the record should be deleted. Defaults to true.

Overrides

CActiveRecord::beforeDelete()
public static array
# criteria( string $event, string $modelName, integer $userId )

Composes and returns a CDbCriteria-compatible property array for querying hooks for any given event.

Composes and returns a CDbCriteria-compatible property array for querying hooks for any given event.

Creates the criteria properties for fetching all hooks for a specified model name, event name and user ID.

Parameters

$event
string
$event Event name
$modelName
string
$modelName Model name associated with the hook; used for distinguishing generic events such as "a record was created"
$userId
integer
$userId run hooks for a user with this ID.

Returns

array
public type
# getMaxNHooks( )

Getter w/stripped code (Platinum-only settings) for the maximum number of API hooks to send.

Getter w/stripped code (Platinum-only settings) for the maximum number of API hooks to send.

Returns

type
public
# getStatus( )

Returns the last status code

Returns the last status code

public
# getTimeout( )
public boolean
# insert( array $attributes = null )

Inserts a row into the table based on this active record attributes. If the table's primary key is auto-incremental and is null before insertion, it will be populated with the actual value after insertion. Note, validation is not performed in this method. You may call CModel::validate() to perform the validation. After the record is inserted to DB successfully, its isNewRecord property will be set false, and its scenario property will be set to be 'update'.

Inserts a row into the table based on this active record attributes. If the table's primary key is auto-incremental and is null before insertion, it will be populated with the actual value after insertion. Note, validation is not performed in this method. You may call CModel::validate() to perform the validation. After the record is inserted to DB successfully, its isNewRecord property will be set false, and its scenario property will be set to be 'update'.

Parameters

$attributes
array
$attributes list of attributes that need to be saved. Defaults to null, meaning all attributes that are loaded from DB will be saved.

Returns

boolean
whether the attributes are valid and the record is inserted successfully.

Throws

CDbException
if the record is not new

Overrides

CActiveRecord::insert()
public
# maxBatchSize( type $attribute, type $params = array() )

Validator for limiting the number of hooks on a given action.

Validator for limiting the number of hooks on a given action.

Parameters

$attribute
type
$attribute
$params
type
$params
public static static
# model( string $className = __CLASS__ )

Returns the static model of the specified AR class. The model returned is a static instance of the AR class. It is provided for invoking class-level methods (something similar to static class methods.)

Returns the static model of the specified AR class. The model returned is a static instance of the AR class. It is provided for invoking class-level methods (something similar to static class methods.)

EVERY derived AR class must override this method as follows,

public static function model($className=__CLASS__)
{
    return parent::model($className);
}

Parameters

$className
string
$className active record class name.

Returns

static
active record model instance.

Overrides

CActiveRecord::model()
public array
# rules( )

Returns the validation rules for attributes.

Returns the validation rules for attributes.

This method should be overridden to declare validation rules. Each rule is an array with the following structure:

array('attribute list', 'validator name', 'on'=>'scenario name', ...validation parameters...)
where
  • attribute list: specifies the attributes (separated by commas) to be validated;
  • validator name: specifies the validator to be used. It can be the name of a model class method, the name of a built-in validator, or a validator class (or its path alias). A validation method must have the following signature:
    // $params refers to validation parameters given in the rule
    function validatorName($attribute,$params)
    
    A built-in validator refers to one of the validators declared in CValidator::builtInValidators. And a validator class is a class extending CValidator.
  • on: this specifies the scenarios when the validation rule should be performed. Separate different scenarios with commas. If this option is not set, the rule will be applied in any scenario that is not listed in "except". Please see scenario for more details about this option.
  • except: this specifies the scenarios when the validation rule should not be performed. Separate different scenarios with commas. Please see scenario for more details about this option.
  • additional parameters are used to initialize the corresponding validator properties. Please refer to individual validator class API for possible properties.

The following are some examples:

array(
    array('username', 'required'),
    array('username', 'length', 'min'=>3, 'max'=>12),
    array('password', 'compare', 'compareAttribute'=>'password2', 'on'=>'register'),
    array('password', 'authenticate', 'on'=>'login'),
);

Note, in order to inherit rules defined in the parent class, a child class needs to merge the parent rules with child rules using functions like array_merge().

Returns

array
validation rules to be applied when CModel::validate() is called.

See

scenario

Overrides

CModel::rules()
public ApiHook
# run( X2Model $output )

Runs the API hook; sends data to the third-party service.

Runs the API hook; sends data to the third-party service.

Parameters

$output
X2Model
$output The relevant model object

Returns

ApiHook
public static
# runAll( string $event, mixed $output = null, integer $userId = null )

Runs all API hooks corresponding to an event, a model (or arbitrary payload), and a user.

Runs all API hooks corresponding to an event, a model (or arbitrary payload), and a user.

Parameters

$event
string
$event Name of the event
$output
mixed
$output The relevant model object
$userId
integer
$userId the ID of the acting user in running the API hook
public
# send( string $method, array $data )

Sends a request to pull data from X2Engine, or to delete/unsubscribe.

Sends a request to pull data from X2Engine, or to delete/unsubscribe.

Parameters

$method
string
$method Request method to use
$data
array
$data an array to JSON-encode and send
public string
# tableName( )

Returns the name of the associated database table. By default this method returns the class name as the table name. You may override this method if the table is not named after this convention.

Returns the name of the associated database table. By default this method returns the class name as the table name. You may override this method if the table is not named after this convention.

Returns

string
the table name

Overrides

CActiveRecord::tableName()
Methods inherited from CActiveRecord
__call(), __construct(), __get(), __isset(), __set(), __sleep(), __unset(), addRelatedRecord(), afterDelete(), afterFind(), afterFindInternal(), afterSave(), applyScopes(), attributeNames(), beforeCount(), beforeFind(), beforeFindInternal(), beforeSave(), cache(), count(), countByAttributes(), countBySql(), defaultScope(), delete(), deleteAll(), deleteAllByAttributes(), deleteByPk(), equals(), exists(), find(), findAll(), findAllByAttributes(), findAllByPk(), findAllBySql(), findByAttributes(), findByPk(), findBySql(), getActiveFinder(), getActiveRelation(), getAttribute(), getAttributeLabel(), getAttributes(), getCommandBuilder(), getDbConnection(), getDbCriteria(), getIsNewRecord(), getMetaData(), getOldPrimaryKey(), getPrimaryKey(), getRelated(), getTableAlias(), getTableSchema(), hasAttribute(), hasRelated(), init(), instantiate(), offsetExists(), onAfterDelete(), onAfterFind(), onAfterSave(), onBeforeCount(), onBeforeDelete(), onBeforeFind(), onBeforeSave(), populateRecord(), populateRecords(), primaryKey(), query(), refresh(), refreshMetaData(), relations(), resetScope(), save(), saveAttributes(), saveCounters(), scopes(), setAttribute(), setDbCriteria(), setIsNewRecord(), setOldPrimaryKey(), setPrimaryKey(), setTableAlias(), together(), update(), updateAll(), updateByPk(), updateCounters(), with()
Methods inherited from CModel
addError(), addErrors(), afterConstruct(), afterValidate(), beforeValidate(), behaviors(), clearErrors(), createValidators(), generateAttributeLabel(), getError(), getErrors(), getIterator(), getSafeAttributeNames(), getScenario(), getValidatorList(), getValidators(), hasErrors(), isAttributeRequired(), isAttributeSafe(), offsetGet(), offsetSet(), offsetUnset(), onAfterConstruct(), onAfterValidate(), onBeforeValidate(), onUnsafeAttribute(), setAttributes(), setScenario(), unsetAttributes(), validate()
Methods inherited from CComponent
asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Constants summary
integer MAX_API_HOOK_BATCH 3
#

No more than this number of remote hooks can run at a time.

No more than this number of remote hooks can run at a time.

integer MAX_WAIT_TIME 3
#

Hook timeout after 3 seconds

Hook timeout after 3 seconds

Constants inherited from CActiveRecord
BELONGS_TO, HAS_MANY, HAS_ONE, MANY_MANY, STAT
Properties summary
public mixed $sent false
#

Response data, or false if no requests have yet been sent.

Response data, or false if no requests have yet been sent.

Properties inherited from CActiveRecord
$db
Magic properties inherited from CActiveRecord
$attributes, $commandBuilder, $dbConnection, $dbCriteria, $isNewRecord, $metaData, $oldPrimaryKey, $primaryKey, $tableAlias, $tableSchema
Magic properties inherited from CModel
$errors, $iterator, $safeAttributeNames, $scenario, $validatorList, $validators
X2CRM Documentation API documentation generated by ApiGen 2.8.0