idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
18,300 | final public function extendPropertyModel ( $ dataModel = array ( ) , $ objectType = "object" ) { $ this -> propertyModel = array_merge ( $ this -> propertyModel , $ dataModel ) ; $ this -> setObjectType ( $ objectType ) ; return $ this ; } | Extends the parent data model Allows the current object to use parent object properties |
18,301 | final public function definePropertyModel ( $ dataModel = array ( ) , $ objectType = "object" ) { $ this -> propertyModel = $ dataModel ; $ this -> setObjectType ( $ objectType ) ; return $ this ; } | Creates a completely new data model . Any Properties not explicitly described for this object will be ignored |
18,302 | final public function defineValueGroup ( $ valueGroup = NULL ) { $ this -> valueGroup = ! empty ( $ valueGroup ) ? trim ( $ valueGroup ) . "_" : NULL ; if ( ! empty ( $ valueGroup ) ) { return $ this -> setObjectType ( trim ( $ valueGroup ) ) ; } } | Defines a sub table for value data ; |
18,303 | public function IP2City ( $ ip ) { $ baidu_IP_url = 'http://api.map.baidu.com/location/ip?ak=bsa3LH1GT1jhOep5N7Uz950xtTQWvp9I&ip=' . $ ip . '&coor=bd09ll' ; $ client = new Client ( ) ; $ json = $ client -> get ( $ baidu_IP_url ) -> getBody ( ) ; return json_decode ( $ json , true ) ; } | IP to City |
18,304 | public function oneToMany ( $ id , $ name , $ img , $ gender ) { $ ids = explode ( ',' , $ id ) ; $ names = explode ( ',' , $ name ) ; $ imgs = explode ( ',' , $ img ) ; $ genders = explode ( ',' , $ gender ) ; for ( $ i = 0 ; $ i < count ( $ names ) ; $ i ++ ) { $ male = "" ; if ( $ genders [ $ i ] == 1 ) $ male = " c... | 1 to many |
18,305 | public function getConfigList ( $ list ) { $ records = Conf :: where ( 'config.list' , $ list ) -> leftJoin ( 'config as p' , 'config.parent_id' , '=' , 'p.id' ) -> orderBy ( 'config.parent_id' ) -> select ( 'config.id' , 'config.parent_id' , 'config.text' , 'p.text as pre_text' ) -> get ( ) ; $ out = [ ] ; $ parent_id... | get config items |
18,306 | public function removeForBillingToAllAddresses ( $ actorId ) { $ qb = $ this -> getQueryBuilder ( ) -> update ( ) -> set ( 'a.forBilling' , 0 ) -> where ( 'a.actor = :actor' ) -> setParameter ( 'actor' , $ actorId ) ; $ qb -> getQuery ( ) -> execute ( ) ; } | Remove the forBilling field to all addresses of the given actor |
18,307 | public function complete ( $ params ) { $ requestParams = $ this -> initRequestParams ( 'complete' , $ params ) ; $ this -> request ( 'complete' , $ requestParams ) ; return empty ( $ this -> error ) ; } | Complete authorization payment |
18,308 | public function refund ( $ params ) { $ requestParams = $ this -> initRequestParams ( 'refund' , $ params ) ; $ this -> request ( 'refund' , $ requestParams ) ; return empty ( $ this -> error ) ; } | Refund for complete or sale payments |
18,309 | public function callback ( array $ params = null ) { $ this -> cleanup ( ) ; if ( null === $ params ) { if ( ! empty ( $ _POST ) ) { $ params = $ _POST ; } } if ( empty ( $ params ) || empty ( $ params [ 'term' ] ) || empty ( $ params [ 'sign' ] ) || empty ( $ params [ 'type' ] ) ) { throw new GatewayException ( 'Input... | Parse callback request |
18,310 | private function initRequestParams ( $ type , $ params ) { $ list = self :: $ customParams ; if ( ! isset ( $ list [ $ type ] ) ) { throw new GatewayException ( 'Undefined request type' ) ; } $ list = $ list [ $ type ] ; $ requestParams = array ( ) ; foreach ( $ list as $ key ) { if ( ! empty ( $ params [ $ key ] ) ) {... | Generate params for http query |
18,311 | private function convert ( $ requestParams ) { $ convertedParams = array ( ) ; $ convertList = self :: $ convertRequestParams ; if ( isset ( $ convertList [ 'term' ] ) ) { $ convertList = array_flip ( $ convertList ) ; } foreach ( $ requestParams as $ key => $ value ) { if ( isset ( $ convertList [ $ key ] ) ) { $ conv... | Reverse gateway and human names |
18,312 | protected function getErrorMessage ( $ nCode , $ strMessage = null ) { $ strReturn = 'Failure: ' ; if ( null !== $ this -> strResourcePath ) { $ strReturn = 'Path: "' . $ this -> strResourcePath . '" ' ; } $ strReturn .= 'Name: "' . $ this -> strResourceName . '"' ; $ strReturn .= ' Code: ' ; switch ( $ nCode ) { case ... | Builds and returns an error message for this exception . |
18,313 | public function submit ( LongLog $ longLog ) { $ curl = curl_init ( $ this -> getEndpointUrl ( ) . '/project/log' ) ; curl_setopt ( $ curl , CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' , ] ) ; curl_setopt ( $ curl , CURLOPT_TIMEOUT , $ this -> getTimeout ( ) ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYHOST... | Send log to API |
18,314 | public function setProjectToken ( $ token ) { if ( ! $ token ) { throw new InvalidArgumentException ( 'Project token required' ) ; } elseif ( strlen ( $ token ) !== 32 ) { throw new InvalidArgumentException ( 'Project token must be 32 characters length' ) ; } $ this -> projectToken = $ token ; return $ this ; } | Set project token |
18,315 | public static function typed ( string $ type , iterable $ input = [ ] ) : Vector { $ resolver = Resolver :: typed ( $ type ) ; return new static ( $ input , $ resolver ) ; } | Vector named constructor . |
18,316 | public function loadConfig ( $ file ) { $ options = [ ] ; try { $ loader = new PhpConfig ( ) ; $ options = $ loader -> read ( $ file ) ; } catch ( \ Exception $ e ) { Log :: warning ( $ e -> getMessage ( ) ) ; } $ this -> config ( 'options' , $ options ) ; } | Load a config file containing editor options . |
18,317 | protected function _format ( $ varname , $ objectname , $ data ) { $ format = $ this -> $ varname ; $ replaceData = str_ireplace ( array_keys ( $ format ) , array_values ( $ format ) , $ data ) ; $ this -> $ objectname = $ this -> _slashes ( $ replaceData ) ; } | Protected Time Format |
18,318 | protected function classFile ( $ className ) { $ classFile = preg_replace ( '#[_\\\]#' , '/' , $ className ) . '.php' ; foreach ( $ this -> _paths as $ path ) { $ classPath = "$path/$classFile" ; if ( file_exists ( $ classPath ) ) { return $ classPath ; } } } | Returns the class file for a particular class name |
18,319 | public function loadClass ( $ className ) { if ( class_exists ( $ className , false ) || interface_exists ( $ className , false ) ) { return false ; } if ( $ classFile = $ this -> classFile ( $ className ) ) { require $ classFile ; return true ; } return false ; } | SPL autoload function loads a class file based on the class name . |
18,320 | public function includePaths ( $ path ) { $ paths = is_array ( $ path ) ? $ path : array ( $ path ) ; $ this -> _paths = array_merge ( $ paths , $ this -> _paths ) ; return $ this ; } | Prepends one or more items to the include path of the class loader and the php include path . |
18,321 | public function export ( ) { $ systemPaths = explode ( PATH_SEPARATOR , get_include_path ( ) ) ; set_include_path ( implode ( PATH_SEPARATOR , array_merge ( $ systemPaths , $ this -> _paths ) ) ) ; return $ this ; } | Exports the classloader path into the PHP system include path |
18,322 | protected function getValue ( ) { if ( ! $ this -> trigger ( CachePool :: EVENT_GET_BEFORE ) ) { $ this -> setHit ( false ) ; return null ; } $ this -> strval = $ this -> pool -> getDriver ( ) -> get ( $ this -> key ) ; if ( ! $ this -> trigger ( CachePool :: EVENT_GET_AFTER ) ) { $ this -> setHit ( false ) ; $ this ->... | Get value from the cache pool |
18,323 | protected function hasHit ( ) { if ( ! $ this -> trigger ( CachePool :: EVENT_HAS_BEFORE ) ) { return $ this -> setHit ( false ) ; } $ meta = $ this -> pool -> getDriver ( ) -> has ( $ this -> key ) ; if ( isset ( $ meta [ 'expire' ] ) ) { $ this -> expire = $ meta [ 'expire' ] ; } else { return $ this -> setHit ( fals... | Get hit status from driver |
18,324 | protected function getPlaceHolders ( $ message ) { if ( false === strpos ( $ message , '{' ) ) { return [ ] ; } $ matches = [ ] ; $ pattern = '~\{([^\}]+)\}~' ; if ( preg_match_all ( $ pattern , $ message , $ matches ) ) { return array_combine ( $ matches [ 1 ] , $ matches [ 0 ] ) ; } return [ ] ; } | Get placeholders in array |
18,325 | protected function replaceWith ( $ name , $ placeholder , array & $ context ) { if ( isset ( $ context [ $ name ] ) ) { return $ this -> getString ( $ context [ $ name ] ) ; } $ first = explode ( '.' , $ name ) [ 0 ] ; if ( false !== strpos ( $ name , '.' ) && isset ( $ context [ $ first ] ) ) { return $ this -> getSub... | Replace with values from the context array |
18,326 | protected function getObjectString ( $ object ) { if ( $ object instanceof \ Exception ) { return 'EXCEPTION: ' . $ object -> getMessage ( ) ; } elseif ( method_exists ( $ object , '__toString' ) ) { return ( string ) $ object ; } else { return 'OBJECT: ' . get_class ( $ object ) ; } } | Get string representation of an object |
18,327 | protected function getSubPart ( $ name , $ placeholder , $ data ) { list ( , $ second ) = explode ( '.' , $ name , 2 ) ; $ arr = ( array ) $ data ; if ( isset ( $ arr [ $ second ] ) ) { return $ arr [ $ second ] ; } return $ placeholder ; } | Get user . name type of result only support 2 level |
18,328 | public function getValueAttribute ( $ name , $ value = null ) { if ( strpos ( $ name , '[]' ) !== false ) { $ name = str_replace ( '[]' , '' , $ name ) ; } if ( $ this -> hasOldInput ( ) ) { return $ this -> getOldInput ( $ name ) ; } if ( $ this -> hasModelValue ( $ name ) ) { return $ this -> getModelValue ( $ name )... | Get value from an attribute . |
18,329 | public function wpEditor ( $ name , $ value = null , $ options = array ( ) ) { ob_start ( ) ; $ value = $ this -> getValueAttribute ( $ name , $ value ) ; $ value = $ this -> html -> decode ( $ value ) ; wp_editor ( $ value , $ name , $ options = array ( ) ) ; $ wpEditor = ob_get_contents ( ) ; ob_end_clean ( ) ; retur... | Create a WordPress Editor . |
18,330 | public function radio ( $ name , $ value = null , $ checked = null , $ options = array ( ) ) { if ( is_null ( $ value ) ) { $ value = $ name ; } return $ this -> checkable ( 'radio' , $ name , $ value , $ checked , $ options ) ; } | Create a radio button input field . |
18,331 | protected function checkable ( $ type , $ name , $ value , $ checked , $ options ) { $ checked = $ this -> getCheckedState ( $ type , $ name , $ value , $ checked ) ; if ( $ checked ) { $ options [ 'checked' ] = 'checked' ; } return $ this -> input ( $ type , $ name , $ value , $ options ) ; } | Create a checkable input field . |
18,332 | public function hook ( ) { wp_enqueue_script ( 'jquery' ) ; add_action ( 'wp_head' , array ( $ this , 'printToken' ) ) ; add_action ( 'admin_head' , array ( $ this , 'printToken' ) ) ; add_action ( 'wp_footer' , array ( $ this , 'printAjaxHeader' ) ) ; add_action ( 'admin_footer' , array ( $ this , 'printAjaxHeader' ) ... | Hook required script to WordPress . |
18,333 | public function post ( Request $ request ) { $ email = Arr :: get ( $ this -> getContentAsArray ( $ request ) , 'email' ) ; $ user = $ this -> userService -> findByEmail ( $ email ) ; if ( ! $ user ) { return $ this -> createNotFoundResponse ( ) ; } $ token = $ this -> userService -> findTokenBy ( [ 'user_id' => $ user... | Send reset password email |
18,334 | public function put ( Request $ request ) { $ token = Arr :: get ( $ this -> getContentAsArray ( $ request ) , 'token' ) ; $ token = $ this -> userService -> findTokenBy ( [ 'token' => $ token , 'token_type_id' => TokenEntity :: TYPE_RESET_PASSWORD , ] ) ; if ( ! $ token ) { return $ this -> createNotFoundResponse ( ) ... | Reset password using token and new password |
18,335 | public function initFeaturedSkills ( $ overrideExisting = true ) { if ( null !== $ this -> collFeaturedSkills && ! $ overrideExisting ) { return ; } $ this -> collFeaturedSkills = new ObjectCollection ( ) ; $ this -> collFeaturedSkills -> setModel ( '\gossi\trixionary\model\Skill' ) ; } | Initializes the collFeaturedSkills collection . |
18,336 | public function getFeaturedSkillsJoinMultipleOf ( Criteria $ criteria = null , ConnectionInterface $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildSkillQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'MultipleOf' , $ joinBehavior ) ; return $ this -> getFeaturedSkills ( $ query , ... | If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this Picture is new it will return an empty collection ; or if this Picture has previously been saved it will retrieve related FeaturedSkills from storage . |
18,337 | private function wrapEntry ( $ entry , $ fileMimeType ) { $ wrappedEntry = "--{$this->_boundaryString}\r\n" ; $ wrappedEntry .= "Content-Type: application/atom+xml\r\n\r\n" ; $ wrappedEntry .= $ entry ; $ wrappedEntry .= "\r\n--{$this->_boundaryString}\r\n" ; $ wrappedEntry .= "Content-Type: $fileMimeType\r\n\r\n" ; re... | Sandwiches the entry body into a MIME message |
18,338 | public function read ( $ bytesRequested ) { if ( $ this -> _currentPart >= count ( $ this -> _parts ) ) { return FALSE ; } $ activePart = $ this -> _parts [ $ this -> _currentPart ] ; $ buffer = $ activePart -> read ( $ bytesRequested ) ; while ( strlen ( $ buffer ) < $ bytesRequested ) { $ this -> _currentPart += 1 ; ... | Read a specific chunk of the the MIME multipart message . |
18,339 | public function validate ( $ subject ) : bool { $ propertyNames = \ array_keys ( $ subject ) ; foreach ( $ propertyNames as $ propertyName ) { $ nodeValidator = new NodeValidator ( $ this -> schema [ 'propertyNames' ] , $ this -> rootSchema ) ; if ( ! $ nodeValidator -> validate ( $ propertyName ) ) { return false ; } ... | Validates subject against propertyNames |
18,340 | public function execute ( $ command ) { $ commandClass = get_class ( $ command ) ; $ mappings = $ this -> getMappings ( ) ; $ this -> checkIfCommandExistsInMappings ( $ commandClass , $ mappings ) ; $ handlerClass = array_get ( $ mappings , $ commandClass ) ; try { return $ this -> getContainer ( ) -> make ( $ handlerC... | Dispatch a command on the dispatcher . |
18,341 | public function get ( string $ route , $ handler ) : Route { return $ this -> createRoute ( Method :: GET , $ route , $ handler ) ; } | Add route matched with GET method . Shortcut for createRoute function with preset GET method . |
18,342 | public function post ( string $ route , $ handler ) : Route { return $ this -> createRoute ( Method :: POST , $ route , $ handler ) ; } | Add route matched with POST method . Shortcut for createRoute function with preset POST method . |
18,343 | public function delete ( string $ route , $ handler ) : Route { return $ this -> createRoute ( Method :: DELETE , $ route , $ handler ) ; } | Add route matched with DELETE method . Shortcut for createRoute function with preset DELETE method . |
18,344 | public function put ( string $ route , $ handler ) : Route { return $ this -> createRoute ( Method :: PUT , $ route , $ handler ) ; } | Add route matched with PUT method . Shortcut for createRoute function with preset PUT method . |
18,345 | public function any ( string $ route , $ handler ) : Route { return $ this -> createRoute ( Method :: ANY , $ route , $ handler ) ; } | Add route which will be matched to any method . Shortcut for createRoute function with preset ANY method . |
18,346 | public function loadPreference ( $ name , $ index = null , $ includeExpired = false ) { foreach ( $ this -> getPreferences ( ) as $ pref ) { if ( ( $ pref -> getName ( ) == $ name ) && ( $ pref -> getIx ( ) === $ index ) ) { if ( $ includeExpired || ! $ pref -> getExpiresAt ( ) || ( $ pref -> getExpiresAt ( ) > new \ D... | Return the entity object of the named preference |
18,347 | public function hasPreference ( $ name , $ index = null , $ includeExpired = false ) { return $ this -> getPreference ( $ name , $ index , $ includeExpired ) ; } | Does the named preference exist or not? |
18,348 | public function getPreference ( $ name , $ index = null , $ includeExpired = false ) { $ pref = $ this -> loadPreference ( $ name , $ index , $ includeExpired ) ; if ( ! $ pref ) return false ; return $ pref -> getValue ( ) ; } | Get the named preference s VALUE |
18,349 | public function setPreference ( $ name , $ value , $ expires = null , $ index = null ) { $ pref = $ this -> loadPreference ( $ name , $ index ) ; if ( is_int ( $ expires ) ) $ expires = new \ DateTime ( date ( 'Y-m-d H:i:s' , $ expires ) ) ; elseif ( is_string ( $ expires ) ) $ expires = new \ DateTime ( $ expires ) ; ... | Set or update a preference |
18,350 | public function addIndexedPreference ( $ name , $ value , $ expires = null , $ max = 0 ) { $ highest = - 1 ; $ count = 0 ; foreach ( $ this -> getPreferences ( ) as $ pref ) { if ( $ pref -> getName ( ) == $ name ) { $ count ++ ; if ( $ pref -> getIx ( ) > $ highest ) $ highest = $ pref -> getIx ( ) ; } } if ( $ max &&... | Add an indexed preference |
18,351 | public function cleanExpiredPreferences ( $ asOf = null , $ name = null ) { $ count = 0 ; if ( $ asOf === null ) $ asOf = new \ DateTime ( ) ; elseif ( is_int ( $ asOf ) ) $ asOf = new \ DateTime ( date ( 'Y-m-d H:i:s' , $ asOf ) ) ; elseif ( is_string ( $ asOf ) ) $ asOf = new \ DateTime ( $ asOf ) ; foreach ( $ this ... | Clean expired preferences |
18,352 | public function deletePreference ( $ name , $ index = null ) { $ count = 0 ; foreach ( $ this -> getPreferences ( ) as $ pref ) { if ( ( $ pref -> getName ( ) == $ name ) && ( ( $ index === null ) || ( $ pref -> getIx ( ) == $ index ) ) ) { $ count ++ ; $ this -> getPreferences ( ) -> removeElement ( $ pref ) ; \ D2EM ... | Delete the named preference |
18,353 | public function expungePreferences ( ) { return \ D2EM :: createQuery ( 'delete \\Entities\\' . $ this -> _getPreferenceClassName ( ) . ' up where up.' . $ this -> _getShortClassname ( ) . ' = ?1' ) -> setParameter ( 1 , $ this ) -> execute ( ) ; } | Deletes all preferences . |
18,354 | public function getIndexedPreference ( $ name , $ withIndex = false , $ ignoreExpired = true ) { $ values = [ ] ; foreach ( $ this -> getPreferences ( ) as $ pref ) { if ( $ pref -> getName ( ) == $ name ) { if ( $ ignoreExpired && $ pref -> getExpiresAt ( ) && ( $ pref -> getExpiresAt ( ) < new \ DateTime ( ) ) ) cont... | Get indexed preferences as an array |
18,355 | public function getAssocPreference ( $ name , $ index = null , $ ignoreExpired = true ) { $ values = [ ] ; foreach ( $ this -> getPreferences ( ) as $ pref ) { if ( strpos ( $ pref -> getName ( ) , $ name ) === 0 ) { if ( ( $ index === null ) || ( $ pref -> getIx ( ) == $ index ) ) { if ( ! $ ignoreExpired && $ pref ->... | Get associative preferences as an array . |
18,356 | public function name ( $ data ) { if ( is_object ( $ data ) && isset ( $ data -> type ) ) { return $ data -> value ; } if ( $ data === '*' ) { return '*' ; } if ( is_array ( $ data ) ) { foreach ( $ data as $ i => $ dataItem ) { $ data [ $ i ] = $ this -> name ( $ dataItem ) ; } return $ data ; } return ( string ) $ da... | Imitation of DboSource method . |
18,357 | public function getLog ( $ sorted = false , $ clear = true ) { if ( $ sorted ) { $ log = sortByKey ( $ this -> _requestsLog , 'took' , 'desc' , SORT_NUMERIC ) ; } else { $ log = $ this -> _requestsLog ; } if ( $ clear ) { $ this -> _requestsLog = array ( ) ; } return array ( 'log' => $ log , 'count' => count ( $ log ) ... | Get the query log as an array . |
18,358 | protected function _registerLog ( Model $ model , & $ queryData , $ took , $ numRows ) { if ( ! Configure :: read ( ) ) { return ; } $ this -> _requestsLog [ ] = array ( 'query' => $ this -> _pseudoSelect ( $ model , $ queryData ) , 'error' => '' , 'affected' => 0 , 'numRows' => $ numRows , 'took' => round ( $ took , 3... | Generate a log registry |
18,359 | protected function _pseudoSelect ( Model $ model , & $ queryData ) { $ out = '(symbolic) SELECT ' ; if ( empty ( $ queryData [ 'fields' ] ) ) { $ out .= '*' ; } elseif ( $ queryData [ 'fields' ] ) { $ out .= 'COUNT(*)' ; } else { $ out .= implode ( ', ' , $ queryData [ 'fields' ] ) ; } $ out .= ' FROM ' . $ model -> al... | Generate a pseudo select to log |
18,360 | public function addConnection ( array $ config , $ name = 'default' ) { $ this -> connectionResolver -> addConnection ( $ this -> make ( $ config ) , $ name ) ; return $ this ; } | Register a connection . |
18,361 | protected function createSingleConnection ( array $ config ) { $ connector = $ this -> createConnector ( $ config ) -> connect ( $ config ) ; return $ this -> createConnection ( $ connector , $ config ) ; } | Create a single API connection instance . |
18,362 | public function handle ( $ msg ) { if ( ! $ msg instanceof JobMessage ) { if ( $ this -> logger ) { $ this -> logger -> info ( 'No more message' ) ; } return false ; } return $ this -> handleMsg ( $ msg ) ; } | Handle msg after its execution . If we need to create a new msg to continue execution or stop here |
18,363 | public function addSkills ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Reference not found.' ] ) ; } try { $ this -> doAddSkills ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] )... | Adds Skills to Reference |
18,364 | public function addVideos ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Reference not found.' ] ) ; } try { $ this -> doAddVideos ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] )... | Adds Videos to Reference |
18,365 | public function updateSkills ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Reference not found.' ] ) ; } try { $ this -> doUpdateSkills ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors (... | Updates Skills on Reference |
18,366 | public function updateVideos ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Reference not found.' ] ) ; } try { $ this -> doUpdateVideos ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors (... | Updates Videos on Reference |
18,367 | protected function doAddVideos ( Reference $ model , $ data ) { $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Video' ; } else { $ related = VideoQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addVideo ( $ related ) ; } } if ( ... | Interal mechanism to add Videos to Reference |
18,368 | protected function doUpdateSkills ( Reference $ model , $ data ) { SkillReferenceQuery :: create ( ) -> filterByReference ( $ model ) -> delete ( ) ; $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Skill' ; } else { $ related = SkillQuery :: create (... | Internal update mechanism of Skills on Reference |
18,369 | protected function doUpdateVideos ( Reference $ model , $ data ) { VideoQuery :: create ( ) -> filterByReference ( $ model ) -> delete ( ) ; $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Video' ; } else { $ related = VideoQuery :: create ( ) -> fin... | Internal update mechanism of Videos on Reference |
18,370 | public static function get ( $ key ) { $ exists = ( isset ( $ _SESSION [ $ key ] ) ) ? true : false ; if ( ! $ exists ) return $ exists ; else return $ _SESSION [ $ key ] ; } | This method returns a session data by key |
18,371 | public function setAccountNumber ( $ accountNumber ) { $ this -> accountNumber = ( string ) $ accountNumber ; $ this -> lastFour = substr ( ( string ) $ accountNumber , - 4 ) ; } | Set Account Number |
18,372 | protected function generateGetAll ( ResourceConfiguration $ config ) { $ that = $ this ; $ this -> slim -> get ( $ this -> baseRoute ( $ config ) , function ( ) use ( $ that ) { $ that -> executeRoute ( 'index' , func_get_args ( ) ) ; } ) ; } | Generates the index route . |
18,373 | protected function generateGetSingle ( ResourceConfiguration $ config ) { $ that = $ this ; $ this -> slim -> get ( "{$this->baseRoute($config)}/:id" , function ( ) use ( $ that ) { $ that -> executeRoute ( 'show' , func_get_args ( ) ) ; } ) ; } | Generates the show route . |
18,374 | protected function generatePost ( ResourceConfiguration $ config ) { $ that = $ this ; $ this -> slim -> post ( $ this -> baseRoute ( $ config ) , function ( ) use ( $ that ) { $ that -> executeRoute ( 'create' , func_get_args ( ) ) ; } ) ; } | Generates the create route . |
18,375 | protected function generatePut ( ResourceConfiguration $ config ) { $ that = $ this ; $ this -> slim -> put ( "{$this->baseRoute($config)}/:id" , function ( ) use ( $ that ) { $ that -> executeRoute ( 'update' , func_get_args ( ) ) ; } ) ; } | Generates the update route . |
18,376 | protected function generateDelete ( ResourceConfiguration $ config ) { $ that = $ this ; $ this -> slim -> delete ( "{$this->baseRoute($config)}/:id" , function ( ) use ( $ that ) { $ that -> executeRoute ( 'delete' , func_get_args ( ) ) ; } ) ; } | Generates the delete route . |
18,377 | protected function parentRoutesFor ( ResourceConfiguration $ config ) { if ( $ config -> getParent ( ) ) { $ parentConfig = $ this -> configuration -> resourceConfigurationFor ( $ config -> getParent ( ) ) ; return $ this -> parentRoutesFor ( $ parentConfig ) . "/{$config->getParent()}/:{$config->getParent()}_id" ; } } | Gets the parents routes for a given child resource . |
18,378 | public function findAll ( ) { $ repos = array ( ) ; foreach ( $ this -> repository -> findAll ( ) as $ repo ) { $ this -> loadPackagistInfos ( $ repo ) ; $ repos [ ] = $ repo ; } return $ repos ; } | Find all repos |
18,379 | public function loadExtraInfos ( Repo $ repo ) { try { $ this -> scrutinizerLoader -> load ( $ repo ) ; $ this -> travisLoader -> load ( $ repo ) ; $ this -> versionEyeLoader -> load ( $ repo ) ; } catch ( \ Exception $ e ) { print_r ( $ e -> getMessage ( ) ) ; } } | Load infos from travis & scrutinizer |
18,380 | public function loadPackagistInfos ( Repo $ repo ) { try { $ this -> composerReader -> load ( $ repo -> getSlug ( ) ) ; if ( $ this -> composerReader -> has ( 'name' ) ) { $ repo -> setPackagistSlug ( $ this -> composerReader -> get ( 'name' ) ) ; } if ( $ this -> composerReader -> has ( 'authors' ) ) { $ repo -> setAu... | Load packagist infos by reading composer json file |
18,381 | protected function loadRepo ( Repo $ repo = null ) { if ( null == $ repo ) { return null ; } $ this -> loadExtraInfos ( $ repo ) ; $ this -> loadPackagistInfos ( $ repo ) ; return $ repo ; } | Load repo infos |
18,382 | public function isExists ( Repo $ repo ) { $ anotherRepo = $ this -> findBySlug ( $ repo -> getSlug ( ) ) ; return ( $ anotherRepo != null && $ repo -> getId ( ) != $ anotherRepo -> getId ( ) ) ; } | Checks if slug exist |
18,383 | public static function isPossiblePathTraversalAttack ( $ path ) { $ virtualBase = '/' . md5 ( microtime ( true ) . '/' . mt_rand ( ) ) ; $ virtualPath = $ virtualBase . '/' . ltrim ( $ path , '/' ) ; return ! FileUtil :: isBasePath ( $ virtualPath , $ virtualBase ) ; } | Returns true if the given path will leave the root directory |
18,384 | public function setTitlePosition ( $ position ) { $ allowedValues = array ( "in" , "out" , "none" ) ; if ( ! in_array ( $ position , $ allowedValues ) ) { throw new \ Exception ( "Invalid position: " . $ position ) ; } $ this -> m_options [ 'titlePosition' ] = $ position ; } | Set the position of the title . |
18,385 | private function toArray ( $ obj ) { $ arr = array ( ) ; if ( is_array ( $ obj ) ) { foreach ( $ obj as $ value ) { $ arr [ ] = $ this -> toArray ( $ value ) ; } } else if ( is_object ( $ obj ) ) { $ arObj = ( array ) $ obj ; foreach ( $ arObj as $ key => $ value ) { $ attribute = str_replace ( get_class ( $ obj ) , ""... | Convierte un objeto a notacion json . |
18,386 | public function index ( ViewListener $ listener ) { $ form = $ this -> presenter -> form ( ) ; return $ listener -> show ( compact ( 'form' ) ) ; } | shows module tester default index action |
18,387 | public function prepare ( array $ data = null ) { $ response = [ ] ; $ code = 200 ; try { if ( ! isset ( $ data [ 'module' ] ) or empty ( $ data [ 'module' ] ) ) { throw new Exception \ InvalidArgumentException ( 'Unable to start tests. No module has been selected.' ) ; } $ selected = array_keys ( $ data [ 'module' ] )... | build sepcification data before real test |
18,388 | public function run ( ProcessListener $ listener , array $ data ) { try { if ( empty ( $ data ) ) { throw new Exception \ InvalidArgumentException ( 'Invalid method arguments.' ) ; } $ validator = null ; $ values = null ; if ( isset ( $ data [ 'cid' ] ) ) { $ model = MemoryTests :: findOrNew ( $ data [ 'cid' ] ) ; $ pa... | run validation of partial module configuration |
18,389 | public function setVector ( $ vector ) { if ( empty ( $ vector ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cvss vector "%s" is not valid.' , $ vector ) ) ; } if ( ! preg_match ( '/^' . self :: $ vectorHead . '.*/mi' , $ vector ) ) { throw new \ InvalidArgumentException ( ( sprintf ( 'Cvss vector "%s" is not... | Parse CVSS vector |
18,390 | protected function getSeverity ( $ score ) { foreach ( $ this -> severityRatingScale as $ level => $ options ) { if ( $ score >= $ options [ 'min_range' ] && $ score <= $ options [ 'max_range' ] ) { return $ level ; } } return null ; } | Get severity for the given score |
18,391 | public function getOverallScore ( ) { if ( $ this -> environmentalScore != $ this -> baseScore ) { return $ this -> environmentalScore ; } elseif ( $ this -> temporalScore != $ this -> baseScore ) { return $ this -> temporalScore ; } else { return $ this -> baseScore ; } } | Get overall score |
18,392 | public function getVector ( $ omitUndefined = true ) { $ metrics = [ ] ; foreach ( $ this -> vectorInputs as $ name => $ value ) { if ( $ value != 'X' || ! $ omitUndefined ) { $ metrics [ $ name ] = $ value ; } } return self :: buildVector ( $ metrics ) ; } | Get full vector |
18,393 | static function buildVector ( $ inputs ) { $ inputs = array_merge ( array ( 'CVSS' => self :: VERSION ) , $ inputs ) ; return implode ( self :: $ metricSeparator , array_map ( function ( $ k , $ v ) { return sprintf ( '%1$s%3$s%2$s' , strtoupper ( $ k ) , strtoupper ( $ v ) , self :: $ valueSeparator ) ; } , array_keys... | Build CVSS vector for the given inputs |
18,394 | function Insert ( $ model ) { $ this -> OpenTransaction ( ) ; $ data = clone $ model ; $ table = $ this -> getTableName ( $ data ) ; if ( is_object ( $ data ) ) ModelState :: ModelTreatment ( $ data ) ; $ data = ( array ) $ data ; ksort ( $ data ) ; $ camposNomes = implode ( '`, `' , array_keys ( $ data ) ) ; $ camposV... | Insere dados no banco atraves de uma model mapeada |
18,395 | public function Update ( $ model , array $ campos = null ) { $ this -> OpenTransaction ( ) ; $ data = clone $ model ; if ( is_object ( $ data ) ) ModelState :: ModelTreatment ( $ data ) ; $ primaryKey = ModelState :: GetPrimary ( $ model ) ; if ( $ primaryKey == null ) throw new OwlException ( "Classe nao contem PK" ) ... | Atualiza os dados no banco atraves de uma model mapeada |
18,396 | public function substr ( $ start , $ length = null ) { $ str = mb_substr ( $ this -> value , $ start , $ length ) ; return static :: make ( $ str ) ; } | Get substring from the current string |
18,397 | public function validate ( $ operation , $ model ) { $ model = is_array ( $ model ) ? $ model : $ model -> getAttributes ( ) ; $ rules = $ this -> model -> rules ( $ operation == 'update' ? array_keys ( $ model ) : null , $ operation ) ; $ rules = $ this -> interpolateValidationRules ( $ rules , $ model ) ; $ validator... | Validate model attributes before saving . Throw an exception when validation fails . |
18,398 | protected function interpolateValidationRules ( $ rules , $ model ) { foreach ( $ rules as & $ rule ) { $ attrs = last ( chars_within ( $ rule , [ '{' , '}' ] ) ) ; foreach ( $ attrs as $ attr ) { $ rule = str_replace ( '{' . $ attr . '}' , is_null ( $ model [ $ attr ] ) && $ attr == $ this -> model -> getKeyName ( ) ?... | Interpolate model attribute values on validation rules . |
18,399 | public function getAddress ( $ include_country = false ) { $ string = '' ; if ( $ v = $ this -> getAddressLine1 ( ) ) $ string .= $ v . ', ' ; if ( $ v = $ this -> getAddressLine2 ( ) ) $ string .= $ v . ', ' ; if ( $ v = $ this -> getAddressLine3 ( ) ) $ string .= $ v . ', ' ; $ string .= $ this -> getCityStateZip ( )... | Get address string |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.