idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
37,700 | public static function getPart ( $ string , $ index , $ default = null ) { $ parts = self :: explode ( $ string ) ; if ( $ index < 0 ) { $ index = count ( $ parts ) + $ index ; } return isset ( $ parts [ $ index ] ) ? $ parts [ $ index ] : $ default ; } | Gets a part of a CamelCased word by index |
37,701 | public function getValidator ( ) { if ( ! $ this -> _validator instanceof LibBaseControllerValidatorAbstract ) { if ( ! ( $ this -> _validator instanceof AnServiceIdentifier ) ) { $ this -> setValidator ( $ this -> _validator ) ; } $ config = array ( 'controller' => $ this -> getMixer ( ) , ) ; $ this -> _validator = $... | Return the validator . |
37,702 | public function setValidator ( $ validator ) { if ( ! ( $ validator instanceof LibBaseControllerValidatorAbstract ) ) { if ( is_string ( $ validator ) && strpos ( $ validator , '.' ) === false ) { $ identifier = clone $ this -> getIdentifier ( ) ; $ identifier -> path = array ( 'controller' , 'validator' ) ; $ identifi... | Sets the validator . |
37,703 | protected function _beforeControllerValidate ( ) { if ( ! isset ( $ this -> _validator ) ) { $ this -> setValidator ( $ this -> _mixer -> getIdentifier ( ) -> name ) ; } } | Set the validator before the validate action is called . |
37,704 | protected function _buildAggregateQuery ( $ query , $ config ) { $ cases = array ( ) ; $ config = AnConfig :: unbox ( $ config ) ; $ config [ ] = array ( 'WHEN @col(name) LIKE "avatar_edit" THEN IF(@col(subject.id) = @col(target.id), "", @col(id))' , 'WHEN @col(name) LIKE "actor_follow" THEN @col(subject.id)' , ) ; fo... | Summerize a story query . |
37,705 | protected function _preloadData ( $ stories ) { $ node_ids = array ( ) ; $ comment_ids = array ( ) ; foreach ( $ stories as $ story ) { $ columns = $ story -> getRowData ( ) ; $ node_ids = array_merge ( $ node_ids , $ story -> getIds ( 'owner' ) , $ story -> getIds ( 'subject' ) , $ story -> getIds ( 'target' ) , $ sto... | Loads all the necessary objects after each collection fetch . |
37,706 | protected function _getPreloadedNode ( $ data ) { if ( ! $ this -> aggregated ( ) ) { return $ this -> _mixer -> get ( $ data ) ; } if ( ! isset ( $ this -> _mixer -> __ids ) ) { $ this -> _mixer -> __ids = array ( ) ; } if ( ! isset ( $ this -> _mixer -> __ids [ $ data ] ) ) { $ nodes = array ( ) ; $ ids = $ this -> g... | Since nodes related to an aggregated set have been preloaded we just fetch them from the cache list _loaded_nodes . |
37,707 | public function getIds ( $ key = null ) { if ( ! isset ( $ this -> _mixer -> __ids ) ) { $ this -> _mixer -> __ids = array ( ) ; } $ prop = $ key ? $ key : 'id' ; $ key = $ key ? $ key . '_ids' : 'ids' ; if ( ! isset ( $ this -> _mixer -> __ids [ $ key ] ) ) { $ columns = $ this -> getRowData ( ) ; if ( ! empty ( $ col... | Return an array of aggregated IDs . |
37,708 | public function getComments ( ) { $ comment_ids = $ this -> getIds ( 'comment' ) ; $ comments = array ( ) ; if ( ! empty ( $ comment_ids ) ) { sort ( $ comment_ids ) ; $ size = 0 ; foreach ( $ comment_ids as $ id ) { if ( isset ( $ this -> _loaded_nodes [ $ id ] ) ) { $ comment = $ this -> _loaded_nodes [ $ id ] ; if (... | Return an array of aggregated comments of the object . |
37,709 | public function aggregated ( ) { if ( $ this -> getEntityState ( ) & AnDomain :: STATE_NEW ) { return false ; } if ( $ this -> getRowData ( 'bundle_key' ) == null ) { return false ; } return count ( $ this -> getIds ( ) ) > 1 ; } | Return if a story is an aggregation of multiple stories . |
37,710 | public function setProperty ( $ property ) { $ this -> _properties [ $ property -> getName ( ) ] = $ property ; if ( is_string ( $ this -> _identity_property ) && $ property -> getName ( ) == $ this -> _identity_property ) { $ this -> setIdentityProperty ( $ property ) ; } return $ this ; } | Set a property description . |
37,711 | public function getProperty ( $ name = null ) { if ( is_null ( $ name ) ) { return $ this -> _properties ; } $ name = pick ( $ this -> getAlias ( $ name ) , $ name ) ; $ property = null ; if ( isset ( $ this -> _properties [ $ name ] ) ) { $ property = $ this -> _properties [ $ name ] ; } elseif ( isset ( self :: $ __h... | Return a property or all the properties if name is null . if a property is not defined it will look in the parent descritpion to see if the property is defined in them . If yes it will add it the list of its properties . |
37,712 | public function getAlias ( $ property ) { $ alias = null ; if ( isset ( $ this -> _alias [ $ property ] ) ) { $ alias = $ this -> _alias [ $ property ] ; } return $ alias ; } | Return an alias for a property . |
37,713 | public function addIdentifyingProperty ( $ property ) { if ( $ property -> isSerializable ( ) ) { $ this -> _identifying_properties [ $ property -> getName ( ) ] = $ property ; } $ property -> setRequired ( true ) ; return $ this ; } | Add a property that can uniquely identifies a property . This property is set to required and its value be unique . |
37,714 | public function getIdentifyingValues ( array $ data ) { $ keys = array ( ) ; foreach ( $ this -> getIdentifyingProperties ( ) as $ key ) { if ( $ key -> isMaterializable ( $ data ) ) { $ keys [ $ key -> getName ( ) ] = $ key -> materialize ( $ data , null ) ; } } return $ keys ; } | Materialize an array of identifying values from a row data . |
37,715 | public function getIdentityProperty ( ) { if ( is_string ( $ this -> _identity_property ) ) { $ this -> setIdentityProperty ( $ this -> _identity_property ) ; } return $ this -> _identity_property ; } | Return an identity property that uniquely identifies an entity . |
37,716 | public function getInheritanceColumnValue ( ) { if ( ! isset ( $ this -> _inheritance_column_value ) ) { $ classname = $ this -> getEntityIdentifier ( ) -> classname ; $ classes = get_parents ( $ classname , 'AnDomainEntity' ) ; $ classes [ ] = $ classname ; array_shift ( $ classes ) ; foreach ( $ classes as $ key => $... | Return the type column value . |
37,717 | public function getUniqueIdentifiers ( ) { if ( ! isset ( $ this -> _unique_identifiers ) ) { $ classname = $ this -> getEntityIdentifier ( ) -> classname ; $ this -> _unique_identifiers = get_parents ( $ classname , 'AnDomainEntity' ) ; if ( strpos ( $ classname , 'AnDomainEntity' ) !== 0 ) { $ this -> _unique_identif... | An array of string identifiers that uniquely idenitifies an entity such as class name parent classes and the entity service identifier . |
37,718 | public function setAttribute ( $ name , $ config = array ( ) ) { $ attributes = is_string ( $ name ) ? array ( $ name => $ config ) : $ name ; $ property = null ; foreach ( $ attributes as $ name => $ config ) { if ( is_numeric ( $ name ) ) { $ name = $ config ; $ config = array ( ) ; } elseif ( is_string ( $ config ) ... | Set an attribute or attributes property . It is possible to set an set of attributes by passing an array as the name . |
37,719 | public function setRelationship ( $ name , $ config = array ( ) ) { $ relationships = is_string ( $ name ) ? array ( $ name => $ config ) : $ name ; settype ( $ relationships , 'array' ) ; $ property = null ; foreach ( $ relationships as $ name => $ config ) { if ( is_numeric ( $ name ) ) { $ name = $ config ; $ config... | Set a relationship or relationships property . It is possible to set an set of relationships by passing an array as the name . |
37,720 | public function getAttributes ( ) { $ attributes = array ( ) ; foreach ( $ this -> getProperty ( ) as $ name => $ property ) { if ( $ property -> isAttribute ( ) ) { $ attributes [ $ name ] = $ property ; } } return $ attributes ; } | Return all the properties of type attributes . |
37,721 | public function getRelationships ( ) { $ relationships = array ( ) ; foreach ( $ this -> getProperty ( ) as $ name => $ property ) { if ( $ property -> isRelationship ( ) ) { $ relationships [ $ name ] = $ property ; } } return $ relationships ; } | Returns an array of relationships . |
37,722 | public function storeFile ( $ file ) { $ filename = md5 ( $ this -> id ) ; $ data = file_get_contents ( $ file -> tmp_name ) ; if ( $ this -> getFileName ( ) == $ this -> name ) { $ this -> name = $ file -> name ; } $ file -> append ( array ( 'type' => mime_content_type ( $ file -> name ) , ) ) ; $ this -> mimeType = $... | Store Data . |
37,723 | public function setUpgradeDiscount ( $ discount ) { if ( $ this -> ordering <= 1 ) { $ discount = 0 ; } $ discount = ( float ) min ( 1 , max ( 0 , $ discount ) ) ; $ this -> setValue ( 'upgrade_discount' , $ discount ) ; return $ this ; } | Set the upgrade discount to a value between 0 and 1 . |
37,724 | public function authorizeSubscribePackage ( AnCommandContext $ context ) { $ viewer = $ context -> viewer ; return ! $ viewer -> hasSubscription ( false ) || $ this -> authorize ( 'upgradepackage' ) ; } | Authorizers subscripting to a package . |
37,725 | public function authorizeUpgradePackage ( AnCommandContext $ context ) { $ viewer = $ context -> viewer ; if ( ! $ viewer -> hasSubscription ( ) ) { return false ; } $ package = $ viewer -> subscription -> package ; return ! $ this -> eql ( $ package ) && ( $ package -> duration < $ this -> duration || $ package -> pri... | Authorizers upgrading to a package . |
37,726 | public function getActorIds ( ) { $ actorIds = $ this -> getValue ( 'actorIds' ) ; if ( $ actorIds ) { $ actorIds = explode ( ',' , $ actorIds ) ; $ actorIds = array_unique ( $ actorIds ) ; } else { $ actorIds = array ( ) ; } return $ actorIds ; } | returns actor ids as an array . |
37,727 | public function unserialize ( $ data ) { $ value = @ json_decode ( $ data , true ) ; if ( ! $ value ) { $ value = array ( ) ; } $ this -> append ( $ value ) ; } | Instantiate the json attribute with JSON values . |
37,728 | public function validate ( $ entity ) { $ context = $ this -> getCommandContext ( ) ; $ context -> entity = $ entity ; if ( $ entity -> isValidatable ( ) ) { $ entity -> resetErrors ( ) ; } $ result = $ this -> getCommandChain ( ) -> run ( 'on.validate' , $ context ) ; return $ result !== false ; } | Validates an entity . |
37,729 | public function destroy ( $ conditions ) { $ result = false ; if ( ! empty ( $ conditions ) ) { $ this -> getCommandChain ( ) -> disable ( ) ; $ result = $ this -> getStore ( ) -> delete ( $ this , $ conditions ) ; $ this -> getCommandChain ( ) -> enable ( ) ; } return $ result ; } | Destroy all the entities from a repository withouth instantiating them . |
37,730 | public function update ( $ values , $ conditions ) { $ result = false ; if ( ! empty ( $ conditions ) ) { $ this -> getCommandChain ( ) -> disable ( ) ; $ result = $ this -> getStore ( ) -> update ( $ this , $ conditions , $ values ) ; $ this -> getCommandChain ( ) -> enable ( ) ; } return $ result ; } | Updates a set of entities without instantiating them . |
37,731 | public function fetch ( $ condition = null , $ mode = AnDomain :: FETCH_ENTITY ) { $ query = AnDomainQuery :: getInstance ( $ this , $ condition ) ; $ context = $ this -> getCommandContext ( ) ; $ context -> operation = AnDomain :: OPERATION_FETCH ; $ context -> query = $ query ; $ context -> mode = $ mode ; $ query ->... | Fetch an entity . The condition can be a query object an associative array or an id of an entity . |
37,732 | public function getEntity ( $ config = array ( ) ) { if ( $ this -> getDescription ( ) -> isAbstract ( ) ) { throw new AnDomainRepositoryException ( 'Can not instantiate an abstract entity ' . $ this -> getDescription ( ) -> getEntityIdentifier ( ) ) ; } $ context = $ this -> getCommandContext ( ) ; $ context -> append... | Return a new entity initialized with the new properties . |
37,733 | public function getQuery ( $ disable_chain = false , $ condition = array ( ) ) { $ query = clone $ this -> _query ; if ( $ disable_chain ) { $ query -> disableChain ( ) ; } if ( ! empty ( $ condition ) ) { $ query -> where ( $ condition ) ; } return $ query ; } | Return the repostiroy query object . |
37,734 | public function extract ( $ entity ) { if ( $ entity -> persisted ( ) ) { $ entity -> delete ( ) -> save ( ) ; } $ this -> _space -> extractEntity ( $ entity ) ; } | Extracts an entity from the repository and the space and deletes an entity if it s persisted . |
37,735 | public function find ( $ needle , $ fetch = true ) { if ( empty ( $ needle ) ) { throw new InvalidArgumentException ( 'No condition pased to the repository::find' ) ; } if ( ! is_array ( $ needle ) ) { $ needle = array ( $ this -> _description -> getIdentityProperty ( ) -> getName ( ) => $ needle ) ; } $ found = null ;... | Find an existing entity with the passed properties . If not found it returns null . If the record is not found then try to fetch the entity from the storage . |
37,736 | protected function _beforeRepositoryFetch ( AnCommandContext $ context ) { $ key = $ context -> query -> getKey ( ) ; if ( $ key ) { $ context -> data = $ this -> find ( $ key , false ) ; if ( $ context -> data ) { return false ; } } } | If a query is unique then repository tries to search existing entities . |
37,737 | protected function _afterEntityInstantiate ( AnCommandContext $ context ) { $ entity = $ context -> entity ; $ this -> getSpace ( ) -> setEntityState ( $ entity , AnDomain :: STATE_NEW ) ; $ attributes = $ this -> getDescription ( ) -> getAttributes ( ) ; foreach ( $ attributes as $ attribute ) { $ entity -> set ( $ at... | After an enttiy has been instantiated all of its states are reset . |
37,738 | protected function _afterEntityInsert ( AnCommandContext $ context ) { $ entity = $ context -> entity ; $ id = $ this -> getDescription ( ) -> getIdentityProperty ( ) -> getName ( ) ; $ this -> getSpace ( ) -> insertEntity ( $ entity , array ( $ id => $ context [ 'result' ] ) ) ; $ entity -> set ( $ id , $ context -> r... | After an enttiy has been inserted into the repository . |
37,739 | protected function _afterEntityUpdate ( AnCommandContext $ context ) { $ this -> getSpace ( ) -> setEntityState ( $ context -> entity , AnDomain :: STATE_UPDATED ) ; } | Set the state after an entity has been updated . |
37,740 | protected function _afterEntityDelete ( AnCommandContext $ context ) { $ this -> getSpace ( ) -> setEntityState ( $ context -> entity , AnDomain :: STATE_DESTROYED ) ; } | Set the state after an entity has been deleted . |
37,741 | protected function _actionAdd ( AnCommandContext $ context ) { $ entity = parent :: _actionAdd ( $ context ) ; if ( $ entity -> isPortraitable ( ) && AnRequest :: has ( 'files.portrait' ) ) { $ file = AnRequest :: get ( 'files.portrait' , 'raw' ) ; if ( $ this -> bellowSizeLimit ( $ file ) && $ file [ 'error' ] == 0 ) ... | Add an actor . |
37,742 | protected function _actionEdit ( AnCommandContext $ context ) { $ entity = parent :: _actionEdit ( $ context ) ; if ( $ entity -> isPortraitable ( ) && AnRequest :: has ( 'files.portrait' ) ) { $ file = AnRequest :: get ( 'files.portrait' , 'raw' ) ; if ( $ this -> bellowSizeLimit ( $ file ) && $ file [ 'error' ] == 0 ... | Edit s an actor data . |
37,743 | public function setView ( $ view ) { parent :: setView ( $ view ) ; if ( ! $ this -> _view instanceof ComBaseViewAbstract ) { $ name = AnInflector :: isPlural ( $ this -> view ) ? 'actors' : 'actor' ; $ defaults [ ] = 'ComActorsView' . ucfirst ( $ view ) . ucfirst ( $ this -> _view -> name ) ; $ defaults [ ] = 'ComActo... | Set the default Actor View . |
37,744 | protected function _actionSetPrivacy ( AnCommandContext $ context ) { if ( $ this -> hasBehavior ( 'privatable' ) ) { $ this -> getBehavior ( 'privatable' ) -> execute ( 'action.setprivacy' , $ context ) ; } $ data = $ context -> data ; if ( $ data -> access != 'followers' ) { $ data -> allowFollowRequest = false ; } $... | Overwrite the setPrivacy action in privatable behavior . |
37,745 | public function bellowSizeLimit ( $ file ) { $ content = @ file_get_contents ( $ file [ 'tmp_name' ] ) ; $ filesize = strlen ( $ content ) ; $ uploadlimit = $ this -> _max_upload_limit * 1024 * 1024 ; if ( $ filesize > $ uploadlimit ) { throw new LibBaseControllerExceptionBadRequest ( 'Exceed maximum size' ) ; } return... | Checks to see whether the uploaded file exceeds the allowed limit . |
37,746 | public function getFriends ( ) { try { $ data = $ this -> get ( '/me/friends' ) ; } catch ( Exception $ e ) { throw new \ LogicException ( "Can't get connections from facebook" ) ; } if ( $ data -> error ) { throw new \ LogicException ( "Can't get connections from facebook" ) ; } $ data = AnConfig :: unbox ( $ data ) ;... | Return a set of people who are fb friends . |
37,747 | public function fetchLocation ( AnCommandContext $ context ) { $ data = $ context -> data ; if ( $ data -> location_id ) { $ attr = array ( 'id' => $ data -> location_id ) ; } else { $ attr = array ( 'latitude' => $ data -> latitude , 'longitude' => $ data -> longitude , 'name' => $ data -> name , 'address' => $ data -... | Method to fetch or create a location enitty |
37,748 | protected function _authorizeDelete ( $ context ) { $ ret = false ; $ comment = $ this -> _entity ; if ( $ this -> _viewer -> guest ( ) ) { return false ; } if ( $ this -> _viewer -> admin ( ) || $ this -> _viewer -> eql ( $ comment -> author ) ) { return true ; } if ( $ this -> _entity -> parent -> isOwnable ( ) && $ ... | Checks if a comment of a node can be deleted . |
37,749 | public function getCommandContext ( ) { $ context = $ this -> _command_chain -> getContext ( ) ; $ context -> caller = $ this -> _mixer ; return $ context ; } | Get the command chain context |
37,750 | protected function _authorizeAdd ( AnCommandContext $ context ) { $ can_publish = get_config_value ( $ this -> _entity -> component , 'can_publish' , self :: CAN_ADD_ADMIN ) ; switch ( $ can_publish ) { case self :: CAN_ADD_ADMIN : return $ this -> _viewer -> admin ( ) ; case self :: CAN_ADD_SPECIAL : return $ this -> ... | Authorize whether we can add a new actor or not . |
37,751 | public function addCover ( AnCommandContext $ context ) { $ entity = $ this -> getItem ( ) ; if ( $ entity -> isCoverable ( ) && AnRequest :: has ( 'files.cover' ) ) { $ file = AnRequest :: get ( 'files.cover' , 'raw' ) ; if ( $ this -> _mixer -> bellowSizeLimit ( $ file ) && $ file [ 'error' ] == 0 ) { $ entity -> set... | Add a cover . |
37,752 | protected function _authorizeVote ( $ context ) { if ( $ this -> _viewer -> guest ( ) ) { return false ; } if ( $ this -> _entity instanceof ComBaseDomainEntityComment ) { $ owner = $ this -> _entity -> parent -> owner ; } elseif ( $ this -> _entity -> isOwnable ( ) ) { $ owner = $ this -> _entity -> owner ; } elseif (... | Check if a node authroize being voted . |
37,753 | protected function _authorizeAddComment ( $ context ) { if ( $ this -> _viewer -> guest ( ) ) { return false ; } if ( $ this -> _entity -> isCommentable ( ) ) { if ( is_person ( $ this -> _viewer ) && $ this -> _viewer -> admin ( ) ) { return true ; } if ( ! $ this -> _entity -> openToComment ) { return false ; } if ( ... | Checks if a comment can be added to a node . |
37,754 | public function getTransport ( ) { if ( ! $ this -> _transport instanceof LibBaseDispatcherResponseTransportAbstract ) { if ( ! ( $ this -> _transport instanceof AnServiceIdentifier ) ) { $ this -> setTransport ( $ this -> _transport ) ; } $ config = array ( 'response' => $ this , ) ; $ this -> _transport = $ this -> g... | Return the transport object . |
37,755 | public function setTransport ( $ transport ) { if ( ! ( $ transport instanceof LibBaseDispatcherResponseTransportAbstract ) ) { if ( is_string ( $ transport ) && strpos ( $ transport , '.' ) === false ) { $ identifier = 'com:base.dispatcher.response.transport.' . $ transport ; } else { $ identifier = $ this -> getIdent... | Set the transport object . |
37,756 | public function setRequest ( $ request ) { if ( ! $ request instanceof LibBaseControllerRequest ) { $ request = new LibBaseControllerRequest ( $ request ) ; } $ this -> _request = $ request ; return $ this ; } | Set the response request . |
37,757 | public function send ( ) { $ format = $ this -> getRequest ( ) -> getFormat ( ) ; $ this -> setTransport ( $ format ) -> getTransport ( ) -> send ( ) ; } | Sends a header . |
37,758 | public function sanitizeData ( $ entity , $ property , $ value , $ validations = array ( ) ) { if ( is_string ( $ property ) ) { $ property = $ this -> _description -> getProperty ( $ property ) ; } if ( empty ( $ validations ) ) { $ validations = $ this -> getValidations ( $ property ) ; } $ validations = ( array ) An... | Sanitize an entity property value against an array of passed validations . |
37,759 | public function validateEntity ( $ entity ) { $ description = $ entity -> getEntityDescription ( ) ; if ( $ entity -> isModified ( ) ) { $ properties = array_intersect_key ( $ description -> getProperty ( ) , AnConfig :: unbox ( $ entity -> getModifiedData ( ) ) ) ; } else { $ properties = $ description -> getProperty ... | Called to validate an entity . By deafult it validates all the entity properties . |
37,760 | public function addValidation ( $ property , $ validation , $ options = array ( ) ) { $ validations = $ this -> getValidations ( $ property ) ; $ validations [ $ validation ] = $ options ; return $ this ; } | Adds a property validation . It overwrites an existing validation with the same name . |
37,761 | public function removeValidation ( $ property , $ validation ) { $ validations = $ this -> getValidations ( $ property ) ; unset ( $ validations [ $ validation ] ) ; return $ this ; } | Removes a property validation . |
37,762 | public function getValidations ( $ property ) { if ( is_string ( $ property ) ) { $ property = $ this -> _description -> getProperty ( $ property ) ; } $ name = $ property -> getName ( ) ; if ( ! $ this -> _validations -> $ name ) { $ this -> _validations -> $ name = new AnConfig ( ) ; } return $ this -> _validations -... | Return an array of validations for a property . |
37,763 | public function getFilter ( $ filter ) { if ( ! $ filter instanceof AnFilterAbstract ) { $ filter = ( string ) $ filter ; if ( ! isset ( $ this -> _filters [ $ filter ] ) ) { if ( is_string ( $ filter ) && strpos ( $ filter , '.' ) === false ) { $ identifier = clone $ this -> getIdentifier ( ) ; $ identifier -> path = ... | Return a filter object . |
37,764 | protected function _sanitizeLength ( AnConfig $ config ) { $ property = $ config -> property ; $ value = $ config -> value ; $ options = AnConfig :: unbox ( $ config -> options ) ; if ( ! is_array ( $ options ) ) { $ options = array ( 'max' => $ options ) ; } if ( $ property -> isAttribute ( ) && $ property -> isScalar... | Sanitize length . |
37,765 | protected function _sanitizeFormat ( AnConfig $ config ) { $ property = $ config -> property ; $ value = $ config -> value ; $ filter = $ config -> options ; if ( ! empty ( $ value ) && $ property -> isAttribute ( ) && $ property -> isScalar ( ) ) { $ value = $ this -> getFilter ( $ filter ) -> sanitize ( $ value ) ; }... | Sanitizes format of a property using a KFilter . |
37,766 | protected function _validateFormat ( AnConfig $ config ) { $ property = $ config -> property ; $ value = $ config -> value ; $ entity = $ config -> entity ; $ filter = $ config -> options ; if ( ! empty ( $ value ) && $ property -> isAttribute ( ) && $ property -> isScalar ( ) ) { if ( $ this -> getFilter ( $ filter ) ... | Validate format of a property using a KFilter . |
37,767 | protected function _validateScope ( AnConfig $ config ) { $ property = $ config -> property ; $ value = $ config -> value ; $ entity = $ config -> entity ; $ options = AnConfig :: unbox ( $ config -> options ) ; if ( ! in_array ( $ value , $ options ) ) { $ entity -> addError ( array ( 'message' => $ property -> getNam... | Validate scope of a property . |
37,768 | protected function _validateRequired ( AnConfig $ config ) { $ entity = $ config -> entity ; $ property = $ config -> property ; $ value = AnConfig :: unbox ( $ config [ 'value' ] ) ; $ present = true ; if ( $ entity -> getEntityState ( ) === AnDomain :: STATE_DELETED ) { return true ; } if ( $ property === $ entity ->... | Validate precense . |
37,769 | protected function _validateLength ( AnConfig $ config ) { $ property = $ config -> property ; $ value = $ config -> value ; $ entity = $ config -> entity ; $ options = AnConfig :: unbox ( $ config -> options ) ; if ( ! is_array ( $ options ) ) { $ options = array ( 'max' => $ options ) ; } if ( $ property -> isAttribu... | Validate length . |
37,770 | protected function _validateUniqueness ( AnConfig $ config ) { $ property = $ config -> property ; $ value = $ config -> value ; $ entity = $ config -> entity ; $ options = $ config -> options ; $ conditions = array ( ) ; $ query = $ entity -> getRepository ( ) -> getQuery ( ) ; if ( $ entity -> persisted ( ) ) { $ que... | Validate uniquess . |
37,771 | public function create ( $ data ) { $ data = new AnConfig ( $ data ) ; $ data -> append ( array ( 'owner' => $ data -> target ? $ data -> target : $ data -> subject , ) ) ; $ data = AnConfig :: unbox ( $ data ) ; return $ this -> getEntity ( array ( 'data' => $ data ) ) ; } | Creates a new story . |
37,772 | protected function _beforeRepositoryFetch ( AnCommandContext $ context ) { $ query = $ context -> query ; $ query -> where ( 'IF(@col(target.enabled) IS NULL, 1, @col(target.enabled) <> 0) AND IF(@col(subject.enabled) IS NULL, 1, @col(subject.enabled) <> 0)' ) -> link ( 'target' , array ( 'type' => 'weak' , 'bind_type'... | Before fetch . |
37,773 | public function setInverse ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; if ( ! isset ( $ this -> _parent ) ) { throw new AnException ( 'Can not have an inverse relationship with a polymorphic parent' ) ; } $ config -> append ( array ( 'cardinality' => 'many' , ) ) ; $ config -> append ( array ( 'na... | Set an invere relationship . ie . if x belongs to y then y has at least one x . |
37,774 | public function materialize ( array $ data , $ instance ) { if ( empty ( $ data ) ) { return ; } if ( ! $ this -> isMaterializable ( $ data ) ) { throw new AnDomainExceptionMapping ( $ this -> getName ( ) . ' Mapping Failed' ) ; } $ child_key = $ this -> _child_column -> key ( ) ; $ parent_value = $ data [ $ child_key ... | Materialize a many - to - one relationship for the entity and the data from the database . |
37,775 | public function write ( & $ text ) { $ matches = array ( ) ; if ( strpos ( $ text , '<html' ) ) { $ text = str_replace ( '<html' , '<html lang="' . $ this -> getService ( 'anahita:language' ) -> getTag ( ) . '"' , $ text ) ; $ text = str_replace ( '</head>' , $ this -> _renderHead ( ) . $ this -> _renderStyles ( ) . '<... | Convert the alias . |
37,776 | protected function _renderHead ( ) { $ document = $ this -> getService ( 'anahita:document' ) ; $ html = '<base href="base://" />' ; $ html .= '<title>' . $ document -> getTitle ( ) . '</title>' ; $ html .= '<meta name="description" content="' . $ document -> getDescription ( ) . '" />' ; $ html .= '<meta itemprop="nam... | Render title . |
37,777 | protected function _renderScripts ( ) { $ document = $ this -> getService ( 'anahita:document' ) ; $ string = '' ; $ string .= $ this -> _template -> getHelper ( 'javascript' ) -> language ( 'lib_anahita' ) ; $ scripts = array_reverse ( $ document -> getScripts ( ) ) ; foreach ( $ scripts as $ src => $ script ) { $ typ... | Return the document scripts . |
37,778 | protected function _renderStyles ( ) { $ document = $ this -> getService ( 'anahita:document' ) ; $ html = '' ; foreach ( $ document -> getStyleSheets ( ) as $ src => $ attr ) { $ rel = 'stylesheet' ; if ( strpos ( $ src , '.less' ) ) { $ rel .= '/less' ; } $ html .= '<link rel="' . $ rel . '" href="' . $ src . '" type... | Return the document styles . |
37,779 | public function updateProfileStatus ( $ profileId , $ status , $ options = array ( ) ) { $ options = array_merge ( array ( 'note' => '' ) , $ options ) ; $ this -> post [ 'PROFILEID' ] = $ profileId ; $ this -> post [ 'ACTION' ] = $ status ; $ this -> post [ 'NOTE' ] = $ options [ 'note' ] ; $ response = $ this -> comm... | Profile Information . |
37,780 | protected function _stripTags ( & $ text ) { $ regexp = '@<(\w+)\b.*?>.*?</\1>@si' ; $ matches = array ( ) ; $ replacements = array ( ) ; if ( preg_match_all ( $ regexp , $ text , $ matches ) ) { $ matches = $ matches [ 0 ] ; foreach ( $ matches as $ i => $ tag ) { $ replacements [ ] = $ i . '-' . md5 ( $ tag ) ; } $ t... | Strip the tags from a block of text . |
37,781 | protected function _replaceTags ( & $ text ) { if ( ! empty ( $ this -> _stripped_tags ) ) { $ text = str_replace ( $ this -> _stripped_tags [ 0 ] , $ this -> _stripped_tags [ 1 ] , $ text ) ; } } | Put the stipped tags back in their oringal place . |
37,782 | public function setStartDate ( $ date ) { $ date = AnDomainAttributeDate :: getInstance ( ) -> setDate ( $ date ) ; $ this -> set ( 'startDate' , $ date ) ; return $ this ; } | Sets the start date of an expirable . |
37,783 | protected function _actionSetprivacy ( $ context ) { $ data = $ context -> data ; $ names = AnConfig :: unbox ( $ data -> privacy_name ) ; settype ( $ names , 'array' ) ; foreach ( $ names as $ name ) { $ this -> getItem ( ) -> setPermission ( $ name , $ data -> $ name ) ; } } | Set a privacy for a privatable entity . |
37,784 | protected function _actionEdit ( AnCommandContext $ context ) { $ result = parent :: _actionEdit ( $ context ) ; $ this -> registerCallback ( 'after.edit' , array ( $ this , 'redirect' ) ) ; } | Redirect after edit . |
37,785 | public function redirect ( AnCommandContext $ context ) { if ( $ context -> action === 'edit' || $ context -> action === 'add' ) { $ context -> response -> setRedirect ( route ( $ this -> getItem ( ) -> getURL ( ) . '&layout=edit' ) ) ; } else { return parent :: redirect ( $ context ) ; } } | Article post action . |
37,786 | protected function _beforeControllerGet ( AnCommandContext $ context ) { if ( $ this -> cid ) { $ context -> response -> content = $ this -> getCommentController ( ) -> id ( $ this -> cid ) -> display ( ) ; return false ; } elseif ( $ this -> permalink && ! $ context -> request -> isAjax ( ) ) { $ cid = ( int ) preg_re... | Intercept a get method to check whether to show the comments only or not . |
37,787 | protected function _actionGetcomments ( AnCommandContext $ context ) { $ this -> getCommentController ( ) -> getRequest ( ) -> remove ( 'get' ) ; $ this -> getCommentController ( ) -> limit ( $ this -> getRequest ( ) -> get ( 'limit' ) ) -> start ( $ this -> getRequest ( ) -> get ( 'start' ) ) ; $ this -> getCommentCon... | Render the comments . |
37,788 | public function getCommentController ( ) { if ( ! isset ( $ this -> _comment_controller ) ) { $ identifier = clone $ this -> getIdentifier ( ) ; $ identifier -> path = array ( 'controller' ) ; $ identifier -> name = 'comment' ; $ request = new LibBaseControllerRequest ( array ( 'format' => $ this -> getRequest ( ) -> g... | Returns the comment controller . |
37,789 | protected function _actionCommentstatus ( $ context ) { $ data = $ context -> data ; $ this -> getItem ( ) -> openToComment = ( bool ) $ data -> status ; } | Toggles comment status . |
37,790 | public function getTemplate ( ) { if ( empty ( $ this -> _template ) ) { if ( ! AnService :: get ( 'application.registry' ) -> offsetExists ( 'application-template' ) ) { AnService :: get ( 'application.registry' ) -> offsetSet ( 'application-template' , $ this -> _site_settings -> template ) ; } $ template = AnService... | Get the template . |
37,791 | function getName ( ) { $ name = $ this -> _name ; if ( empty ( $ name ) ) { $ r = null ; if ( ! preg_match ( '/Com(.*)/i' , get_class ( $ this ) , $ r ) ) { throw new AnErrorException ( "Can't get or parse the class name " , AnHttpResponse :: INTERNAL_SERVER_ERROR ) ; } $ name = strtolower ( $ r [ 1 ] ) ; } return $ na... | Method to get the application name |
37,792 | public function & __get ( $ property ) { if ( isset ( $ this -> { '_' . $ property } ) ) { if ( $ property == 'filepath' && empty ( $ this -> _filepath ) ) { $ this -> _filepath = self :: $ _locators [ $ this -> _type ] -> findPath ( $ this ) ; } if ( $ property == 'classname' && empty ( $ this -> _classname ) ) { $ th... | Implements access to virtual properties by reference so that it appears to be a public property . |
37,793 | protected function _actionPin ( $ context ) { $ context -> response -> status = AnHttpResponse :: RESET_CONTENT ; $ this -> getItem ( ) -> pinned = 1 ; return $ this -> getItem ( ) ; } | Pin Entity . |
37,794 | public function addressToArray ( ) { return array ( 'address' => $ this -> address , 'city' => $ this -> city , 'state_province' => $ this -> state_province , 'country' => $ this -> country , 'postalcode' => $ this -> postalcode , 'latitude' => $ this -> latitude , 'longitude' => $ this -> longitude ) ; } | returns address as an array |
37,795 | protected function _authorizeAccess ( $ context ) { if ( is_person ( $ this -> _viewer ) && $ this -> _viewer -> admin ( ) ) { return true ; } if ( $ this -> _entity -> isPrivatable ( ) ) { return $ this -> _entity -> allows ( $ this -> _viewer , 'access' ) ; } } | Check if a medium authorizes acccess . |
37,796 | public function setView ( $ view ) { parent :: setView ( $ view ) ; if ( ! $ this -> _view instanceof LibBaseViewAbstract ) { $ view = AnInflector :: isPlural ( $ view ) ? 'comments' : 'comment' ; $ defaults [ ] = 'ComBaseView' . ucfirst ( $ view ) . ucfirst ( $ this -> _view -> name ) ; register_default ( array ( 'ide... | Sets the default view to the comment views . |
37,797 | protected function _setDisposition ( ) { if ( isset ( $ this -> disposition ) && $ this -> disposition == 'inline' ) { header ( 'Content-Disposition: inline; filename="' . $ this -> filename . '"' ) ; } else { header ( 'Content-Description: File Transfer' ) ; header ( 'Content-type: application/octet-stream' ) ; header... | Set the header disposition headers . |
37,798 | protected function _readChunked ( $ path ) { $ chunksize = 1 * ( 1024 * 1024 ) ; $ buffer = '' ; $ cnt = 0 ; $ handle = fopen ( $ path , 'rb' ) ; if ( $ handle === false ) { throw new KViewException ( 'Cannot open file' ) ; } while ( ! feof ( $ handle ) ) { $ buffer = fread ( $ handle , $ chunksize ) ; echo $ buffer ; ... | Read a file in chunks and flush it to the output stream . |
37,799 | protected function _sanitize ( $ value ) { $ value = trim ( strtolower ( $ value ) ) ; $ pattern = '/[^a-f0-9]*/' ; return substr ( preg_replace ( $ pattern , '' , $ value ) , 0 , 32 ) ; } | Sanitize a valaue |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.