ePages 6.11.0 - DE_EPAGES/Object/API/Object/DALObject.pm

Package DE_EPAGES::Object::API::Object::DALObject

object interface for BaseObjects.

Base
DE_EPAGES::Core::API::Object::BaseObject

Functions

canDelete
class
className
clone
dal
dalPackage
dbPackage
deleteAttributes
deleteXML
exportXMLAttributes
exportXMLElements
exportXMLLanguageElements
exportableAttributes
findXML
get
id
importXML
instanceOf
onDeleteClass
primaryKey
recursiveGet
reset
set
slavePrimaryKey
tagNameXML
tleHash
triggerGetHook

canDelete

Tests if the object can be deleted. If there is any reason why the object should not be deleted, these reasons are appended to the @$aWarnings list. Calls DE_EPAGES::Object::API::BaseAttribute::canDeleteObject for each attribute package of the object's class.

Syntax
$Object->canDelete($aWarnings);
Example
my @Warnings;
$Object->canDelete( \@Warnings );
if( scalar @Warnings ) {
    print "Object can't be deleted, because: ";
    print join( ", ", map { $_->shortMessage } @Warnings );
}
else {
    $Object->delete;
}
Input
$aWarnings (array.ref)
array of Warning Objects

class

Returns the class of an object

Syntax
$Class = $BaseObject->class;
Return
$Class (object)
class object, see DE_EPAGES::Object::API::Object::Class

className

Returns name of class.

Syntax
$Key = $Package->className();
Return
$Key (string)
'BaseObject'

clone

Inserts a new object into the database as copy from old object.

Syntax
$Clone = $DALObject->clone( $hInfo );
Input
$hInfo (hash ref)
hash with attribute values that are different in the clone
object.
Return
$Clone (object)
the new object

dal

Returns name of dal.

Syntax
$DalPackage = $Package->dal();
Return
$Dal (object)
instance of dbPackage use to access objects

dalPackage

Returns name of dal.

Syntax
$DalPackage = $Package->dalPackage();
Return
$DalPackage (string)
'DE_EPAGES::Database::API::DAL'

dbPackage

Returns name for this class used by dal.

Syntax
$DbPackage = $Package->dbPackage();
Return
$DalPackage (string)
'DE_EPAGES::Object::API::Object::BaseObject'

deleteAttributes

Deletes the object attributes. Called by delete.

Syntax
$Object->deleteAttributes;

deleteXML

Called by the SAX driver when a start tag for the current object class is encountered. The function identifies the object by the attributes in $hAttributes and deletes the object if it still exists and and the attribute 'delete="1"' is specified.

Syntax
$Object = DE_EPAGES::Object::API::Object::Object->deleteXML($Handler, $hElement, $hAttributes, $Class);
Input
$ObjectPackage (string)
package name of the objects's class
$Handler (object)
xml delete handler
$hElement (ref.hash)
information about the start tag, see SAX function start_element
$hAttributes (ref.hash)
attributes of the start tag
$Class (object)
class object; the new object will be an instance of this class
Return
$Object (object)
the found object if it still exists

exportXMLAttributes

Returns plain attributes of object to XML export driver. This function removes string attributes with newlines, adds object to each level.

Syntax
$hAttributes = $Object->exportXMLAttributes( $Driver, $hAllAttributes );
Input
$Driver (object)
xml export driver with support function addObject
$hAllAttributes (ref.hash)
all attributes of object,
see $Object->allAttributes
Return
$hAttributes (ref.hash.string)
plain attributes

exportXMLElements

Exports multilinguagal attribute value of this object to the xml SAX driver.

Syntax
$Object->exportXMLElements($Driver, $hAllAttributes);
Input
$Driver (object)
export driver
$hAllAttributes (ref.hash)
all attributes of object,
see $Object->allAttributes

exportXMLLanguageElements

Add xml elements for language dependend attributes (part of exportXMLElements), same as String attributes includes newline.

Syntax
$Object->exportXMLLanguageElements( $Driver, $hAttributes );
Input
$Driver (object)
xml export driver with support function addObject
$hAttributes (ref.hash.string)
plain attributes

exportableAttributes

Returns all attribute values that have an existing (not-null) value. Unlike $Object->_attributes this function returns localized attribute values as hash reference (language id => value).

