PHP Class Sulu\Bundle\ContactBundle\Contact\AbstractContactManager

Inheritance: implements Sulu\Bundle\ContactBundle\Contact\ContactManagerInterface, use trait Sulu\Component\Persistence\RelationTrait
Show file Open project: sulu/sulu Class Usage Examples

Protected Properties

Property Type Description
$accountContactEntityName
$addressEntityName
$addressTypeEntityName
$categoryEntityName
$countryEntityName
$em Doctrine\Common\Persistence\ObjectManager
$emailEntityName
$emailTypeEntityName
$faxTypeEntityName
$mediaManager Sulu\Bundle\MediaBundle\Media\Manager\MediaManagerInterface
$phoneEntityName
$phoneTypeEntityName
$positionEntityName
$tagManager Sulu\Bundle\TagBundle\Tag\TagManagerInterface
$urlEntityName
$urlTypeEntityName

Public Methods

Method Description
__construct ( Doctrine\Common\Persistence\ObjectManager $em, Sulu\Bundle\TagBundle\Tag\TagManagerInterface $tagManager, Sulu\Bundle\MediaBundle\Media\Manager\MediaManagerInterface $mediaManager )
addNewContactRelations ( Contact $contact, array $data ) adds new relations.
contactIsEmployeeOfAccount ( $contact, $account ) : boolean checks if an account is employee of a company.
createMainAccountContact ( Contact $contact, Sulu\Bundle\ContactBundle\Entity\AccountInterface $account, $position = null ) : AccountContact creates a new main Account Contacts relation.
deleteAddresses ( $entity ) deletes all addresses that are assigned to entity.
deleteAllRelations ( $entity ) clears all relational data from entity and deletes it.
deleteEmails ( $entity ) deletes all emails that are assigned to entity.
deleteFaxes ( $entity ) deletes all faxes that are assigned to entity.
deleteNotes ( $entity ) deletes all notes that are assigned to entity.
deletePhones ( $entity ) deletes all phones that are assigned to entity.
deleteUrls ( $entity ) deletes all urls that are assigned to entity.
getAccounContact ( Sulu\Bundle\ContactBundle\Entity\AccountInterface $account, Contact $contact ) : null | AccountContact Returns AccountContact relation if exists.
getAddressByCondition ( Sulu\Bundle\ContactBundle\Entity\AccountInterface | Contact $entity, callable $conditionCallback, boolean $force = false ) : mixed Returns an address by callback-condition.
getAddressTypeByName ( $name ) : mixed return address type by name.
getBillingAddress ( Sulu\Bundle\ContactBundle\Entity\AccountInterface | Contact $entity, boolean $force = false ) : mixed Returns the billing address of an account/contact.
getDeliveryAddress ( Sulu\Bundle\ContactBundle\Entity\AccountInterface | Contact $entity, boolean $force = false ) : mixed Returns the delivery address.
getEmailTypeByName ( $name ) : mixed return email type by name.
getFaxTypeByName ( $name ) : mixed return fax type by name.
getMainAccountContact ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $contact ) : AccountContact | boolean returns the main account-contact relation.
getPhoneTypeByName ( $name ) : mixed return phone type by name.
getPosition ( $data ) : mixed Get a position object.
getTagManager ( ) : Sulu\Bundle\TagBundle\Tag\TagManagerInterface Returns the tag manager.
getUrlTypeByName ( $name ) : mixed return url type by name.
processAddresses ( $contact, array $addresses ) : boolean Process all addresses from request.
processBankAccounts ( $contact, $bankAccounts ) : boolean Process all bankAccounts of a request.
processCategories ( $contact, $categories ) : boolean Process all categories of request.
processEmails ( $contact, $emails ) : boolean Process all emails from request.
processFaxes ( $contact, array $faxes ) : boolean
processNotes ( Contact $contact, $notes ) : boolean Process all notes from request.
processPhones ( $contact, $phones ) : boolean Process all phones from request.
processTags ( $contact, array $tags ) : boolean Process all tags of request.
processUrls ( $contact, array $urls ) : boolean Process all urls of request.
setMainEmail ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity ) sets Entity's Main-Email.
setMainFax ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity ) sets Entity's Main-Fax.
setMainForCollection ( $arrayCollection ) sets the first element to main, if none is set.
setMainPhone ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity ) sets Entity's Main-Phone.
setMainUrl ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity ) sets Entity's Main-Url.
unsetMain ( $arrayCollection ) : boolean unsets main of all elements of an ArrayCollection | PersistanceCollection.

