idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
17,200 | public function resolveReverseProperty ( Model $ source , $ propName ) { if ( ! is_string ( $ propName ) ) { throw new InvalidOperationException ( 'Property name must be string' ) ; } $ entity = $ this -> getObjectMap ( ) -> resolveEntity ( get_class ( $ source ) ) ; if ( null === $ entity ) { $ msg = 'Source model not... | Resolve possible reverse relation property names . |
17,201 | public function storeCallerPermission ( Caller $ caller , Permission $ permission ) { $ this -> getTable ( ) -> insert ( [ 'caller_type' => $ caller -> getCallerType ( ) , 'caller_id' => $ caller -> getCallerId ( ) , 'type' => $ permission -> getType ( ) , 'action' => $ permission -> getAction ( ) , 'resource_type' => ... | Stores a new permission for a caller |
17,202 | public function removeCallerPermission ( Caller $ caller , Permission $ permission ) { $ query = $ this -> getTable ( ) -> where ( 'caller_type' , $ caller -> getCallerType ( ) ) -> where ( 'caller_id' , $ caller -> getCallerId ( ) ) -> where ( 'type' , $ permission -> getType ( ) ) -> where ( 'action' , $ permission -... | Removes a permission for a caller |
17,203 | public function hasCallerPermission ( Caller $ caller , Permission $ permission ) { $ query = $ this -> getTable ( ) -> where ( 'caller_type' , $ caller -> getCallerType ( ) ) -> where ( 'caller_id' , $ caller -> getCallerId ( ) ) -> where ( 'type' , $ permission -> getType ( ) ) -> where ( 'action' , $ permission -> g... | Checks if a permission is stored for a caller |
17,204 | public function deleteResource ( ResourceSet $ sourceResourceSet , $ sourceEntityInstance ) { $ source = $ this -> unpackSourceEntity ( $ sourceEntityInstance ) ; $ verb = 'delete' ; if ( ! ( $ source instanceof Model ) ) { throw new InvalidArgumentException ( 'Source entity must be an Eloquent model.' ) ; } $ class = ... | Delete resource from a resource set . |
17,205 | public function startTransaction ( $ isBulk = false ) { self :: $ touchList = [ ] ; self :: $ inBatch = true === $ isBulk ; DB :: beginTransaction ( ) ; } | Start database transaction . |
17,206 | public function commitTransaction ( ) { foreach ( self :: $ touchList as $ model ) { $ model -> save ( ) ; } DB :: commit ( ) ; self :: $ touchList = [ ] ; self :: $ inBatch = false ; } | Commit database transaction . |
17,207 | public function writeUrlElement ( QueryResult $ entryObject ) { $ url = new ODataURL ( ) ; if ( null !== $ entryObject -> results ) { $ currentResourceType = $ this -> getCurrentResourceSetWrapper ( ) -> getResourceType ( ) ; $ relativeUri = $ this -> getEntryInstanceKey ( $ entryObject -> results , $ currentResourceTy... | Write top level url element . |
17,208 | public function writeUrlElements ( QueryResult $ entryObjects ) { $ urls = new ODataURLCollection ( ) ; if ( ! empty ( $ entryObjects -> results ) ) { $ i = 0 ; foreach ( $ entryObjects -> results as $ entryObject ) { if ( ! $ entryObject instanceof QueryResult ) { $ query = new QueryResult ( ) ; $ query -> results = $... | Write top level url collection . |
17,209 | public function writeTopLevelComplexObject ( QueryResult & $ complexValue , $ propertyName , ResourceType & $ resourceType ) { $ result = $ complexValue -> results ; $ propertyContent = new ODataPropertyContent ( ) ; $ odataProperty = new ODataProperty ( ) ; $ odataProperty -> name = $ propertyName ; $ odataProperty ->... | Write top level complex resource . |
17,210 | public function writeTopLevelBagObject ( QueryResult & $ BagValue , $ propertyName , ResourceType & $ resourceType ) { $ result = $ BagValue -> results ; $ propertyContent = new ODataPropertyContent ( ) ; $ odataProperty = new ODataProperty ( ) ; $ odataProperty -> name = $ propertyName ; $ odataProperty -> typeName = ... | Write top level bag resource . |
17,211 | public function writeTopLevelPrimitive ( QueryResult & $ primitiveValue , ResourceProperty & $ resourceProperty = null ) { if ( null === $ resourceProperty ) { throw new InvalidOperationException ( 'Resource property must not be null' ) ; } $ propertyContent = new ODataPropertyContent ( ) ; $ odataProperty = new ODataP... | Write top level primitive value . |
17,212 | public function setRequest ( RequestDescription $ request ) { $ this -> request = $ request ; $ this -> stack -> setRequest ( $ request ) ; } | Sets reference to the request submitted by client . |
17,213 | protected function getProjectionNodes ( ) { $ expandedProjectionNode = $ this -> getCurrentExpandedProjectionNode ( ) ; if ( null === $ expandedProjectionNode || $ expandedProjectionNode -> canSelectAllProperties ( ) ) { return null ; } return $ expandedProjectionNode -> getChildNodes ( ) ; } | Gets collection of projection nodes under the current node . |
17,214 | protected function getCurrentExpandedProjectionNode ( ) { if ( null === $ this -> rootNode ) { $ this -> rootNode = $ this -> getRequest ( ) -> getRootProjectionNode ( ) ; } $ expandedProjectionNode = $ this -> rootNode ; if ( null === $ expandedProjectionNode ) { return null ; } else { $ segmentNames = $ this -> getLi... | Find a ExpandedProjectionNode instance in the projection tree which describes the current segment . |
17,215 | protected function shouldExpandSegment ( $ navigationPropertyName ) { $ expandedProjectionNode = $ this -> getCurrentExpandedProjectionNode ( ) ; if ( null === $ expandedProjectionNode ) { return false ; } $ expandedProjectionNode = $ expandedProjectionNode -> findNode ( $ navigationPropertyName ) ; return $ expandedPr... | Check whether to expand a navigation property or not . |
17,216 | protected function getCurrentResourceSetWrapper ( ) { $ segmentWrappers = $ this -> getStack ( ) -> getSegmentWrappers ( ) ; $ count = count ( $ segmentWrappers ) ; return 0 == $ count ? $ this -> getRequest ( ) -> getTargetResourceSetWrapper ( ) : $ segmentWrappers [ $ count - 1 ] ; } | Resource set wrapper for the resource being serialized . |
17,217 | protected function getNextLinkUri ( & $ lastObject ) { $ currentExpandedProjectionNode = $ this -> getCurrentExpandedProjectionNode ( ) ; $ internalOrderByInfo = $ currentExpandedProjectionNode -> getInternalOrderByInfo ( ) ; if ( ! $ internalOrderByInfo instanceof InternalOrderByInfo ) { throw new InvalidOperationExce... | Get next page link from the given entity instance . |
17,218 | public function setService ( IService $ service ) { $ this -> service = $ service ; $ this -> absoluteServiceUri = $ service -> getHost ( ) -> getAbsoluteServiceUri ( ) -> getUrlAsString ( ) ; $ this -> absoluteServiceUriWithSlash = rtrim ( $ this -> absoluteServiceUri , '/' ) . '/' ; } | Gets the data service instance . |
17,219 | public function createBulkResourceforResourceSet ( ResourceSet $ sourceResourceSet , array $ data ) { $ verbName = 'bulkCreate' ; $ mapping = $ this -> getOptionalVerbMapping ( $ sourceResourceSet , $ verbName ) ; $ result = [ ] ; try { DB :: beginTransaction ( ) ; if ( null === $ mapping ) { foreach ( $ data as $ newI... | Create multiple new resources in a resource set . |
17,220 | public function isOk ( ) { if ( null === $ this -> multiplicity ) { return false ; } $ relName = $ this -> relationName ; if ( null === $ relName || ! is_string ( $ relName ) || empty ( $ relName ) ) { return false ; } $ keyField = $ this -> keyField ; if ( null === $ keyField || ! is_string ( $ keyField ) || empty ( $... | Is this AssociationStub sane? |
17,221 | public function compare ( AssociationStubBase $ other ) { $ thisClass = get_class ( $ this ) ; $ otherClass = get_class ( $ other ) ; $ classComp = strcmp ( $ thisClass , $ otherClass ) ; if ( 0 !== $ classComp ) { return $ classComp / abs ( $ classComp ) ; } $ thisBase = $ this -> getBaseType ( ) ; $ otherBase = $ oth... | Supply a canonical sort ordering to determine order in associations . |
17,222 | protected function registerGlide ( ) { $ this -> app -> singleton ( '\League\Glide\Server' , function ( $ app ) { $ fileSystem = $ app -> make ( Filesystem :: class ) ; $ uploadDir = config ( 'laravelimage.uploadDir' ) ; $ source = new LeagueFilesystem ( new Local ( $ uploadDir ) ) ; $ cache = new LeagueFilesystem ( ne... | Register glide . |
17,223 | protected function registerBladeExtensions ( ) { $ blade = $ this -> app [ 'view' ] -> getEngineResolver ( ) -> resolve ( 'blade' ) -> getCompiler ( ) ; $ blade -> directive ( 'laravelImage' , function ( $ options ) { return "<?php echo \\AnkitPokhrel\\LaravelImage\\LaravelImageFacade::image($options);?>" ; } ) ; } | Register blade templates . |
17,224 | public function setUploadFolder ( $ folder ) { $ this -> uploadPath = $ this -> basePath . $ folder . '/' . $ this -> getUniqueFolderName ( ) . '/' ; $ this -> destination = $ this -> publicPath ? public_path ( $ this -> uploadPath ) : $ this -> uploadPath ; } | Set upload folder . |
17,225 | protected function validate ( $ file ) { if ( ! $ file -> isValid ( ) ) { return false ; } $ inputFile = [ $ this -> field => $ file ] ; $ rules = [ $ this -> field => $ this -> validationRules ] ; $ validator = Validator :: make ( $ inputFile , $ rules ) ; if ( $ validator -> fails ( ) ) { $ this -> errors = $ validat... | Perform image validation . |
17,226 | public function upload ( ) { $ file = Input :: file ( $ this -> field ) ; if ( ! $ this -> validate ( $ file ) ) { return false ; } $ originalFileName = $ file -> getClientOriginalName ( ) ; $ encryptedFileName = $ this -> getUniqueFilename ( $ originalFileName ) ; $ mimeType = $ file -> getMimeType ( ) ; $ size = $ fi... | Uploads file to required destination . |
17,227 | public function clean ( $ folder , $ removeDirectory = false ) { if ( ! is_dir ( $ folder ) ) { throw new \ Exception ( ( 'Not a folder.' ) ) ; } array_map ( 'unlink' , glob ( $ folder . DIRECTORY_SEPARATOR . '*' ) ) ; if ( $ removeDirectory && file_exists ( $ folder ) ) { rmdir ( $ folder ) ; } } | Clear out a folder and its content . |
17,228 | public function getUniqueFilename ( $ filename ) { $ uniqueName = uniqid ( ) ; $ fileExt = explode ( '.' , $ filename ) ; $ mimeType = end ( $ fileExt ) ; $ filename = $ uniqueName . '.' . $ mimeType ; return $ filename ; } | function to generate unique filename for images . |
17,229 | protected function makePostRequest ( $ endpoint , array $ params , $ type = 'form_params' ) { try { $ params [ $ type ] = $ params ; $ response = $ this -> _client -> post ( $ endpoint , $ params ) ; $ this -> validateResponse ( $ response -> getStatusCode ( ) ) ; return $ this -> to_json ( $ response ) ; } catch ( Cli... | Util function to make post request |
17,230 | protected function makeGetRequest ( $ endpoint , array $ params ) { try { $ url = self :: API_ENDPOINT . $ endpoint . '?' . http_build_query ( $ params ) ; $ response = $ this -> _client -> get ( $ url ) ; $ this -> validateResponse ( $ response -> getStatusCode ( ) ) ; return $ response ; } catch ( ClientException $ e... | Util function to make get request |
17,231 | protected function validateResponse ( $ statusCode ) { switch ( $ statusCode ) { case 204 : throw new Exceptions \ RateLimitException ( 'Too many requests' ) ; case 403 : throw new Exceptions \ InvalidApiKeyException ( sprintf ( 'Key %s is invalid' , $ this -> _apiKey ) ) ; default : return ; } } | Validate response by looking up the http status code |
17,232 | public function getOptions ( $ method = null ) { if ( $ method === null ) { return $ this -> _options ; } if ( ! array_key_exists ( $ method , $ this -> _options ) ) { $ optionsClass = get_class ( $ this -> client ) . "\\" . ucfirst ( $ method ) ; if ( ! class_exists ( $ optionsClass ) ) { throw new ClassNotFoundExcept... | Get an options object or all of them for current Api class |
17,233 | public function setOptionsObject ( $ method , $ args ) { $ class = get_class ( $ this -> client ) . "\\" . ucfirst ( $ method ) ; if ( ! is_array ( $ args [ 0 ] ) || count ( $ args [ 0 ] ) === 0 ) { return new $ class ; } $ optionClass = new $ class ; foreach ( $ args [ 0 ] as $ key => $ val ) { $ setterMethod = str_re... | Sets the given options object and stores it |
17,234 | public function authenticate ( ) { if ( ! isset ( $ this -> account_id ) ) { $ accounts = $ this -> authentication -> login ( ) ; $ allAccounts = $ accounts -> getLoginAccounts ( ) ; $ account = $ allAccounts [ 0 ] ; $ this -> account_id = $ account -> getAccountId ( ) ; } $ this -> authenticated = true ; return $ this... | Authenticates api client and stores account_id |
17,235 | private function get_list_or_item ( $ data , $ field , $ i = null , $ default = '' ) { $ i = ( $ i === false || count ( $ this -> article_ids ) > 1 ) ? $ i : 0 ; if ( $ i === null || $ i === false ) { $ result = [ ] ; foreach ( $ data as $ page_id => $ item ) { $ result [ $ page_id ] = isset ( $ item [ $ field ] ) ? $ ... | Get list of articles or items |
17,236 | public function setLanguage ( $ language ) { $ language = $ language ? : $ this -> language ; if ( ! in_array ( $ language , $ this -> getSupportedLanguages ( ) ) ) { throw new LanguageNotSupportedException ( sprintf ( 'Language [%s] is not supported' , $ language ) ) ; } $ this -> language = $ language ; $ this -> cha... | Set the language the api should use |
17,237 | public function setEngine ( $ engine ) { if ( ! in_array ( $ engine , $ this -> getSupportedEngines ( ) ) ) { throw new EngineNotSupportedException ( sprintf ( 'Engine [%s] is not supported' , $ engine ) ) ; } $ this -> engine = $ engine ; $ this -> changeBaseApi ( ) ; } | Set Engine to use whethere wikipedia or wikiquote |
17,238 | protected function changeBaseApi ( ) { $ domain = $ this -> language . '.' . $ this -> engine_supported [ $ this -> engine ] ; $ this -> base_api = sprintf ( 'http://%s/w/api.php?format=json&rawcontinue=1&' , $ domain ) ; } | Change the base api to fetch quotes from |
17,239 | public function getNewRandomArticle ( $ number = 1 ) { $ wiki_api = $ this -> base_api . 'action=query&list=random&rnnamespace=0&rnlimit=' . $ number ; $ json_wapi = json_decode ( file_get_contents ( $ wiki_api ) , true ) ; $ this -> article_ids = [ ] ; foreach ( $ json_wapi [ 'query' ] [ 'random' ] as $ item ) { $ thi... | Get a new random article |
17,240 | public function getFirstSentence ( $ number = 1 , $ i = null ) { $ wiki_api = sprintf ( $ this -> base_api . 'action=query&prop=extracts&exsentences=%d&explaintext=&exsectionformat=plain&pageids=%s' , intval ( $ number ) , $ this -> getId ( ) ) ; $ json_wapi = json_decode ( file_get_contents ( $ wiki_api ) , true ) ; r... | Get the first sentence of the article |
17,241 | public function getCategoriesRelated ( $ i = null ) { $ wiki_api = $ this -> base_api . 'action=query&prop=categories&pageids=' . $ this -> getId ( ) ; $ json_wapi = json_decode ( file_get_contents ( $ wiki_api ) , true ) ; $ result = $ this -> get_list_or_item ( $ json_wapi [ 'query' ] [ 'pages' ] , 'categories' , fal... | Get related categories for the articles |
17,242 | public function getArticleImages ( $ i = null , $ image_min_size = 0 ) { $ result = [ ] ; $ i = count ( $ this -> article_ids ) > 1 ? $ i : 0 ; $ article_ids = ( $ i === null ) ? $ this -> article_ids : [ $ this -> article_ids [ $ i ] ] ; foreach ( $ article_ids as $ page_id ) { $ result [ $ page_id ] = [ ] ; $ wiki_ap... | Get Images of the Articles |
17,243 | public function getOtherLangLinks ( $ i = null ) { $ wiki_api = $ this -> base_api . 'action=query&prop=langlinks&llprop=url&pageids=' . $ this -> getId ( ) ; $ json_wapi = json_decode ( file_get_contents ( $ wiki_api ) , true ) ; return $ this -> get_list_or_item ( $ json_wapi [ 'query' ] [ 'pages' ] , 'langlinks' , $... | Get other language links |
17,244 | public function getBulkData ( $ limit = 1 , $ sentences = 5 , $ chars = 200 , $ with_images = false , $ image_min_size = 102400 ) { $ wiki_api = $ this -> base_api . 'action=query&generator=random&grnnamespace=0&grnlimit=' . $ limit . '&prop=info|extracts&inprop=url&explaintext=&exsectionformat=plain' ; if ( $ sentence... | Get Bulk Data |
17,245 | protected function createServer ( $ endpoint , $ config = [ ] ) { if ( stripos ( $ endpoint , 'unix://' ) !== false ) { if ( $ endpoint [ 7 ] === DIRECTORY_SEPARATOR ) { $ path = substr ( $ endpoint , 7 ) ; } else { $ path = getcwd ( ) . DIRECTORY_SEPARATOR . substr ( $ endpoint , 7 ) ; $ endpoint = 'unix://' . $ path ... | Create the server resource . |
17,246 | public function handleConnect ( ) { $ socket = @ stream_socket_accept ( $ this -> socket ) ; if ( $ socket === false ) { $ this -> emit ( 'error' , [ $ this , new ReadException ( 'Socket could not accept new connection.' ) ] ) ; return ; } $ client = null ; $ ex = null ; try { $ client = $ this -> createClient ( $ sock... | Handle the new connection . |
17,247 | public function handleClose ( ) { $ this -> pause ( ) ; if ( is_resource ( $ this -> socket ) ) { if ( $ this -> getStreamType ( ) === Socket :: TYPE_UNIX ) { $ path = substr ( $ this -> parseEndpoint ( ) , 7 ) ; unlink ( $ path ) ; } fclose ( $ this -> socket ) ; } } | Handle closing event . |
17,248 | private function configure ( $ config = [ ] ) { $ this -> config = $ config ; $ this -> configureVariable ( 'ssl' ) ; $ this -> configureVariable ( 'ssl_method' ) ; $ this -> configureVariable ( 'ssl_name' ) ; $ this -> configureVariable ( 'ssl_verify_sign' ) ; $ this -> configureVariable ( 'ssl_verify_peer' ) ; $ this... | Configure socket . |
17,249 | private function configureVariable ( $ configKey ) { $ configStaticKey = 'CONFIG_DEFAULT_' . strtoupper ( $ configKey ) ; $ this -> config [ $ configKey ] = isset ( $ this -> config [ $ configKey ] ) ? $ this -> config [ $ configKey ] : constant ( "static::$configStaticKey" ) ; } | Configure static key |
17,250 | public function findFacetById ( $ id ) { if ( is_null ( $ this -> personality ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'trait_id' , $ id , $ this -> personality ) ; } | Get a Facet using Id . |
17,251 | public function findFacetByName ( $ name ) { if ( is_null ( $ this -> personality ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'name' , $ name , $ this -> personality ) ; } | Get a Facet using Name . |
17,252 | public function hasFacet ( $ facet ) { return ! is_null ( $ this -> findFacetByName ( $ facet ) ) || ! is_null ( $ this -> findFacetById ( $ facet ) ) ; } | Checks if the Profile has the Facet given . |
17,253 | public function findNeedById ( $ id ) { if ( is_null ( $ this -> needs ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'trait_id' , $ id , $ this -> needs ) ; } | Get a Need using Id . |
17,254 | public function findNeedByName ( $ name ) { if ( is_null ( $ this -> needs ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'name' , $ name , $ this -> needs ) ; } | Get a Need using its name . |
17,255 | public function hasNeed ( $ need ) { return ! is_null ( $ this -> findNeedByName ( $ need ) ) || ! is_null ( $ this -> findNeedById ( $ need ) ) ; } | Checks if Profile has given need . |
17,256 | public function findValueById ( $ id ) { if ( is_null ( $ this -> values ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'trait_id' , $ id , $ this -> values ) ; } | Get a Value using Id . |
17,257 | public function findValueByName ( $ name ) { if ( is_null ( $ this -> values ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'name' , $ name , $ this -> values ) ; } | Get a Value using its name . |
17,258 | public function hasValue ( $ value ) { return ! is_null ( $ this -> findValueByName ( $ value ) ) || ! is_null ( $ this -> findValueById ( $ value ) ) ; } | Checks if Profile has given value . |
17,259 | public function findBehaviorsFor ( $ times ) { if ( is_null ( $ this -> behavior ) ) { return null ; } $ times = ! is_array ( $ times ) ? [ $ times ] : $ times ; $ behaviors = $ this -> behavior -> reject ( function ( BehaviorNode $ behavior ) use ( $ times ) { return ! in_array ( $ behavior -> name , $ times ) ; } ) ;... | Find Behaviors a give times or Days . |
17,260 | public function findConsumptionPreferenceCategoryById ( $ preference ) { if ( is_null ( $ this -> consumption_preferences ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'consumption_preference_category_id' , $ preference , $ this -> consumption_preferences ) ; } | Get a ConsumptionPreferencesCategory using Id . |
17,261 | public function findConsumptionPreferenceCategoryName ( $ preference ) { if ( is_null ( $ this -> consumption_preferences ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'name' , $ preference , $ this -> consumption_preferences ) ; } | Get a ConsumptionPreferencesCategory using its name . |
17,262 | public function hasConsumptionPreferenceCategory ( $ preference ) { return ! is_null ( $ this -> findConsumptionPreferenceCategoryName ( $ preference ) ) || ! is_null ( $ this -> findConsumptionPreferenceCategoryById ( $ preference ) ) ; } | Checks if ConsumptionPreferencesCategory exists on profile . |
17,263 | public function findConsumptionPreference ( $ preferenceId ) { if ( is_null ( $ this -> consumption_preferences ) ) { return null ; } return $ this -> traverseNodesAndFindBy ( 'consumption_preference_id' , $ preferenceId , $ this -> consumption_preferences ) ; } | Find ConsumptionPreferencesNode by Id . |
17,264 | public function setCredentialsName ( $ credentialsName = null ) { if ( is_null ( $ credentialsName ) ) { $ credentialsName = config ( 'personality-insights.default_credentials' ) ; } if ( ! config ( ) -> has ( 'personality-insights.credentials.' . $ credentialsName ) ) { throw new InvalidCredentialsName ; } $ this -> c... | Sets the Credentials name . |
17,265 | public function setCredentials ( $ name = null ) { if ( is_null ( $ name ) ) { $ name = config ( 'personality-insights.default_credentials' ) ; } if ( ! config ( ) -> has ( 'personality-insights.credentials.' . $ name ) ) { throw new InvalidCredentialsName ; } $ this -> credentials = config ( 'personality-insights.cred... | Sets the Credentials we will use to perform requests . |
17,266 | public function setApiVersion ( $ apiVersion = null ) { if ( is_null ( $ apiVersion ) ) { $ apiVersion = config ( 'personality-insights.api_version' ) ? : 'v3' ; } $ this -> apiVersion = $ apiVersion ; return $ this ; } | Sets ths API version we are using . |
17,267 | public function calculatePercentage ( $ decimal = 1 ) { if ( is_null ( $ this -> percentile ) ) { return null ; } return ( float ) number_format ( $ this -> percentile * 100 , $ decimal , '.' , '' ) ; } | Calculate the percentage for this node . |
17,268 | protected function createClient ( $ endpoint , $ config = [ ] ) { $ ssl = $ this -> config [ 'ssl' ] ; $ name = $ this -> config [ 'ssl_name' ] ; $ verifySign = $ this -> config [ 'ssl_verify_sign' ] ; $ verifyPeer = $ this -> config [ 'ssl_verify_peer' ] ; $ verifyDepth = $ this -> config [ 'ssl_verify_depth' ] ; $ co... | Create the client resource . |
17,269 | public function handleEncrypt ( ) { $ ex = null ; try { if ( $ this -> isEncrypted ( ) ) { return ; } $ this -> encrypt ( $ this -> config [ 'ssl_method' ] ) ; if ( $ this -> isEncrypted ( ) ) { $ this -> pause ( ) ; $ this -> resume ( ) ; } } catch ( Error $ ex ) { } catch ( Exception $ ex ) { } if ( $ ex !== null ) {... | Handle socket encryption . |
17,270 | private function selectCryptoType ( $ version ) { switch ( $ version ) { case STREAM_CRYPTO_METHOD_SSLv3_SERVER : case STREAM_CRYPTO_METHOD_TLSv1_0_SERVER : case STREAM_CRYPTO_METHOD_TLSv1_1_SERVER : case STREAM_CRYPTO_METHOD_TLSv1_2_SERVER : return self :: CRYPTO_TYPE_SERVER ; case STREAM_CRYPTO_METHOD_SSLv3_CLIENT : ... | Checks type of crypto . |
17,271 | public function getProfileFromWatson ( ) { if ( $ this -> cacheIsOn ( ) && $ this -> cache -> has ( $ this -> getContainer ( ) -> getCacheKey ( ) ) ) { return $ this -> cache -> get ( $ this -> getContainer ( ) -> getCacheKey ( ) ) ; } $ response = $ this -> sendRequest ( ) ; $ profile = $ this -> jsonMapper -> map ( j... | Get Full Insights From Watson API . |
17,272 | public function clean ( ) { $ this -> profile = null ; $ this -> credentialsName = null ; $ this -> newUpContainer ( ) ; $ this -> cleanHeaders ( ) ; $ this -> cleanQuery ( ) ; return $ this ; } | Cleans the object by erasing all profile and content info . |
17,273 | protected function registerBindings ( ) { $ this -> app -> bind ( InsightsContract :: class , PersonalityInsights :: class ) ; $ this -> app -> bind ( PersonalityInsights :: SERVICE_ID , PersonalityInsights :: class ) ; $ this -> registerAccessManager ( ) ; $ this -> registerBridge ( ) ; $ this -> app -> bind ( Content... | Registers all Interface to Class bindings . |
17,274 | protected function registerAccessManager ( ) { $ this -> app -> singleton ( AccessManager :: SERVICE_ID , function ( Application $ app ) { $ configRepo = $ app -> make ( 'config' ) ; return new AccessManager ( $ configRepo -> get ( 'personality-insights.default_credentials' ) , $ configRepo -> get ( 'personality-insigh... | Registers the Access Manager in the Container . |
17,275 | protected function registerBridge ( ) { $ this -> app -> bind ( 'PIBridge' , function ( Application $ app ) { $ credentials = $ app -> make ( AccessManager :: SERVICE_ID ) -> getCredentials ( ) ; return new Bridge ( $ credentials [ 'username' ] , $ credentials [ 'password' ] , $ credentials [ 'url' ] ) ; } ) ; } | Registers the Bridge . |
17,276 | protected function registerFacades ( ) { if ( $ this -> app -> version ( ) >= 5.0 && $ this -> app -> version ( ) < 5.4 ) { $ this -> app -> booting ( function ( ) { AliasLoader :: getInstance ( ) -> alias ( PersonalityInsights :: SERVICE_ID , PersonalityInsightsFacade :: class ) ; } ) ; } } | Registers all facades . |
17,277 | public function usingCredentials ( $ name = null ) { $ this -> getAccessManager ( ) -> setCredentialsName ( $ name ) -> setCredentials ( $ name ) ; return $ this ; } | Specify the credentials name to use . |
17,278 | protected function getQuery ( ) { $ finalQueryString = '' ; foreach ( $ this -> query as $ key => $ value ) { $ finalQueryString .= $ key . '=' . $ value . '&' ; } if ( ! empty ( $ finalQueryString ) ) { $ finalQueryString = rtrim ( $ finalQueryString , '&' ) ; } return $ finalQueryString ; } | Get Query to pass additionally to the request . |
17,279 | protected function sendRequest ( ) { $ accessManager = $ this -> getAccessManager ( ) ; $ watsonBridge = $ this -> makeBridge ( ) ; $ postUrl = $ accessManager -> getProfileResourcePath ( ) ; if ( ! empty ( $ this -> getQuery ( ) ) ) { $ postUrl .= '?' . $ this -> getQuery ( ) ; } return $ watsonBridge -> post ( $ post... | Send API Request to Watson and get Response . |
17,280 | public function appendHeaders ( array $ headers = [ ] ) { $ this -> headers = collect ( $ this -> headers ) -> merge ( $ headers ) -> all ( ) ; return $ this ; } | Append Headers to request . |
17,281 | public function withQuery ( array $ query = [ ] ) { $ this -> query = collect ( $ this -> query ) -> merge ( $ query ) -> all ( ) ; return $ this ; } | Add Query to the Request . |
17,282 | public function addSingleContentItem ( $ items = [ ] ) { $ this -> contentListContainer -> push ( $ items instanceof ContentItem ? $ items : personality_insights_content_item ( $ items ) ) ; return $ this ; } | Add a ContentItem to ContentListContainer . |
17,283 | public function addContentItems ( $ items = [ ] ) { collect ( $ items ) -> each ( function ( $ item ) { $ this -> addSingleContentItem ( $ item ) ; } ) ; return $ this ; } | Add ContentItems to the Container . |
17,284 | public function traverseNodesAndFindBy ( $ propName , $ propValue , Collection $ nodes = null ) { if ( is_null ( $ nodes ) ) { return null ; } foreach ( $ nodes as $ node ) { if ( $ node -> { $ propName } == $ propValue ) { return $ node ; } if ( $ node -> hasChildren ( ) ) { $ node = $ this -> traverseNodesAndFindBy (... | Traverse Collection of Nodes and return specific Node if criteria matches . |
17,285 | public function getCacheKey ( ) { return 'PersonalityInsights-' . Uuid :: uuid5 ( Uuid :: NAMESPACE_DNS , collect ( [ 'contentItems' => $ this -> toArray ( ) ] ) -> toJson ( ) ) -> toString ( ) ; } | Unique cache key for this Container . |
17,286 | public static function load ( $ path = '' , $ file = '.env' , $ overload = false ) { if ( empty ( $ path ) ) { if ( class_exists ( 'Yii' , false ) ) { if ( Yii :: getAlias ( '@vendor' , false ) ) { $ vendorDir = Yii :: getAlias ( '@vendor' ) ; $ path = dirname ( $ vendorDir ) ; } elseif ( Yii :: getAlias ( '@app' , fal... | Load . env file from Yii2 project root directory . |
17,287 | public static function getTemplate ( $ template , $ format = 'html5' ) { $ templates = static :: getTemplates ( $ template , $ format = 'html5' ) ; return isset ( $ templates [ 0 ] ) ? $ templates [ 0 ] : null ; } | Get the template path |
17,288 | public static function getTemplates ( $ template , $ format = 'html5' ) { $ templates = array ( ) ; try { $ theme = \ ThemeModel :: findAll ( array ( 'order' => 'name' ) ) ; } catch ( \ Exception $ e ) { $ theme = null ; } while ( $ theme && $ theme -> next ( ) ) { if ( $ theme -> templates != '' ) { if ( file_exists (... | Get all found template paths |
17,289 | public function generate ( ) { $ this -> strTemplate = $ this -> customTpl ? : $ this -> type ; if ( ( $ output = $ this -> rsceGetBackendOutput ( ) ) !== null ) { return $ output ; } try { return parent :: generate ( ) ; } catch ( \ Exception $ exception ) { if ( TL_MODE === 'BE' ) { $ template = new CustomTemplate ( ... | Find the correct template and parse it |
17,290 | public function rsceGetBackendOutput ( ) { if ( TL_MODE !== 'BE' ) { return null ; } $ config = CustomElements :: getConfigByType ( $ this -> type ) ? : array ( ) ; if ( ! empty ( $ config [ 'isNewsletter' ] ) ) { if ( \ Input :: get ( 'do' ) === 'newsletter' ) { return null ; } foreach ( debug_backtrace ( DEBUG_BACKTR... | Generate backend output if TL_MODE is set to BE |
17,291 | public function compile ( ) { if ( $ this -> addImage && trim ( $ this -> singleSRC ) ) { $ fileModel = \ FilesModel :: findByUuid ( $ this -> singleSRC ) ; if ( $ fileModel !== null && is_file ( TL_ROOT . '/' . $ fileModel -> path ) ) { $ this -> singleSRC = $ fileModel -> path ; $ this -> addImageToTemplate ( $ this ... | Parse the json data and pass it to the template |
17,292 | protected function deserializeDataRecursive ( $ data ) { foreach ( $ data as $ key => $ value ) { if ( is_string ( $ value ) && trim ( $ value ) ) { if ( is_object ( $ data ) ) { $ data -> $ key = \ StringUtil :: deserialize ( $ value ) ; } else { $ data [ $ key ] = \ StringUtil :: deserialize ( $ value ) ; } } else if... | Deserialize all data recursively |
17,293 | public function getColumnClassName ( $ index ) { if ( ! class_exists ( ColumnsStart :: class ) ) { return '' ; } $ config = ColumnsStart :: getColumnsConfiguration ( $ this -> arrData ) ; $ classes = array ( 'rs-column' ) ; foreach ( $ config as $ name => $ media ) { $ classes = array_merge ( $ classes , $ media [ $ in... | Get the column class name for the specified index |
17,294 | public function onloadCallback ( $ dc ) { if ( \ Input :: get ( 'act' ) === 'create' ) { return ; } if ( \ Input :: get ( 'act' ) === 'edit' ) { $ this -> reloadConfig ( ) ; } if ( $ dc -> table === 'tl_content' && class_exists ( 'CeAccess' ) ) { $ ceAccess = new \ CeAccess ; $ ceAccess -> filterContentElements ( $ dc ... | tl_content tl_module and tl_form_field DCA onload callback |
17,295 | public function onsubmitCallback ( $ dc ) { $ type = $ this -> getDcaFieldValue ( $ dc , 'type' ) ; if ( ! $ type || substr ( $ type , 0 , 5 ) !== 'rsce_' ) { return ; } $ data = $ this -> getDcaFieldValue ( $ dc , 'rsce_data' , true ) ; if ( $ data === null && ! count ( $ this -> saveData ) ) { $ data = $ this -> save... | tl_content tl_module and tl_form_field DCA onsubmit callback |
17,296 | public function loadCallback ( $ value , $ dc ) { if ( $ value !== null ) { return $ value ; } $ value = $ this -> getNestedValue ( $ dc -> field ) ; if ( $ value === null && isset ( $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ $ dc -> field ] [ 'default' ] ) ) { $ value = $ GLOBALS [ 'TL_DCA' ] [ $ dc -> ta... | Field load callback |
17,297 | public function loadCallbackMultiEdit ( $ value , $ dc ) { if ( $ value !== null ) { return $ value ; } $ field = substr ( $ dc -> field , strlen ( $ dc -> activeRecord -> type . '_field_' ) ) ; $ data = \ Database :: getInstance ( ) -> prepare ( "SELECT rsce_data FROM {$dc->table} WHERE id=?" ) -> execute ( $ dc -> id... | Field load callback multi edit |
17,298 | protected function getNestedConfig ( $ field , $ config ) { $ field = preg_split ( '(__([0-9]+)__)' , substr ( $ field , 11 ) , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; if ( ! isset ( $ config [ $ field [ 0 ] ] ) ) { return null ; } $ fieldConfig = & $ config [ $ field [ 0 ] ] ; for ( $ i = 0 ; isset ( $ field [ $ i ] ) ; $ ... | Get the config from field name |
17,299 | public function saveCallback ( $ value , $ dc ) { if ( strpos ( $ dc -> field , '__rsce_dummy__' ) !== false ) { return ; } if ( $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ $ dc -> field ] [ 'inputType' ] === 'fileTree' || $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ $ dc -> field ] [ 'inputType'... | Field save callback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.