idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
38,000
public function getLeadCommand ( $ actor , $ person ) { if ( ! $ actor -> isFollowable ( ) || ! $ person -> isLeadable ( ) ) { return ; } if ( $ actor -> eql ( $ person ) ) { return ; } if ( $ actor -> blocking ( $ person ) ) { return ; } if ( $ person -> following ( $ actor ) && $ actor -> authorize ( 'administration'...
Lead a person command .
38,001
protected function _commandAddFollowers ( $ command ) { $ actor = $ command -> actor ; $ labels = array ( ) ; $ labels [ ] = strtoupper ( 'com-' . $ this -> getIdentifier ( ) -> package . '-socialgraph-toolbar-followers-add' ) ; $ labels [ ] = 'COM-ACTORS-SOCIALGRAPH-TOOLBAR-FOLLOWERS-ADD' ; $ label = translate ( $ lab...
Add Followers button toolbar .
38,002
protected function _buildCommand ( $ command ) { $ url = $ command -> receiver -> getURL ( ) ; $ command -> setAttribute ( 'data-action' , $ command -> action ) ; $ command -> setAttribute ( 'data-actor' , $ command -> actor -> id ) ; if ( ! $ this -> _use_post && $ this -> getController ( ) -> getRequest ( ) -> getFor...
Method to build a command .
38,003
public function getParentRepository ( ) { $ parent = $ this -> getRepository ( ) -> getDescription ( ) -> getProperty ( 'parent' ) ; $ parent = $ this -> getIdentifier ( $ parent -> getParent ( ) ) ; return AnDomain :: getRepository ( $ parent ) ; }
Return the parent repository .
38,004
protected function _findRelativePath ( $ from , $ to ) { $ path = dirname ( $ from ) ; $ to = str_replace ( COMPOSER_ROOT . DIRECTORY_SEPARATOR , '' , $ to ) ; while ( $ path != COMPOSER_ROOT ) { $ path = dirname ( $ path ) ; $ to = '..' . DIRECTORY_SEPARATOR . $ to ; } ; return $ to ; }
Find from to to
38,005
public function write ( $ output ) { if ( $ this -> _hasBeenModified ( $ this -> _file ) || ! file_exists ( $ output ) ) { file_put_contents ( $ output , $ this -> getData ( ) ) ; $ this -> _cache_data [ 'timestamp' ] = time ( ) ; file_put_contents ( $ this -> _cache_file , serialize ( $ this -> _cache_data ) ) ; } }
Write the output of the file into and output .
38,006
protected function _hasBeenModified ( $ file ) { if ( ! isset ( $ this -> _cache_data [ $ file ] ) ) { return true ; } if ( filemtime ( $ file ) > $ this -> _cache_data [ 'timestamp' ] ) { return true ; } $ imports = $ this -> _cache_data [ $ file ] [ 'imports' ] ; foreach ( $ imports as $ import ) { if ( $ this -> _ha...
Check if the file or any of the imported files within it has been modified since the last time it was cached .
38,007
public function sendHeaders ( ) { $ response = $ this -> getResponse ( ) ; $ headers = $ response -> getHeaders ( ) ; $ isAjax = $ response -> getRequest ( ) -> isAjax ( ) ; if ( isset ( $ headers [ 'Location' ] ) && $ response -> isSuccess ( ) && ! $ isAjax ) { $ response -> setStatus ( AnHttpResponse :: SEE_OTHER ) ;...
For all the success HTML responses unless its ajax perform a redirect if the location is set .
38,008
protected function _actionOptions ( AnCommandContext $ context ) { $ context -> response -> status = AnHttpResponse :: OK ; $ context -> response -> set ( 'Content-Length' , 0 ) ; }
Options action .
38,009
protected function _actionPost ( AnCommandContext $ context ) { $ context -> append ( array ( 'data' => AnRequest :: get ( 'post' , 'raw' , array ( ) ) , ) ) ; if ( $ context -> data [ 'action' ] ) { $ context -> data [ '_action' ] = $ context -> data [ 'action' ] ; } $ action = 'post' ; if ( $ context -> data [ '_acti...
Post action .
38,010
public function get ( $ key = null , $ default = null ) { if ( ! empty ( $ this -> _settings -> $ key ) ) { return $ this -> _settings -> $ key ; } return $ default ; }
obtains a setting parameter value
38,011
public function set ( $ key , $ value = null ) { if ( isset ( $ this -> _settings -> $ key ) ) { $ this -> _settings -> $ key = $ value ; } return $ this -> _settings -> $ key ; }
sets a setting parameter value
38,012
public function getQuery ( AnConfig $ config = null ) { if ( ! isset ( $ config ) ) { $ config = new AnConfig ( array ( 'adapter' => $ this ) ) ; } return new AnDatabaseQuery ( $ config ) ; }
Get a database query object
38,013
public function show ( $ query , $ mode = AnDatabase :: FETCH_ARRAY_LIST ) { $ context = $ this -> getCommandContext ( ) ; $ context -> query = $ query ; $ context -> operation = AnDatabase :: OPERATION_SHOW ; $ context -> mode = $ mode ; if ( $ this -> getCommandChain ( ) -> run ( 'before.show' , $ context ) !== false...
Preforms a show query
38,014
public function insert ( $ table , array $ data ) { $ context = $ this -> getCommandContext ( ) ; $ context -> table = $ table ; $ context -> data = $ data ; $ context -> operation = AnDatabase :: OPERATION_INSERT ; if ( $ this -> getCommandChain ( ) -> run ( 'before.insert' , $ context ) !== false ) { if ( count ( $ c...
Inserts a row of data into a table .
38,015
public function update ( $ table , array $ data , $ where = null ) { $ context = $ this -> getCommandContext ( ) ; $ context -> table = $ table ; $ context -> data = $ data ; $ context -> where = $ where ; $ context -> operation = AnDatabase :: OPERATION_UPDATE ; if ( $ this -> getCommandChain ( ) -> run ( 'before.upda...
Updates a table with specified data based on a WHERE clause
38,016
public function delete ( $ table , $ where ) { $ context = $ this -> getCommandContext ( ) ; $ context -> table = $ table ; $ context -> data = null ; $ context -> where = $ where ; $ context -> operation = AnDatabase :: OPERATION_DELETE ; if ( $ this -> getCommandChain ( ) -> run ( 'before.delete' , $ context ) !== fa...
Deletes rows from the table based on a WHERE clause .
38,017
public function replaceTableNeedle ( $ sql , $ replace = null ) { $ needle = $ this -> getTableNeedle ( ) ; $ replace = isset ( $ replace ) ? $ replace : $ this -> getTablePrefix ( ) ; $ sql = trim ( $ sql ) ; $ pattern = "($needle(?=[a-z0-9]))" ; $ sql = preg_replace ( $ pattern , $ replace , $ sql ) ; return $ sql ; ...
This function replaces the table needles in a query string with the actual table prefix .
38,018
protected function _actionRender ( AnCommandContext $ context ) { if ( $ context -> data instanceof Exception ) { $ this -> getView ( ) -> content ( $ context -> data ) ; } else { $ this -> getView ( ) -> content ( $ context -> response -> getContent ( ) ) ; } $ content = $ this -> getView ( ) -> display ( ) ; $ contex...
Renders the page .
38,019
public function getUser ( ) { if ( ! isset ( $ this -> _user ) ) { $ this -> _user = new ComConnectOauthUser ( ) ; $ data = $ this -> _getUserData ( ) ; if ( $ data ) { foreach ( $ data as $ key => $ value ) { $ this -> _user -> $ key = $ value ; } } } return $ this -> _user ; }
Return a user object representing the logged - in user .
38,020
public function requestRequestToken ( $ data = array ( ) ) { $ config = new AnConfig ( array ( 'data' => $ data ) ) ; $ config -> append ( array ( 'url' => $ this -> request_token_url , 'data' => array ( 'oauth_callback' => $ this -> getConsumer ( ) -> callback_url ) , ) ) ; $ request = $ this -> getRequest ( $ config ...
Request for a request token .
38,021
public function getRequest ( $ config = array ( ) ) { $ config [ 'consumer' ] = $ this -> getConsumer ( ) ; $ config [ 'token' ] = $ this -> getToken ( ) ; $ config [ 'version' ] = $ this -> getVersion ( ) ; return new ComConnectOauthRequest ( new AnConfig ( $ config ) ) ; }
Creates an returns a request .
38,022
public function call ( $ resource , $ method , $ data = array ( ) ) { $ resource = $ this -> api_url . '/' . $ resource ; $ response = $ this -> getRequest ( array ( 'url' => $ resource , 'method' => $ method , 'data' => $ data , ) ) -> send ( ) ; $ result = null ; if ( strlen ( $ response ) ) { $ result = $ response -...
Make a PUT request .
38,023
protected function _actionPost ( AnCommandContext $ context ) { $ action = $ this -> getItem ( ) ? 'edit' : 'add' ; $ result = $ this -> execute ( $ action , $ context ) ; return $ result ; }
Generic POST action for a medium . If an entity exists then execute edit else execute add .
38,024
public static function getEntityIdentifier ( $ identifier ) { $ identifier = AnService :: getIdentifier ( $ identifier ) ; if ( ! $ identifier -> basepath ) { $ adapters = AnService :: get ( 'anahita:loader' ) -> getAdapters ( ) ; $ basepath = pick ( $ adapters [ $ identifier -> type ] -> getBasePath ( ) , ANPATH_BASE ...
Entity Identifers must have application in their path . This method set the application of an identifier if the path is missing .
38,025
public static function getRepository ( $ identifier , $ config = array ( ) ) { if ( strpos ( $ identifier , 'repos:' ) === 0 ) { $ repository = AnService :: get ( $ identifier ) ; } else { $ strIdentifier = ( string ) $ identifier ; if ( ! AnService :: has ( $ identifier ) ) { $ identifier = self :: getEntityIdentifier...
Helper mehtod to return a repository for an entity .
38,026
protected function _authorizeDelete ( AnCommandContext $ context ) { if ( $ this -> _viewer -> eql ( $ this -> _entity ) && $ this -> _entity -> superadmin ( ) ) { return false ; } return parent :: _authorizeDelete ( $ context ) ; }
Check if a person can be deleted by the viewer .
38,027
protected function _authorizeMention ( AnCommandContext $ context ) { if ( $ this -> _entity -> blocking ( $ this -> _viewer ) || $ this -> _viewer -> blocking ( $ this -> _entity ) ) { return false ; } return true ; }
Whether the viewer can mention this person or not .
38,028
public function getApi ( ) { if ( ! isset ( $ this -> _api ) ) { $ this -> _api = ComConnectHelperApi :: getApi ( $ this -> get ( 'api' ) ) ; $ this -> _api -> setToken ( $ this -> tokenKey , $ this -> tokenSecret ) ; } return $ this -> _api ; }
Return an instance of API Adapter .
38,029
public function setToken ( $ token ) { $ this -> tokenKey = $ token -> key ; $ this -> tokenSecret = $ token -> secret ; return $ this ; }
Sets the oauth token attributes .
38,030
public function echoStory ( $ data ) { $ service = $ this -> getService ( 'com:connect.domain.echoer.' . $ this -> get ( 'api' ) ) ; return $ service -> echoStory ( $ this , $ data ) ; }
Echo a story .
38,031
public function login ( $ service , $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'html' => $ this -> icon ( $ service ) , 'url' => $ this -> url ( $ service ) , 'attributes' => array ( ) , ) ) ; $ html = $ this -> getService ( 'com:base.template.helper.html' ) ; $ link = ...
Returns the logo for a service .
38,032
public function url ( $ service ) { $ url = 'index.php?option=com_connect&view=login&server=' . $ service ; if ( AnRequest :: get ( 'get.return' , 'cmd' ) ) { $ url .= '&return=' . AnRequest :: get ( 'get.return' , 'raw' ) ; } return route ( $ url ) ; }
Returns the url login for a service .
38,033
protected function _arrayToTime ( $ array ) { $ time = array_key_exists ( 'H' , $ array ) && trim ( $ array [ 'H' ] ) != '' && array_key_exists ( 'i' , $ array ) && trim ( $ array [ 'i' ] ) != '' ; if ( ! $ time ) { return ; } $ s = array_key_exists ( 's' , $ array ) && trim ( $ array [ 's' ] ) != '' ? $ array [ 's' ] ...
Converts an array of time parts to a string time .
38,034
public function send ( ) { $ this -> getResponse ( ) -> setContentType ( 'application/json' ) ; $ headers = $ this -> getResponse ( ) -> getHeaders ( ) ; if ( isset ( $ headers [ 'Location' ] ) ) { $ headers [ 'Content-Location' ] = $ headers [ 'Location' ] ; unset ( $ headers [ 'Location' ] ) ; } if ( empty ( $ this -...
Send HTTP response .
38,035
protected function _layoutForm ( ) { if ( ! $ this -> expiresOn ) { $ expiresOn = new AnDate ( ) ; $ expiresOn -> addMonths ( 1 ) ; $ this -> set ( array ( 'expiresOn' => $ expiresOn , ) ) ; } }
Prepare form layout .
38,036
protected function _layoutEdit ( ) { $ config = new AnConfig ( array ( 'date' => $ this -> item -> expiresOn , ) ) ; $ this -> set ( array ( 'expiresOn' => new AnDate ( $ config ) , ) ) ; }
Prepare edit layout .
38,037
private function parse ( $ body ) { parse_str ( $ body , $ response_array ) ; if ( $ response_array [ 'ACK' ] == self :: FAILURE ) { $ error_message = 'Error code (' . $ response_array [ 'L_ERRORCODE0' ] . ")\n " . $ response_array [ 'L_SHORTMESSAGE0' ] . ".\n Reason: " . $ response_array [ 'L_LONGMESSAGE0' ] ; Merchan...
Parse the raw data response from gateway .
38,038
protected function _vimeo ( & $ text ) { $ matches = array ( ) ; if ( preg_match_all ( '%http[s]?://\S*vimeo.com/(\d+)%' , $ text , $ matches ) ) { foreach ( $ matches [ 1 ] as $ index => $ id ) { $ video = sprintf ( '<div class="an-media-video" data-trigger="video-player" data-plyr-provider="vimeo" data-plyr-embed-id=...
Checks the text for a vimeo URL .
38,039
protected function _layoutList ( ) { $ preloaded_nodes = $ this -> getService ( 'repos:stories.story' ) -> getLoadedNodes ( ) ; $ story = $ this -> _state -> getItem ( ) ; $ helper = $ this -> getTemplate ( ) -> getHelper ( 'parser' ) ; $ data = $ helper -> parse ( $ story , $ this -> actor ) ; $ data [ 'subject' ] = $...
Sets the story title body and avatar .
38,040
protected function _layoutDefault ( ) { $ story = $ this -> _state -> getItem ( ) ; $ helper = $ this -> getTemplate ( ) -> getHelper ( 'parser' ) ; $ data = $ helper -> parse ( $ story , $ this -> actor ) ; $ data [ 'subject' ] = $ story -> subject ; $ data [ 'timestamp' ] = $ story -> creationTime ; $ data [ 'story' ...
Called before default layout .
38,041
public function language ( $ langs ) { settype ( $ langs , 'array' ) ; $ scripts = '' ; $ language = $ this -> getService ( 'anahita:language' ) ; $ tag = $ language -> getTag ( ) ; $ base = $ language -> getLanguagePath ( ANPATH_ROOT , $ tag ) ; foreach ( $ langs as $ lang ) { $ path = $ base . '/' . $ tag . '.' . $ l...
Loads an aray of javascript language .
38,042
public function getPermissions ( ) { $ registry = $ this -> getService ( 'application.registry' ) ; $ key = $ this -> getIdentifier ( ) . '-permissions' ; if ( ! $ registry -> offsetExists ( $ key ) ) { $ registry -> offsetSet ( $ key , self :: _getDefaultPermissions ( $ this ) ) ; } return $ registry -> offsetGet ( $ ...
Return an array of permission object .
38,043
public function onSettingDisplay ( AnEvent $ event ) { $ actor = $ event -> actor ; $ tabs = $ event -> tabs ; $ this -> _setSettingTabs ( $ actor , $ tabs ) ; }
On Setting display .
38,044
public function onMenuDisplay ( AnEvent $ event ) { $ actor = $ event -> actor ; $ menuItems = $ event -> menuItems ; if ( $ this -> activeForActor ( $ actor ) ) { $ this -> _setMenuLinks ( $ actor , $ menuItems ) ; } }
On Viewer Menu display .
38,045
protected static function _getDefaultPermissions ( $ component ) { $ identifiers = $ component -> getEntityIdentifiers ( 'ComMediumDomainEntityMedium' ) ; $ permissions = array ( ) ; foreach ( $ identifiers as $ identifier ) { try { $ repos = AnDomain :: getRepository ( $ identifier ) ; if ( $ repos -> entityInherits (...
Return an array of permissions by using the medium objects .
38,046
public function addNavigation ( $ name , $ label , $ url , $ active = false ) { if ( is_array ( $ url ) ) { $ url = http_build_query ( $ url ) ; } $ command = $ this -> addCommand ( $ name , array ( 'label' => $ label , ) ) -> getCommand ( $ name ) -> href ( $ url ) ; if ( $ active ) { $ command -> class ( 'active' , '...
Adds a command to the menubar . A menubar command must always be used as means to navigation through different views .
38,047
protected function _actionAdd ( AnCommandContext $ context ) { $ data = $ context -> data ; $ email = $ data -> email ; $ person = $ this -> getService ( 'repos:people.person' ) -> getQuery ( ) -> email ( $ email ) -> where ( 'IF(!@col(enabled),@col(activationCode) <> \'\',1)' ) -> disableChain ( ) -> fetch ( ) ; if ( ...
Resets a password .
38,048
public function mailConfirmation ( AnCommandContext $ context ) { if ( $ this -> person ) { $ settings = $ this -> getService ( 'com:settings.setting' ) ; $ mails [ ] = array ( 'to' => $ this -> person -> email , 'subject' => sprintf ( AnTranslator :: _ ( 'COM-PEOPLE-MAIL-SUBJECT-PASSWORD-RESET' ) , $ settings -> siten...
Send an email confirmation after reset .
38,049
protected function _actionTogglesubscription ( $ context ) { if ( $ this -> getItem ( ) -> subscribed ( get_viewer ( ) ) ) { $ ret = $ this -> _mixer -> execute ( 'unsubscribe' , $ context ) ; } else { $ ret = $ this -> _mixer -> execute ( 'subscribe' , $ context ) ; } return $ ret ; }
If the viewer is subscribe then unsubscribe if not subscribe then subscribe .
38,050
public static function insert ( $ array , $ values , $ index = null ) { $ values = ( array ) AnConfig :: unbox ( $ values ) ; $ array = ( array ) AnConfig :: unbox ( $ array ) ; if ( $ index === null ) { foreach ( $ values as $ value ) { array_push ( $ array , $ value ) ; } } else { array_splice ( $ array , $ index , 0...
Insert into an array . If no offset is given then the values are inserted at the end of the list . Returns the new array with value inserted into .
38,051
public static function getValues ( $ array ) { settype ( $ array , 'array' ) ; $ values = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ values = array_merge ( $ values , self :: getValues ( $ value ) ) ; } else { $ values [ ] = $ value ; } } return $ values ; }
Flattens a multi - dimensial array and return all the values as one single array .
38,052
public static function toArray ( $ object ) { $ object = AnConfig :: unbox ( $ object ) ; if ( is ( $ object , 'AnObjectArray' ) || is ( $ object , 'AnObjectSet' ) ) { return $ object -> toArray ( ) ; } return ( array ) $ object ; }
Return the simple scalar array of the object .
38,053
public static function getValueAtIndex ( $ array , $ index ) { $ value = null ; if ( abs ( ( int ) $ index ) == self :: LAST_INDEX ) { $ index == self :: LAST_INDEX ? end ( $ array ) : reset ( $ array ) ; $ value = current ( $ array ) ; } elseif ( isset ( $ array [ $ index ] ) ) { $ value = $ array [ $ index ] ; } retu...
Get the value at an index . The index can be an integer or first or last . If the index doesn t exists it returns null .
38,054
public static function count ( array $ array ) { $ count = 0 ; foreach ( $ array as $ v ) { if ( is_array ( $ v ) ) { $ count += self :: count ( $ v ) ; } else { $ count ++ ; } } return $ count ; }
Count array items recursively
38,055
public static function toString ( $ array = null , $ inner_glue = '=' , $ outer_glue = ' ' , $ keepOuterKey = false ) { $ output = array ( ) ; if ( $ array instanceof AnConfig ) { $ data = array ( ) ; foreach ( $ array as $ key => $ item ) { $ data [ $ key ] = ( string ) $ item ; } $ array = $ data ; } if ( is_object (...
Utility function to map an array to a string
38,056
public function setNodeB ( $ package ) { $ this -> set ( 'nodeB' , $ package ) ; $ this -> set ( 'endDate' , clone $ this -> startDate ) ; $ this -> endDate -> addSeconds ( $ package -> duration ) ; return $ this ; }
Set the subscription package .
38,057
protected function _afterEntityInsert ( AnCommandContext $ context ) { $ actorIds = $ this -> package -> getActorIds ( ) ; if ( count ( $ actorIds ) ) { $ actors = $ this -> getService ( 'repos:actors.actor' ) -> getQuery ( true ) -> where ( 'id' , 'IN' , $ actorIds ) -> fetchSet ( ) ; foreach ( $ actors as $ actor ) {...
After adding a subscriptions add the person as a follower to all the package actors .
38,058
public function getView ( ) { if ( ! $ this -> _view instanceof LibBaseViewAbstract ) { if ( ! ( $ this -> _view instanceof AnServiceIdentifier ) ) { $ this -> setView ( $ this -> _view ) ; } $ config = array ( 'media_url' => AnRequest :: root ( ) . '/media' , 'base_url' => AnRequest :: url ( ) -> getUrl ( AnHttpUrl ::...
Get the view object attached to the controller .
38,059
protected static function _cache ( $ entity ) { static $ cache ; if ( ! $ cache ) { $ cache = new AnObjectArray ( ) ; } if ( ! isset ( $ cache [ $ entity -> getRepository ( ) ] ) ) { $ cache [ $ entity -> getRepository ( ) ] = new ArrayObject ( ) ; } return $ cache [ $ entity -> getRepository ( ) ] ; }
Static cache to store runtime information of an entity .
38,060
protected function _afterEntityFetch ( AnCommandContext $ context ) { $ this -> setPersisted ( true ) ; $ this -> _data -> setRowData ( $ context [ 'data' ] ) ; foreach ( $ context [ 'keys' ] as $ key => $ value ) { $ this -> _data [ $ key ] = $ value ; } }
Sets the enity data after it has been fetched from the database storage .
38,061
public function saveEntity ( ) { $ ret = null ; if ( $ this -> getRepository ( ) -> validate ( $ this ) ) { $ ret = $ this -> getRepository ( ) -> commit ( $ this ) ; } return $ ret ; }
Tries to only save the entity .
38,062
public function reset ( ) { $ this -> getRepository ( ) -> getSpace ( ) -> setEntityState ( $ this , AnDomain :: STATE_CLEAN ) ; $ this -> _modified = array ( ) ; return $ this ; }
Reset the state of a entity to clean state .
38,063
public function getIdentifyingData ( ) { $ keys = array_keys ( $ this -> getEntityDescription ( ) -> getIdentifyingProperties ( ) ) ; $ data = array ( ) ; foreach ( $ keys as $ key ) { if ( $ this -> _data -> isMaterialized ( $ key ) ) { $ value = $ this -> get ( $ key ) ; if ( $ value ) { $ data [ $ key ] = $ value ; ...
Return an array of data that can be used to identify this entity .
38,064
public function get ( $ name = null , $ default = null ) { $ description = $ this -> getEntityDescription ( ) ; $ property = $ description -> getProperty ( $ name ) ; if ( ! $ property ) { return parent :: get ( $ name , $ default ) ; } $ name = $ property -> getName ( ) ; $ value = $ this -> _data -> offsetGet ( $ nam...
Get the raw value of a property or return the default value passed .
38,065
public function load ( $ properties = array ( ) ) { $ keys = $ this -> getIdentifyingData ( ) ; if ( empty ( $ keys ) ) { throw new AnDomainEntityException ( 'Trying to load an entity without any identifying data' ) ; } if ( ! $ this -> _persisted ) { $ entity = $ this -> getRepository ( ) -> find ( $ keys , false ) ; ...
ReLoad the entity properties from storage . Overriding any changes .
38,066
public function getAffectedRowData ( ) { $ data = array ( ) ; $ description = $ this -> getEntityDescription ( ) ; switch ( $ this -> getEntityState ( ) ) { case AnDomain :: STATE_NEW : foreach ( $ description -> getProperty ( ) as $ name => $ property ) { if ( $ property instanceof AnDomainPropertySerializable ) { $ d...
This method is used to return an array of entity row data that have either been changed or are new .
38,067
public function getData ( $ property = AnDomain :: ACCESS_PUBLIC , $ default = null ) { $ description = $ this -> getEntityDescription ( ) ; if ( gettype ( $ property ) === 'integer' ) { $ properties = $ this -> getEntityDescription ( ) -> getProperty ( ) ; $ access = ( int ) $ property ; $ data = array ( ) ; foreach (...
get the value of a property by checking for custom getter . If no property is passed an array of properties is returend .
38,068
public function __isset ( $ property ) { if ( $ property = $ this -> getEntityDescription ( ) -> getProperty ( $ property ) ) { $ name = $ property -> getName ( ) ; if ( $ this -> _data -> offsetExists ( $ name ) ) { $ value = $ this -> _data -> offsetGet ( $ name ) ; if ( $ value instanceof AnDomainEntityProxy ) { if ...
Check if a property has been set .
38,069
public function execute ( $ command , $ context ) { if ( ! $ context instanceof AnCommandContext ) { $ context = new AnCommandContext ( $ context ) ; } $ parts = explode ( '.' , $ command ) ; $ method = '_' . $ parts [ 0 ] . 'Entity' . ucfirst ( $ parts [ 1 ] ) ; $ result = null ; if ( method_exists ( $ this , $ method...
Executes a command on entity .
38,070
public function inherits ( $ class ) { if ( $ this instanceof $ class ) { return true ; } if ( ! parent :: inherits ( $ class ) ) { $ behaviors = $ this -> getRepository ( ) -> getBehaviors ( ) ; foreach ( $ behaviors as $ behavior ) { if ( $ behavior instanceof $ class ) { return true ; } } return false ; } else { ret...
Checks if the object or one of it s mixins inherits from a class .
38,071
public function getRepository ( ) { if ( ! $ this -> _repository instanceof AnDomainRepositoryAbstract ) { $ this -> _repository = $ this -> getService ( $ this -> _repository ) ; } return $ this -> _repository ; }
Get the entity repository .
38,072
public function cloneEntity ( $ deep = true ) { $ copy = $ this -> getRepository ( ) -> getEntity ( ) ; $ properties = $ this -> getEntityDescription ( ) -> getProperty ( ) ; $ data = array ( ) ; foreach ( $ properties as $ property ) { if ( $ property -> isUnique ( ) ) { continue ; } if ( $ property === $ this -> getE...
Make a clone of the entity with it s attributes . The unique properties are not copied . If deep copy is selected then this method tries to replicate all the ony - to - many relationships as well .
38,073
public function getMethods ( ) { $ behaviors = $ this -> getRepository ( ) -> getBehaviors ( ) ; foreach ( $ behaviors as $ behavior ) { $ this -> mixin ( $ behavior ) ; } return parent :: getMethods ( ) ; }
Return an array of methods .
38,074
public function serialize ( ) { $ row = array ( ) ; $ row = $ this -> _data -> getRowData ( ) ; $ row = array_merge ( $ row , $ this -> getAffectedRowData ( ) ) ; return serialize ( array ( 'row' => $ row , 'identifier' => ( string ) $ this -> getIdentifier ( ) ) ) ; }
Return an array of raw data from which the object can be recreated .
38,075
public function methodExists ( $ method ) { $ key = 'method.' . $ method ; if ( ! self :: _cache ( $ this ) -> offsetExists ( $ key ) ) { $ result = false ; if ( method_exists ( $ this , $ method ) ) { $ result = true ; } elseif ( self :: _cache ( $ this ) -> offsetExists ( 'behavior.' . $ method ) ) { $ result = self ...
Check if method exists between the entities and all its behavior . It caches the result once for the whole repository in order to improve performance .
38,076
public function setRecurring ( $ frequency , $ unit , $ start_date ) { $ this -> _recurring_options = new AnConfig ( array ( 'frequency' => $ frequency , 'unit' => $ unit , 'start_date' => $ start_date , ) ) ; return $ this ; }
Set the recurring options .
38,077
public function find ( $ scope ) { if ( strpos ( $ scope , '.' ) === false ) { $ scope = $ scope . '.' . AnInflector :: singularize ( $ scope ) ; } if ( isset ( $ this [ $ scope ] ) ) { return $ this [ $ scope ] ; } return ; }
Return a scope using a key or not if not found .
38,078
public function getResponse ( ) { if ( ! $ this -> _response instanceof LibBaseControllerResponse ) { $ this -> _response = $ this -> getService ( $ this -> _response ) ; if ( ! $ this -> _response instanceof LibBaseControllerResponse ) { throw new UnexpectedValueException ( 'Response must be an instanceof LibBaseContr...
Return the response object .
38,079
public function getBehavior ( $ behavior , $ config = array ( ) ) { if ( is_string ( $ behavior ) ) { if ( strpos ( $ behavior , '.' ) === false ) { $ identifier = clone $ this -> getIdentifier ( ) ; $ identifier -> path = array ( 'controller' , 'behavior' ) ; $ identifier -> name = $ behavior ; register_default ( arra...
Get a behavior by identifier .
38,080
public function set ( $ property , $ value = null ) { if ( is_object ( $ property ) ) { $ property = get_object_vars ( $ property ) ; } if ( is_array ( $ property ) ) { foreach ( $ property as $ k => $ v ) { $ this -> set ( $ k , $ v ) ; } } elseif ( '_' != substr ( $ property , 0 , 1 ) ) { if ( method_exists ( $ this ...
Set the object properties .
38,081
public function getName ( ) { $ total = count ( $ this -> getIdentifier ( ) -> path ) ; return $ this -> getIdentifier ( ) -> path [ $ total - 1 ] ; }
Get the name .
38,082
public function getRoute ( $ route = '' , $ fqr = true ) { if ( ! is_array ( $ route ) ) { $ parts = array ( ) ; parse_str ( trim ( $ route ) , $ parts ) ; $ route = $ parts ; } $ parts = $ route ; $ route = array ( ) ; if ( ! isset ( $ parts [ 'option' ] ) ) { $ route [ 'option' ] = 'com_' . $ this -> getIdentifier ( ...
Get a route based on a full or partial query string .
38,083
public function getController ( ) { if ( ! ( $ this -> _controller instanceof LibBaseControllerAbstract ) ) { if ( ! ( $ this -> _controller instanceof AnServiceIdentifier ) ) { $ this -> setController ( $ this -> _controller ) ; } $ config = array ( 'response' => $ this -> getResponse ( ) , 'request' => $ this -> _req...
Method to get a controller object .
38,084
public function getResponse ( ) { if ( ! $ this -> _response instanceof LibBaseDispatcherResponse ) { $ this -> _response = parent :: getResponse ( ) ; if ( ! $ this -> _response instanceof LibBaseDispatcherResponse ) { throw new InvalidArgumentException ( 'Response: ' . get_class ( $ this -> _response ) . ' must be an...
Set the request of the response .
38,085
public function setController ( $ controller ) { if ( ! ( $ controller instanceof LibBaseControllerAbstract ) ) { if ( is_string ( $ controller ) && strpos ( $ controller , '.' ) === false ) { if ( AnInflector :: isPlural ( $ controller ) ) { $ controller = AnInflector :: singularize ( $ controller ) ; } $ identifier =...
Method to set a controller object attached to the dispatcher .
38,086
public function inherits ( $ class ) { $ result = false ; $ object = $ this -> getObject ( ) ; if ( $ object instanceof AnObject ) { $ result = $ object -> inherits ( $ class ) ; } else { $ result = $ object instanceof $ class ; } return $ result ; }
Checks if the decorated object or one of it s mixins inherits from a class .
38,087
public function onAfterDispatch ( AnEvent $ event ) { $ this -> _viewer = AnService :: get ( 'com:people.viewer' ) ; $ this -> _logoutIfDisabledAccount ( ) ; if ( ! $ this -> _viewer -> guest ( ) ) { return ; } if ( AnRequest :: method ( ) === 'GET' ) { $ this -> _handleAutoLogin ( ) ; } return ; }
Remebers handling .
38,088
private function _handleAutoLogin ( ) { $ credentials = $ this -> _getRememberMeCredentials ( ) ; if ( ! empty ( $ credentials ) ) { if ( $ this -> _authenticate ( $ credentials ) ) { $ this -> _login ( $ credentials ) ; } } }
Handles all scenarios where user is logged back in . For example if they had checked Stay Logged In last time that they d logged on .
38,089
private function _authenticate ( $ credentials ) { try { $ response = $ this -> getService ( 'com:people.authentication.response' ) ; dispatch_plugin ( 'authentication.onAuthenticate' , array ( 'credentials' => $ credentials , 'response' => $ response ) ) ; if ( $ response -> status === ComPeopleAuthentication :: STATU...
Authenticate the credentials
38,090
private function _login ( $ credentials ) { $ this -> getService ( 'com:people.helper.person' ) -> login ( $ credentials ) ; $ this -> getService ( 'application.dispatcher' ) -> getResponse ( ) -> setRedirect ( $ this -> _getCurrentUrl ( ) ) -> send ( ) ; }
Loggin the user and keep them logged in
38,091
private function _getRememberMeCredentials ( ) { $ credentials = array ( ) ; $ remember = get_hash ( 'AN_LOGIN_REMEMBER' ) ; if ( isset ( $ _COOKIE [ $ remember ] ) && ! empty ( $ _COOKIE [ $ remember ] ) ) { $ key = get_hash ( 'AN_LOGIN_REMEMBER' , 'md5' ) ; $ crypt = $ this -> getService ( 'anahita:encrypter' , array...
Obtains credentials for the people who have obted to stay logged in
38,092
private function _logoutIfDisabledAccount ( ) { if ( ! is_null ( $ this -> _viewer ) ) { if ( ! $ this -> _viewer -> guest ( ) && ! $ this -> _viewer -> enabled ) { $ this -> getService ( 'com:people.helper.person' ) -> logout ( ) ; $ this -> getService ( 'application.dispatcher' ) -> getResponse ( ) -> setRedirect ( r...
Logout a user with disabled account
38,093
protected function _actionGetcandidates ( AnCommandContext $ context ) { if ( $ context -> request -> getFormat ( ) != 'html' ) { $ data = $ context -> data ; $ canditates = $ this -> getItem ( ) -> getAdminCanditates ( ) ; $ canditates -> keyword ( $ this -> value ) -> limit ( 10 ) ; $ people = array ( ) ; foreach ( $...
Get Candidates .
38,094
protected function _actionAddapp ( AnCommandContext $ context ) { $ data = $ context -> data ; $ this -> getItem ( ) -> components -> insert ( $ data -> app ) ; $ this -> commit ( ) ; }
Add App .
38,095
protected function _actionRemoveapp ( AnCommandContext $ context ) { $ data = $ context -> data ; $ this -> getItem ( ) -> components -> extract ( $ data -> app ) ; $ this -> commit ( ) ; }
Remove App .
38,096
protected function _actionDispatch ( AnCommandContext $ context ) { if ( $ this -> getController ( ) -> getIdentifier ( ) -> name === 'session' && $ this -> token != '' ) { $ this -> getController ( ) -> execute ( 'tokenlogin' , $ context ) ; $ context -> response -> send ( ) ; exit ( 0 ) ; } return parent :: _actionDi...
Handles passowrd token before dispatching .
38,097
protected function _actionException ( AnCommandContext $ context ) { if ( $ context -> data instanceof LibBaseControllerExceptionUnauthorized && $ this -> getController ( ) instanceof ComPeopleControllerSession ) { $ context -> response -> send ( ) ; exit ( 0 ) ; } else { parent :: _actionException ( $ context ) ; } }
If session throws LibBaseControllerExceptionUnauthorized exception that means the user has entere wrong credentials . In that case let the application handle the error .
38,098
public function setTaxInfo ( AnCommandContext $ context ) { $ vats = $ context -> data -> federal_tax ; $ this -> getItem ( ) -> setFederalTax ( AnConfig :: unbox ( $ vats ) ) ; }
Set the tax info of the entity .
38,099
public function canBrowse ( ) { $ viewer = get_viewer ( ) ; if ( $ viewer -> admin ( ) || $ viewer -> eql ( $ this -> actor ) ) { return true ; } return false ; }
Authorize if viewer can browse .