Protected Methods

Method Description
addBankAccount ( $contact, $data ) : boolean Add a new note to the given contact and persist it with the given object manager.
addCategories ( $contact, $data ) : boolean Adds a new category to the given contact.
addEmail ( Contact $contact, array $emailData ) : boolean Adds a new email to the given contact and persist it with the given object manager.
addFax ( $contact, array $faxData )
addNote ( $contact, array $noteData ) : boolean Add a new note to the given contact and persist it with the given object manager.
addPhone ( $contact, array $phoneData ) : boolean Add a new phone to the given contact and persist it with the given object manager.
addTag ( $contact, $data ) : boolean Adds a new tag to the given contact and persist it with the given object manager.
addUrl ( $contact, $data ) : boolean Adds a new tag to the given contact.
checkAndSetMainAddress ( $addresses ) : mixed sets main address.
createAddress ( array $addressData, &$isMain = null ) : Address Creates an address based on the data passed.
deleteAllEntitiesOfCollection ( $arrayCollection )
getBooleanValue ( $value ) : boolean Checks if a value is a boolean and converts it if necessary and returns it.
updateAddress ( Address $address, mixed $entry, boolean &$isMain = null ) : boolean Updates the given address.
updateBankAccount ( BankAccount $entity, string $data ) : boolean Updates the given note.
updateEmail ( Email $email, array $entry ) : boolean Updates the given email address.
updateFax ( Fax $fax, $entry ) : boolean
updateNote ( Note $note, array $entry ) : boolean Updates the given note.
updatePhone ( Phone $phone, $entry ) : boolean Updates the given phone.
updateUrl ( Url $url, $entry ) : boolean

Private Methods

Method Description
getAddresses ( Sulu\Bundle\ContactBundle\Entity\AccountInterface | Contact $entity ) : Doctrine\Common\Collections\Collection | null returns addresses from account or contact.
getProperty ( array $data, string $key, string $default = null ) : string | null Return property for key or given default value.
hasMain ( $arrayCollection, &$mainEntity = null ) : mixed checks if a collection for main attribute.
resetIndexOfSubentites ( mixed $entities ) TODO: this is just a hack to avoid relations that start with index != 0 otherwise deserialization process will parse relations as object instead of an array reindex entities.

Method Details

__construct() public method

public __construct ( Doctrine\Common\Persistence\ObjectManager $em, Sulu\Bundle\TagBundle\Tag\TagManagerInterface $tagManager, Sulu\Bundle\MediaBundle\Media\Manager\MediaManagerInterface $mediaManager )
$em Doctrine\Common\Persistence\ObjectManager
$tagManager Sulu\Bundle\TagBundle\Tag\TagManagerInterface
$mediaManager Sulu\Bundle\MediaBundle\Media\Manager\MediaManagerInterface

addBankAccount() protected method

Add a new note to the given contact and persist it with the given object manager.
protected addBankAccount ( $contact, $data ) : boolean
$contact
$data
return boolean

addCategories() protected method

Adds a new category to the given contact.
protected addCategories ( $contact, $data ) : boolean
$contact
$data
return boolean

addEmail() protected method

Adds a new email to the given contact and persist it with the given object manager.
protected addEmail ( Contact $contact, array $emailData ) : boolean
$contact Sulu\Bundle\ContactBundle\Entity\Contact
$emailData array
return boolean

addFax() protected method

protected addFax ( $contact, array $faxData )
$contact
$faxData array

addNewContactRelations() public method