Syntax
$hValues = $Object->exportableAttributes
Example
$Description = $Object->exportableAttributes;
Return
$hValues (hash ref)
object attributes as key => value pairs

findXML

Imports an object from an XML file. This function is called at the XML start tag.

Syntax
$ObjectID = DE_EPAGES::Object::API::Object::Object->findXML($Handler, $hElement, $Class, $hAttributes);
Input
$Handler (object)
xml import handler with support function addObject
$hElement (ref.hash)
XML element structure, see XML::SAX
$Class (object)
class object; the new object will be an instance of this class
$hAttributes (ref.hash)
attributes hash
Return
$ObjectID (string)
the existing object id or undef

get

Returns one or more attribute values.

Syntax
$Value = $Object->get( $Name, $LanguageID );
$hValues = $Object->get( $aNames, $LanguageID );
Example
$Password = $Object->get( 'Password' );
$Password = $Object->get( ['Login', 'Password'] )->{'Password'};
Input
$Name (string)
attribute name
$aNames (array ref)
list of attribute names
$LanguageID (integer)
language identifier (optional)
Return
$hValues (hash ref)
name => value pairs
$Value (string (or other))
attribute value

id

Returns the base-object id.

Syntax
$BaseObjectID = $BaseObject->id;
Return
$BaseObjectID (string)
object id

importXML

Imports an object from an XML file. This function is called at the XML start tag.

Syntax
$Object = DE_EPAGES::Object::API::Object::Object->importXML($Handler, $hElement, $Class, $hAttributes);
Input
$Handler (object)
xml import handler with support function addObject
$hElement (ref.hash)
XML element structure, see XML::SAX
$Class (object)
class object; the new object will be an instance of this class
$hAttributes (ref.hash)
attributes hash
Return
$Object (object)
the imported object

instanceOf

Returns true if the object is an instance of the class or one of its sub classes.

Syntax
$IsInstance = $BaseObject->instanceOf( $Class )
$IsInstance = $BaseObject->instanceOf( $ClassName )
Example
my $ClassProduct = LoadClassByAlias( 'Product' );
if( $Object->instanceOf( $ClassProduct ) ) { ... }
if( $Object->instanceOf('Product' ) ) { ... }
Input
$ClassName (object)
name of class (or object of class) | string
Return
$IsInstance (boolean)
true if the object is an instance of the class

onDeleteClass

Called before the class of this object is deleted. The default implementation calls $self->delete.

Syntax
$BaseObject->onDeleteClass;

primaryKey

Returns name of identifier of master table.

Syntax
$Key = $Package->primaryKey();
Return
$Key (string)
'BaseObjectID'

recursiveGet

Obsolete. Do not use.

reset

Removes internal cache key class.

Syntax
$Object->reset;

set

Sets the given attribute values on the object.

Syntax
$Object->set($hValues, $LanguageID);
Input
$hValues (ref.hash)
attribute name => value hash
$LanguageID (integer)
(optional) language id for localized attributes

slavePrimaryKey

Returns name of identifier of slave table

Syntax
$Key = $Package->slavePrimaryKey();
Return
$Key (string)
'BaseObjectID'

tagNameXML

Returns the tag name to use in XML export/import. By default, the tag name is the Alias of the class.

Syntax
$TagName = $Object->tagNameXML;
Return
$TagName (string)
xml tag name

tleHash

Returns a tied hash for the TLE compiler.

Syntax
$BaseObject->tleHash;

triggerGetHook

Triggers a hook for $Object->get.

Syntax
$hValues = $Object->triggerGetHook( $HookName, $aNames, $LanguageID, $Sub );
$Value = $Object->triggerGetHook( $HookName, $Name, $LanguageID, $Sub );
Example
return $self->triggerGetHook('OBJ_GetDownloadProductMap', $aNames, $LanguageID, sub {
    my ($_aNames, $_LanguageID) = @_;
    return $self->SUPER::get($_aNames, $_LanguageID)
});
Input
$HookName (string)
package name of the objects's class
$aNames (ref.array.string)
list of attribute names
$Name (string)
attribute name
$LanguageID (int)
language id
$Sub (ref.code)
code reference