adds new relations.
public addNewContactRelations ( Contact $contact, array $data )
$contact Sulu\Bundle\ContactBundle\Entity\Contact
$data array

addNote() protected method

Add a new note to the given contact and persist it with the given object manager.
protected addNote ( $contact, array $noteData ) : boolean
$contact
$noteData array
return boolean True if there was no error, otherwise false

addPhone() protected method

Add a new phone to the given contact and persist it with the given object manager.
protected addPhone ( $contact, array $phoneData ) : boolean
$contact
$phoneData array
return boolean True if there was no error, otherwise false

addTag() protected method

Adds a new tag to the given contact and persist it with the given object manager.
protected addTag ( $contact, $data ) : boolean
$contact
$data
return boolean True if there was no error, otherwise false

addUrl() protected method

Adds a new tag to the given contact.
protected addUrl ( $contact, $data ) : boolean
$contact
$data
return boolean

checkAndSetMainAddress() protected method

sets main address.
protected checkAndSetMainAddress ( $addresses ) : mixed
$addresses
return mixed

contactIsEmployeeOfAccount() public method

checks if an account is employee of a company.
public contactIsEmployeeOfAccount ( $contact, $account ) : boolean
$contact
$account
return boolean

createAddress() protected method

Creates an address based on the data passed.
protected createAddress ( array $addressData, &$isMain = null ) : Address
$addressData array
$isMain returns if address is main address
return Sulu\Bundle\ContactBundle\Entity\Address

createMainAccountContact() public method

creates a new main Account Contacts relation.
public createMainAccountContact ( Contact $contact, Sulu\Bundle\ContactBundle\Entity\AccountInterface $account, $position = null ) : AccountContact
$contact Sulu\Bundle\ContactBundle\Entity\Contact
$account Sulu\Bundle\ContactBundle\Entity\AccountInterface
$position
return Sulu\Bundle\ContactBundle\Entity\AccountContact

deleteAddresses() public method

deletes all addresses that are assigned to entity.
public deleteAddresses ( $entity )
$entity

deleteAllEntitiesOfCollection() protected method

protected deleteAllEntitiesOfCollection ( $arrayCollection )
$arrayCollection

deleteAllRelations() public method

clears all relational data from entity and deletes it.
public deleteAllRelations ( $entity )
$entity

deleteEmails() public method

deletes all emails that are assigned to entity.
public deleteEmails ( $entity )
$entity

deleteFaxes() public method

deletes all faxes that are assigned to entity.
public deleteFaxes ( $entity )
$entity

deleteNotes() public method

deletes all notes that are assigned to entity.
public deleteNotes ( $entity )
$entity

deletePhones() public method

deletes all phones that are assigned to entity.
public deletePhones ( $entity )
$entity

deleteUrls() public method

deletes all urls that are assigned to entity.
public deleteUrls ( $entity )
$entity

getAccounContact() public method

Returns AccountContact relation if exists.
public getAccounContact ( Sulu\Bundle\ContactBundle\Entity\AccountInterface $account, Contact $contact ) : null | AccountContact
$account Sulu\Bundle\ContactBundle\Entity\AccountInterface
$contact Sulu\Bundle\ContactBundle\Entity\Contact
return null | Sulu\Bundle\ContactBundle\Entity\AccountContact

getAddressByCondition() public method

Returns an address by callback-condition.
public getAddressByCondition ( Sulu\Bundle\ContactBundle\Entity\AccountInterface | Contact $entity, callable $conditionCallback, boolean $force = false ) : mixed
$entity Sulu\Bundle\ContactBundle\Entity\AccountInterface | Sulu\Bundle\ContactBundle\Entity\Contact
$conditionCallback callable
$force boolean Forces function to return an address if any address is defined if no delivery address is defined it will first return the main address then any
return mixed

getAddressTypeByName() public method

return address type by name.
public getAddressTypeByName ( $name ) : mixed
$name
return mixed

getBillingAddress() public method

Returns the billing address of an account/contact.
public getBillingAddress ( Sulu\Bundle\ContactBundle\Entity\AccountInterface | Contact $entity, boolean $force = false ) : mixed
$entity Sulu\Bundle\ContactBundle\Entity\AccountInterface | Sulu\Bundle\ContactBundle\Entity\Contact
$force boolean Forces function to return an address if any address is defined if no delivery address is defined it will first return the main address then any
return mixed

getBooleanValue() protected method

Checks if a value is a boolean and converts it if necessary and returns it.
protected getBooleanValue ( $value ) : boolean
$value
return boolean

getDeliveryAddress() public method

Returns the delivery address.
public getDeliveryAddress ( Sulu\Bundle\ContactBundle\Entity\AccountInterface | Contact $entity, boolean $force = false ) : mixed
$entity Sulu\Bundle\ContactBundle\Entity\AccountInterface | Sulu\Bundle\ContactBundle\Entity\Contact
$force boolean Forces function to return an address if any address is defined if no delivery address is defined it will first return the main address then any
return mixed

getEmailTypeByName() public method

return email type by name.
public getEmailTypeByName ( $name ) : mixed
$name
return mixed

getFaxTypeByName() public method

return fax type by name.
public getFaxTypeByName ( $name ) : mixed
$name
return mixed

getMainAccountContact() public method

returns the main account-contact relation.
public getMainAccountContact ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $contact ) : AccountContact | boolean
$contact Sulu\Bundle\ContactBundle\Entity\Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface
return Sulu\Bundle\ContactBundle\Entity\AccountContact | boolean

getPhoneTypeByName() public method

return phone type by name.
public getPhoneTypeByName ( $name ) : mixed
$name
return mixed

getPosition() public method

Get a position object.
public getPosition ( $data ) : mixed
return mixed

getTagManager() public method

Returns the tag manager.
public getTagManager ( ) : Sulu\Bundle\TagBundle\Tag\TagManagerInterface
return Sulu\Bundle\TagBundle\Tag\TagManagerInterface

getUrlTypeByName() public method

return url type by name.
public getUrlTypeByName ( $name ) : mixed
$name
return mixed

processAddresses() public method

Process all addresses from request.
public processAddresses ( $contact, array $addresses ) : boolean
$contact The contact on which is worked
$addresses array
return boolean True if the processing was sucessful, otherwise false

processBankAccounts() public method

Process all bankAccounts of a request.
public processBankAccounts ( $contact, $bankAccounts ) : boolean
$contact
$bankAccounts
return boolean True if the processing was sucessful, otherwise false

processCategories() public method

Process all categories of request.
public processCategories ( $contact, $categories ) : boolean
$contact - the contact which is processed
$categories
return boolean True if the processing was successful, otherwise false

processEmails() public method

Process all emails from request.
public processEmails ( $contact, $emails ) : boolean
$contact The contact on which is worked
$emails
return boolean True if the processing was successful, otherwise false

processFaxes() public method

public processFaxes ( $contact, array $faxes ) : boolean
$contact
$faxes array
return boolean

processNotes() public method

Process all notes from request.
public processNotes ( Contact $contact, $notes ) : boolean
$contact Sulu\Bundle\ContactBundle\Entity\Contact The contact on which is worked
$notes
return boolean True if the processing was successful, otherwise false

processPhones() public method

Process all phones from request.
public processPhones ( $contact, $phones ) : boolean
$contact The contact on which is processed
$phones
return boolean True if the processing was successful, otherwise false

processTags() public method

Process all tags of request.
public processTags ( $contact, array $tags ) : boolean
$contact The contact on which is worked
$tags array
return boolean True if the processing was successful, otherwise false

processUrls() public method

Process all urls of request.
public processUrls ( $contact, array $urls ) : boolean
$contact The contact to be processed
$urls array
return boolean True if the processing was successful, otherwise false

setMainEmail() public method

sets Entity's Main-Email.
public setMainEmail ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity )
$entity Sulu\Bundle\ContactBundle\Entity\Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface

setMainFax() public method

sets Entity's Main-Fax.
public setMainFax ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity )
$entity Sulu\Bundle\ContactBundle\Entity\Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface

setMainForCollection() public method

sets the first element to main, if none is set.
public setMainForCollection ( $arrayCollection )
$arrayCollection

setMainPhone() public method

sets Entity's Main-Phone.
public setMainPhone ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity )
$entity Sulu\Bundle\ContactBundle\Entity\Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface

setMainUrl() public method

sets Entity's Main-Url.
public setMainUrl ( Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface $entity )
$entity Sulu\Bundle\ContactBundle\Entity\Contact | Sulu\Bundle\ContactBundle\Entity\AccountInterface

unsetMain() public method

unsets main of all elements of an ArrayCollection | PersistanceCollection.
public unsetMain ( $arrayCollection ) : boolean
$arrayCollection
return boolean returns true if a element was unset

updateAddress() protected method

Updates the given address.
protected updateAddress ( Address $address, mixed $entry, boolean &$isMain = null ) : boolean
$address Sulu\Bundle\ContactBundle\Entity\Address The phone object to update
$entry mixed The entry with the new data
$isMain boolean returns if address should be set to main
return boolean True if successful, otherwise false

updateBankAccount() protected method

Updates the given note.
protected updateBankAccount ( BankAccount $entity, string $data ) : boolean
$entity Sulu\Bundle\ContactBundle\Entity\BankAccount The phone object to update
$data string The entry with the new data
return boolean True if successful, otherwise false

updateEmail() protected method

Updates the given email address.
protected updateEmail ( Email $email, array $entry ) : boolean
$email Sulu\Bundle\ContactBundle\Entity\Email The email object to update
$entry array The entry with the new data
return boolean True if successful, otherwise false

updateFax() protected method

protected updateFax ( Fax $fax, $entry ) : boolean
$fax Sulu\Bundle\ContactBundle\Entity\Fax
$entry
return boolean

updateNote() protected method

Updates the given note.
protected updateNote ( Note $note, array $entry ) : boolean
$note Sulu\Bundle\ContactBundle\Entity\Note
$entry array The entry with the new data
return boolean True if successful, otherwise false

updatePhone() protected method

Updates the given phone.
protected updatePhone ( Phone $phone, $entry ) : boolean
$phone Sulu\Bundle\ContactBundle\Entity\Phone The phone object to update
$entry The entry with the new data
return boolean True if successful, otherwise false

updateUrl() protected method

protected updateUrl ( Url $url, $entry ) : boolean
$url Sulu\Bundle\ContactBundle\Entity\Url
$entry
return boolean

Property Details

$accountContactEntityName protected static property

protected static $accountContactEntityName

$addressEntityName protected static property

protected static $addressEntityName

$addressTypeEntityName protected static property

protected static $addressTypeEntityName

$categoryEntityName protected static property

protected static $categoryEntityName

$countryEntityName protected static property

protected static $countryEntityName

$em protected property

protected ObjectManager,Doctrine\Common\Persistence $em
return Doctrine\Common\Persistence\ObjectManager

$emailEntityName protected static property

protected static $emailEntityName

$emailTypeEntityName protected static property

protected static $emailTypeEntityName

$faxTypeEntityName protected static property

protected static $faxTypeEntityName

$mediaManager protected property

protected MediaManagerInterface,Sulu\Bundle\MediaBundle\Media\Manager $mediaManager
return Sulu\Bundle\MediaBundle\Media\Manager\MediaManagerInterface

$phoneEntityName protected static property

protected static $phoneEntityName

$phoneTypeEntityName protected static property

protected static $phoneTypeEntityName

$positionEntityName protected static property

protected static $positionEntityName

$tagManager protected property

protected TagManagerInterface,Sulu\Bundle\TagBundle\Tag $tagManager
return Sulu\Bundle\TagBundle\Tag\TagManagerInterface

$urlEntityName protected static property

protected static $urlEntityName

$urlTypeEntityName protected static property

protected static $urlTypeEntityName