idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
9,500 | public function getThemeBootstrapVersion ( $ themeName = null ) { if ( null === $ themeName ) { if ( null !== $ this -> bootstrapVersion ) { return $ this -> bootstrapVersion ; } $ themeName = $ this -> getActiveThemeBackend ( ) -> getThemeName ( ) ; } $ this -> bootstrapVersion = $ this -> container -> getParameter ( ... | Returns the Twitter Bootstrap version for the theme requested as argument |
9,501 | protected function checkTargetFolders ( array $ options ) { $ this -> fileSystem -> mkdir ( $ options [ "assetsDir" ] ) ; $ this -> fileSystem -> mkdir ( $ options [ "configDir" ] ) ; $ this -> fileSystem -> mkdir ( $ options [ "deployDir" ] ) ; } | Checks if mandatory folders to publish websites exist and creates them when required |
9,502 | protected function savePages ( Theme $ theme , array $ options ) { $ pages = $ this -> pageTreeCollection -> getPages ( ) ; $ basePages = $ this -> pageTreeCollection -> getBasePages ( ) ; $ options [ "type" ] = "Pages" ; if ( ! $ this -> doSavePages ( $ pages , $ theme , $ options ) ) { return false ; } $ options [ "t... | Saves the pages instantiating an PageTreeCollection object |
9,503 | public static function compare ( $ left , $ right ) { if ( self :: isContainer ( $ left ) && self :: isContainer ( $ right ) ) { $ leftFields = self :: normalize ( $ left ) ; $ rightFields = self :: normalize ( $ right ) ; if ( count ( $ leftFields ) !== count ( $ rightFields ) ) { return false ; } foreach ( $ leftFiel... | Compares whether two values are equals . Uses the comparsion rules described in the JSON patch RFC . Basically that means that the order of elements in objects does not matter |
9,504 | public function resolve ( array $ parameters ) : array { if ( ! $ number = $ this -> reflection -> getNumberOfParameters ( ) ) { return [ ] ; } $ arguments = \ array_fill ( 0 , $ number , null ) ; foreach ( $ this -> getParameters ( ) as $ pos => $ parameter ) { $ result = $ this -> match ( $ parameter , $ parameters )... | Resolves function arguments . |
9,505 | public function onBeforeDeletePageCommit ( BeforeDeletePageCommitEvent $ event ) { if ( $ event -> isAborted ( ) ) { return ; } $ pageManager = $ event -> getContentManager ( ) ; $ pageRepository = $ pageManager -> getPageRepository ( ) ; try { $ languages = $ this -> languageRepository -> activeLanguages ( ) ; if ( co... | Deletes the page s seo attributes for all the languages of the site |
9,506 | public function ajaxChoiceListAction ( Request $ request , $ type ) { return AjaxChoiceListHelper :: generateResponse ( $ request , $ this -> get ( 'form.factory' ) -> createBuilder ( $ type , null , [ 'select2' => [ 'enabled' => true , 'ajax' => true ] ] ) ) ; } | Gets the ajax response of choice list . |
9,507 | public function remove ( $ idBlock , BlockManagersCollection $ blockManagersCollection ) { $ blockManagerInfo = $ blockManagersCollection -> getManagerInfoByBlockId ( $ idBlock ) ; $ blockManager = $ blockManagerInfo [ 'manager' ] ; if ( null === $ blockManager ) { return null ; } try { $ this -> blockRepository -> sta... | Removes the block manager that handles the given block id |
9,508 | public function clear ( BlockManagersCollection $ blockManagersCollection ) { if ( $ blockManagersCollection -> count ( ) == 0 ) { return null ; } try { $ result = null ; $ this -> blockRepository -> startTransaction ( ) ; $ blockManagers = $ blockManagersCollection -> getBlockManagers ( ) ; foreach ( $ blockManagers a... | Deletes all the blocks managed by the slot |
9,509 | public static function localFilename ( StreamInterface $ stream ) { self :: register ( ) ; $ uri = 'spiral://' . spl_object_hash ( $ stream ) ; self :: $ uris [ $ uri ] = $ stream ; return $ uri ; } | Register StreamInterface and get unique url for it . |
9,510 | public static function getResource ( StreamInterface $ stream ) { $ mode = null ; if ( $ stream -> isReadable ( ) ) { $ mode = 'r' ; } if ( $ stream -> isWritable ( ) ) { $ mode = ! empty ( $ mode ) ? 'r+' : 'w' ; } if ( empty ( $ mode ) ) { throw new WrapperException ( "Stream is not available in read or write modes" ... | Create StreamInterface associated resource . |
9,511 | public static function releaseUri ( $ uri ) { if ( $ uri instanceof StreamInterface ) { $ uri = 'spiral://' . spl_object_hash ( $ uri ) ; } unset ( self :: $ uris [ $ uri ] ) ; } | Free uri dedicated to specified StreamInterface . Method is useful for long living applications . |
9,512 | public function availableIncludeKeys ( ) : array { $ availableKeys = [ ] ; if ( ( $ transformer = $ this -> transformer ( ) ) !== null && ( $ transformer instanceof TransformerInterface ) ) { $ availableKeys = $ transformer -> getAvailableIncludes ( ) ; } return $ availableKeys ; } | List of array keys identifying the available includes for this resource . |
9,513 | public function resolvedRelationshipKeys ( ) : array { $ includeMap = $ this -> includeMap ( ) ; $ keys = [ ] ; foreach ( $ this -> resolvedIncludeKeys ( ) as $ includeKey ) { $ relations = $ includeMap [ $ includeKey ] [ 'relation' ] ?? [ ] ; if ( \ count ( $ relations ) > 0 ) { array_push ( $ keys , ... $ relations )... | Get a list of relationship keys for all of the includes which have been resolved . |
9,514 | public function filterData ( array $ data ) { $ filterProps = $ this -> filterProps ( ) ; if ( ! empty ( $ filterProps ) ) { $ filteredData = array_filter ( $ data , function ( $ key ) use ( $ filterProps ) { return \ in_array ( $ key , $ filterProps , true ) ; } , ARRAY_FILTER_USE_KEY ) ; if ( ! empty ( $ filteredData... | Apply the scope s sparse field - set to the given data . |
9,515 | public static function parse ( string $ type ) : self { static $ parser = null ; if ( null === $ parser ) { $ parser = new Parser ( ) ; } return $ parser -> parse ( $ type ) ; } | Parse a type string and return a Type instance . |
9,516 | public static function from ( $ object ) : self { if ( $ object instanceof self ) { return $ object ; } if ( \ is_object ( $ object ) ) { $ object = \ get_class ( $ object ) ; } if ( ! \ is_string ( $ object ) ) { throw new InvalidArgumentException ( 'Cannot create a type from ' . \ gettype ( $ object ) ) ; } return ne... | Create a new Type from an object or a class string . |
9,517 | public function getCommentsForPostvote ( $ postvote ) { $ postvoteCommentMapper = $ this -> getPostVoteCommentMapper ( ) ; $ comments = $ postvoteCommentMapper -> findBy ( array ( 'postvote' => $ postvote ) , array ( 'createdAt' => 'DESC' ) ) ; return $ comments ; } | Get all comments for this game |
9,518 | private function initUserData ( ) { $ this -> user_data [ $ this -> cache_key ] = ( object ) [ 'continent' => new \ StdClass ( ) , 'country' => new \ StdClass ( ) , 'state' => new \ StdClass ( ) , 'city' => new \ StdClass ( ) , 'geolocation' => new \ StdClass ( ) , ] ; } | Init empty Object of user data |
9,519 | private function debugData ( ) { $ state = new \ stdClass ; $ state -> names = isset ( $ _REQUEST [ 'geot_state' ] ) ? [ filter_var ( $ _REQUEST [ 'geot_state' ] , FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ] : '' ; $ state -> iso_code = isset ( $ _REQUEST [ 'geot_state_code' ] ) ? filter_var ( $ _REQUEST [ 'geot_state_code'... | Return debug data set in query vars |
9,520 | public function setData ( $ key , $ property , $ value ) { $ this -> user_data [ $ this -> cache_key ] -> $ key -> $ property = $ value ; $ this -> user_data [ $ this -> cache_key ] = new GeotRecord ( $ this -> user_data [ $ this -> cache_key ] ) ; return $ this -> user_data [ $ this -> cache_key ] ; } | Add new values or update in user data |
9,521 | public function get ( $ key ) { if ( ! in_array ( $ key , GeotRecord :: getValidRecords ( ) ) ) { return 'Invalid GeotRecord classname provided. Valids ones are: ' . implode ( ',' , GeotRecord :: getValidRecords ( ) ) ; } if ( $ this -> user_data [ $ this -> cache_key ] === null ) { $ this -> getUserData ( ) ; } if ( i... | Get a specif record |
9,522 | private function getCountryByIsoCode ( $ iso_code ) { global $ wpdb ; $ query = "SELECT * FROM {$wpdb->base_prefix}geot_countries WHERE iso_code = %s" ; $ result = $ wpdb -> get_row ( $ wpdb -> prepare ( $ query , array ( $ iso_code ) ) , ARRAY_A ) ; $ country = new \ StdClass ( ) ; $ country -> names = new \ StdClass ... | Get country from database and return object like api |
9,523 | private function getFallbackCountry ( ) { if ( empty ( $ this -> opts [ 'fallback_country' ] ) ) { $ this -> opts [ 'fallback_country' ] = 'US' ; } $ record = ( object ) [ 'continent' => new \ StdClass ( ) , 'country' => new \ StdClass ( ) , 'state' => new \ StdClass ( ) , 'city' => new \ StdClass ( ) , 'geolocation' =... | If we have an exception return |
9,524 | public function createRocketCookies ( ) { if ( apply_filters ( 'geot/disable_cookies' , false ) ) { return ; } if ( ! $ this -> user_data [ $ this -> cache_key ] instanceof GeotRecord ) { return ; } $ country = isset ( $ this -> user_data [ $ this -> cache_key ] -> country -> iso_code ) ? $ this -> user_data [ $ this -... | Create cookies so WPRocket plugin can generate different page caches |
9,525 | private function set_defaults ( ) { $ args = geot_settings ( ) ; $ this -> opts = wp_parse_args ( $ args , [ 'license' => '' , 'debug_mode' => false , 'cache_mode' => false , 'bots_country' => '' , 'api_secret' => '' , 'cookie_name' => 'geot_country' , 'maxmind' => 0 , 'maxmind_db' => maxmind_db ( ) , 'ip2location' => ... | Set some default options for the class |
9,526 | private function check_active_user ( ) { if ( ( ! isset ( $ this -> opts [ 'wpengine' ] ) || $ this -> opts [ 'wpengine' ] != '1' || getenv ( 'HTTP_GEOIP_COUNTRY_CODE' ) === false ) && ( ! isset ( $ this -> opts [ 'maxmind' ] ) || $ this -> opts [ 'maxmind' ] != '1' || ! file_exists ( maxmind_db ( ) ) ) && ( ! isset ( ... | Check if user has active subscription |
9,527 | private function targetZip ( $ places , $ exclude_places ) { $ target = false ; $ user_place = $ this -> get ( 'city' ) ; if ( ! $ user_place ) { return apply_filters ( 'geot/target_zip/return_on_user_null' , false ) ; } if ( count ( $ places ) > 0 ) { foreach ( $ places as $ zip ) { if ( strtolower ( $ user_place -> z... | Target by ZIP |
9,528 | private function cleanResponse ( $ response ) { if ( $ this -> opts [ 'cache_mode' ] ) { $ this -> session -> set ( 'geot_data' , $ response ) ; } $ this -> user_data [ $ this -> cache_key ] = new GeotRecord ( $ response ) ; return $ this -> user_data [ $ this -> cache_key ] ; } | Save user data save to session and create record and create GeotRecord class |
9,529 | private function maxmind ( ) { $ reader = new Reader ( $ this -> opts [ 'maxmind_db' ] ) ; try { $ record = $ reader -> get ( $ this -> ip ) ; if ( empty ( $ record ) ) { throw new AddressNotFoundException ( 'Ip Address not found' ) ; } $ reader -> close ( ) ; return $ this -> cleanResponse ( RecordConverter :: maxmind... | Use maxmind local db |
9,530 | private function ip2location ( ) { $ db = new Database ( $ this -> opts [ 'ip2location_db' ] , $ this -> opts [ 'ip2location_method' ] ) ; try { $ record = $ db -> lookup ( $ this -> ip , Database :: ALL ) ; return $ this -> cleanResponse ( RecordConverter :: ip2locationRecord ( $ record ) ) ; } catch ( \ Exception $ e... | Use ip2location database |
9,531 | private function checkLocale ( $ force_locale = null ) { if ( ! $ this -> user_data [ $ this -> cache_key ] instanceof GeotRecord || apply_filters ( 'geot/cancel_locale_check' , false ) ) { return ; } $ locale = get_locale ( ) ; $ wp_locale = strstr ( $ locale , '_' ) === false ? $ locale : strstr ( get_locale ( ) , '_... | For API results we can let users change locale but also we can check against wordpress locale |
9,532 | private function treatAsBot ( ) { $ ret = false ; $ script = isset ( $ _SERVER [ 'PHP_SELF' ] ) ? basename ( $ _SERVER [ 'PHP_SELF' ] ) : '' ; if ( in_array ( $ script , array ( 'wp-login.php' , 'xmlrpc.php' , 'wp-cron.php' ) ) ) { $ ret = true ; } if ( defined ( 'DOING_AUTOSAVE' ) ) { $ ret = true ; } if ( defined ( '... | Check for some urls where geotargeting should be disabled |
9,533 | private function user_whitelisted ( ) { $ ret = false ; $ settings = geot_settings ( ) ; if ( isset ( $ settings [ 'fallback_country_ips' ] ) && in_array ( $ this -> ip , textarea_to_array ( $ settings [ 'fallback_country_ips' ] ) ) ) { $ ret = true ; } return apply_filters ( 'geot/treat_request_as_whitelisted' , $ ret... | Check if the user is whitelisted in settings |
9,534 | public static function routes ( Router $ router , array $ files = null ) { $ files = $ files ? $ files : Kernel :: config ( 'route.files' ) ; foreach ( $ files as $ file ) { $ router -> load ( path ( true , $ file ) ) ; } return $ router ; } | Load the routes of project |
9,535 | public function verify ( string $ secret ) : bool { try { $ withoutSig = substr ( $ this -> token , 0 , strrpos ( $ this -> token , '.' ) ) ; $ expected = hash_hmac ( self :: HASH_HMAC_ALGO , $ withoutSig , $ secret , true ) ; return hash_equals ( $ expected , $ this -> signature ) ; } catch ( \ Throwable $ e ) { retur... | Verify the token signature matches when signed with the given secret . |
9,536 | public function enqueue_styles ( ) { global $ pagenow ; if ( 'post.php' == $ pagenow ) { wp_enqueue_style ( 'wp-jquery-ui-dialog' ) ; } $ version = \ GeotFunctions \ get_version ( ) ; wp_enqueue_style ( 'geot' , $ this -> plugin_url . 'css/geotarget.css' , array ( ) , $ version , 'all' ) ; } | Register the stylesheets for the Dashboard . |
9,537 | public function enqueue_scripts ( ) { $ version = \ GeotFunctions \ get_version ( ) ; wp_enqueue_script ( 'geot-selectize' , $ this -> plugin_url . 'js/selectize.min.js' , array ( 'jquery' ) , $ version , false ) ; wp_enqueue_script ( 'geot-chosen' , $ this -> plugin_url . 'js/chosen.jquery.min.js' , array ( 'jquery' )... | Register the JavaScript for the dashboard . |
9,538 | public function ajax_check_license ( ) { if ( empty ( $ _POST [ 'license' ] ) ) { echo json_encode ( [ 'error' => 'Please enter the license' ] ) ; die ( ) ; } $ license = esc_attr ( $ _POST [ 'license' ] ) ; $ response = $ this -> is_valid_license ( $ license ) ; $ opts = geot_settings ( ) ; $ opts [ 'license' ] = $ li... | Ajax callback for check license button |
9,539 | function is_valid_license ( $ license ) { try { $ response = GeotargetingWP :: checkLicense ( $ license ) ; $ result = json_decode ( $ response ) ; if ( isset ( $ result -> success ) ) { update_option ( 'geot_license_active' , 'valid' ) ; } else { delete_option ( 'geot_license_active' ) ; } } catch ( \ Exception $ e ) ... | Call the API and update if valid license Return original response for later use |
9,540 | public function tabs ( ) { $ tabs = $ this -> get_tabs ( ) ; echo '<ul class="geot-admin-tabs">' ; foreach ( $ tabs as $ id => $ tab ) { $ active = $ id === $ this -> view ? 'active' : '' ; $ name = $ tab [ 'name' ] ; $ link = add_query_arg ( 'view' , $ id , admin_url ( 'admin.php?page=geot-settings' ) ) ; echo '<li><a... | Output tab navigation area . |
9,541 | public function save_settings ( ) { if ( isset ( $ _POST [ 'geot_nonce' ] ) && wp_verify_nonce ( $ _POST [ 'geot_nonce' ] , 'geot_save_settings' ) ) { $ settings = $ _POST [ 'geot_settings' ] ; if ( isset ( $ _FILES [ 'geot_settings_json' ] ) && 'application/json' == $ _FILES [ 'geot_settings_json' ] [ 'type' ] ) { $ f... | Save the settings page |
9,542 | public function apply ( Request $ request , Match $ match , array $ middlewares = [ ] ) { $ pipe = $ match -> getOption ( 'pipe' ) ; if ( ! is_array ( $ pipe ) ) { return $ this -> resolve ( $ request , $ match ) ; } $ piping = array_filter ( $ middlewares , function ( $ middleWare ) use ( $ pipe ) { return in_array ( ... | Apply the middleware s to Match |
9,543 | public function render ( array $ views ) { if ( ! array_key_exists ( 'views' , $ views ) ) { $ views [ 'views' ] = array ( $ views ) ; } $ content = '' ; foreach ( $ views [ 'views' ] as $ view ) { $ content .= $ this -> renderView ( $ view ) ; } return $ content ; } | Renders a set of twig templates . |
9,544 | public static function copyTransparency ( $ dstImg , $ srcImg ) { $ tIndex = imagecolortransparent ( $ srcImg ) ; $ tColor = array ( 'red' => 255 , 'green' => 255 , 'blue' => 255 ) ; if ( $ tIndex >= 0 ) { $ tColor = imagecolorsforindex ( $ srcImg , $ tIndex ) ; } $ tIndex = imagecolorallocate ( $ dstImg , $ tColor [ '... | Copy transparency from source image to destination |
9,545 | public function handleRequest ( ) { list ( $ route , $ target ) = $ this -> bootForRequest ( ) ; $ response = $ this -> runRequest ( $ route , $ target ) ; $ this -> sendResponse ( $ response ) ; $ this -> terminateRequest ( ) ; } | Handle request to this application . |
9,546 | private function bootForRequest ( ) { $ request = Request :: getInstance ( ) ; $ this -> setErrorConfigurations ( $ request ) ; $ route = Router :: getInstance ( ) -> matchRequest ( $ request ) ; abort_unless ( $ route instanceof Route , 404 ) ; $ target = $ route -> getTarget ( ) ; if ( ! $ target instanceof Closure )... | Boots application to handle HTTP request |
9,547 | private function getControllerLogic ( $ action ) { list ( $ class , $ method ) = getClassAndMethodFromString ( $ action ) ; $ controllerClass = fixClassname ( Router :: $ namespace , $ class ) ; $ controller = new $ controllerClass ( ) ; if ( ! $ controller instanceof Controller ) { throw new Exception ( "$class does n... | Converts controller action into a closure |
9,548 | private function bootForJob ( ) { if ( ! isCLI ( ) ) { abort ( 500 , "Somehow, you are not running this from a command line interface." ) ; } $ this -> setErrorConfigurations ( ) ; $ args = Args :: parse ( ) ; $ target = CLIRouter :: getInstance ( ) -> matchCommand ( $ args ) ; return [ $ args , $ target ] ; } | Boots application to handle CLI requests |
9,549 | public function client ( $ client , $ secret , $ redirect , $ requestUrl , $ accessUrl ) { Argument :: i ( ) -> test ( 1 , 'string' ) -> test ( 2 , 'string' ) -> test ( 3 , 'url' ) -> test ( 4 , 'url' ) -> test ( 5 , 'url' ) ; return Client :: i ( $ client , $ secret , $ redirect , $ requestUrl , $ accessUrl ) ; } | Returns oauth 2 client side class |
9,550 | public function desktop ( $ client , $ secret , $ redirect , $ requestUrl , $ accessUrl ) { Argument :: i ( ) -> test ( 1 , 'string' ) -> test ( 2 , 'string' ) -> test ( 3 , 'url' ) -> test ( 4 , 'url' ) -> test ( 5 , 'url' ) ; return Desktop :: i ( $ client , $ secret , $ redirect , $ requestUrl , $ accessUrl ) ; } | Returns oauth 2 desktop class |
9,551 | public function setRequestFormatByAcceptHeader ( JoinPointInterface $ joinPoint ) { $ actionRequest = $ joinPoint -> getProxy ( ) ; foreach ( array ( 'Accept' , 'Http-Accept' , 'Content-Type' ) as $ fieldName ) { $ headerValue = $ actionRequest -> getHttpRequest ( ) -> getHeader ( $ fieldName ) ; foreach ( array ( 'app... | Sets the request format according th the given accept header . |
9,552 | public function read ( $ text ) { $ payload = $ this -> getPayload ( $ text ) ; $ handle = $ this -> getHandle ( ) ; $ handle -> setUrl ( $ payload -> getServiceUrl ( ) ) ; $ handle -> setOption ( CURLOPT_RETURNTRANSFER , 1 ) ; $ handle -> setOption ( CURLOPT_POST , true ) ; $ handle -> setOption ( CURLOPT_POSTFIELDS ,... | Read audio from Ivona service |
9,553 | public function save ( ) { $ data = [ ] ; $ values = [ ] ; foreach ( $ this -> getAlias ( ) as $ field => $ alias ) { $ method = 'get' . ucfirst ( $ alias ) ; $ value = $ this -> $ method ( ) ; if ( null === $ value ) { continue ; } $ data [ $ field ] = ':' . $ alias ; $ values [ $ alias ] = $ value ; } if ( null !== $... | Save row in database . |
9,554 | public function setRequestHandler ( $ handler ) { $ this -> requestHandler = $ handler ; $ this -> requestHandler -> setUri ( $ this -> url ) -> setMethod ( $ this -> method ) ; $ this -> requestHandler -> getUri ( ) -> setPort ( $ this -> port ) ; return $ this ; } | Sets request handler |
9,555 | public function getRequestHandler ( ) { if ( ! isset ( $ this -> requestHandler ) ) { $ requestHandler = new \ Zend \ Http \ Client ( ) ; $ requestHandler -> setOptions ( array ( 'timeout' => 60 ) ) ; $ this -> setRequestHandler ( $ requestHandler ) ; } return $ this -> requestHandler ; } | Returns request handler |
9,556 | protected function parseXml ( $ xml ) { $ data = array ( ) ; foreach ( $ xml -> children ( ) as $ name => $ child ) { if ( count ( $ child -> children ( ) ) > 0 ) { $ value = $ this -> parseXml ( $ child ) ; } else { $ value = ( string ) $ child ; } $ node = array ( 'tag' => $ name , 'value' => $ value ) ; foreach ( $ ... | Parse response xml |
9,557 | protected function buildResponse ( $ data ) { $ response = $ this -> getCompilerResponse ( ) ; foreach ( $ data as $ item ) { if ( ! isset ( $ item [ 'tag' ] ) && ! isset ( $ item [ 'value' ] ) ) { continue ; } if ( isset ( $ item [ 'tag' ] ) && ( $ item [ 'tag' ] == 'errors' || $ item [ 'tag' ] == 'warnings' ) ) { for... | Build response object from compiler response data |
9,558 | protected function encodeData ( $ params ) { $ data = array ( ) ; foreach ( $ params as $ key => $ value ) { $ key = preg_replace ( '/_[0-9]$/' , '' , $ key ) ; $ data [ ] = $ key . '=' . urlencode ( $ value ) ; } return implode ( '&' , $ data ) ; } | Parse and encode data |
9,559 | public function compile ( ) { $ requestHandler = $ this -> getRequestHandler ( ) ; $ encodedData = $ this -> encodeData ( $ this -> getParams ( ) ) ; $ requestHandler -> setRawBody ( $ encodedData ) ; $ response = $ requestHandler -> send ( ) ; $ xml = new \ SimpleXMLElement ( $ response -> getBody ( ) ) ; $ data = $ t... | Compile Javascript code |
9,560 | protected function getObjectManager ( ClassMetadata $ metadata ) : ? ObjectManager { foreach ( $ this -> managerRegistryCollection as $ managerRegistry ) { if ( $ objectManager = $ managerRegistry -> getManagerForClass ( $ metadata -> getName ( ) ) ) { return $ objectManager ; } } return null ; } | Get the object manager handling the specified class Returns NULL if cannot be found . |
9,561 | protected function loadFromObjectManager ( ClassMetadata $ metadata , $ data ) { if ( null === $ objectManager = $ this -> getObjectManager ( $ metadata ) ) { return null ; } $ classMetadataFactory = $ objectManager -> getMetadataFactory ( ) ; if ( $ classMetadataFactory -> isTransient ( $ metadata -> getName ( ) ) ) {... | Try to load an object from doctrine . |
9,562 | public function convert ( $ img , $ outputFormat , $ targetPath , $ quality = null ) { ImageFile :: save ( $ targetPath , ImageFile :: get ( $ img ) , ImageFile :: getType ( $ img , $ outputFormat ) , $ quality ) ; } | Convert image to given format |
9,563 | protected function setPageFrom ( QueryInterface $ query ) { if ( $ this -> pageFromPk ) { $ class = $ this -> query -> modelClass ; $ pks = $ class :: primaryKey ( ) ; if ( count ( $ pks ) > 1 ) { throw new NotSupportedException ( 'The "page-from-pk" filter can not be apply for composite primary key.' ) ; } $ query -> ... | Set the page - from - pk option |
9,564 | public function content ( $ content = null ) { if ( $ content !== null ) { if ( ! is_scalar ( $ content ) && ! is_callable ( [ $ content , '__toString' ] ) ) { throw new ResponseException ( 'Response content must be a scalar or object with __toString() method "' . $ this -> getType ( $ content ) . '" given.' ) ; } $ th... | Returns response content |
9,565 | public function status ( $ status = null ) { if ( $ status !== null ) { if ( ! isset ( $ this -> statusTexts [ $ status ] ) ) { throw new ResponseException ( 'Unsupported status code "' . $ status . '"' ) ; } $ this -> status = ( int ) $ status ; if ( $ this -> content === null ) { $ this -> content = $ this -> statusT... | Returns response status code |
9,566 | public function protocol ( $ protocol = null ) { if ( $ protocol !== null ) { $ this -> protocol = $ protocol ; } return $ this -> protocol ; } | Returns response protocol and its version |
9,567 | protected function createRequest ( $ pid , callable $ success = null , callable $ failure = null , callable $ cancel = null , $ timeout = 0.0 ) { if ( $ timeout > 0.0 ) { $ timeout = $ timeout * 1000 + TimeSupport :: now ( ) ; } return new RequestRecord ( $ pid , $ success , $ failure , $ cancel , $ timeout ) ; } | Create RequestRecord . |
9,568 | protected function expireRequests ( ) { $ now = TimeSupport :: now ( ) ; $ expiredReqs = [ ] ; foreach ( $ this -> reqs as $ pid => $ request ) { if ( $ now >= $ request -> getTimeout ( ) ) { $ expiredReqs [ ] = $ request ; } } foreach ( $ expiredReqs as $ request ) { unset ( $ this -> reqs [ $ request -> getPid ( ) ] ... | Cancel overdue Requests . |
9,569 | public static function getProfileAcl ( $ profile ) { $ acl = new AclLibrary ( ) ; $ resources = Resource :: all ( ) ; $ permissions = Permission :: getRecord ( $ profile ) ; $ acl -> addRole ( new Role ( $ profile ) ) ; foreach ( $ resources as $ resource ) $ acl -> addResource ( new AclResource ( $ resource -> id_007 ... | Function instance the acl of a particular profile |
9,570 | public function getJsActionsAllowed ( $ profile , $ resource , $ actions ) { $ actionsAllowed = '[' ; $ flag = false ; foreach ( $ actions as $ action ) { if ( parent :: isAllowed ( $ profile , $ resource , $ action -> id_008 ) ) { if ( $ flag ) $ actionsAllowed .= ',' ; $ actionsAllowed .= '"' . $ action -> id_008 . '... | Function that instantiates an array in javascript to identify actions that allow resource |
9,571 | public function allows ( $ resource = null , $ privilege = null , $ profile = null ) { if ( $ profile === null ) $ profile = auth ( ) -> guard ( 'pulsar' ) -> user ( ) -> profile_id_010 ; try { return parent :: isAllowed ( $ profile , $ resource , $ privilege ) ; } catch ( Exception \ InvalidArgumentException $ e ) { r... | Function to check permission |
9,572 | public function authenticate ( $ auth = null ) { if ( $ auth !== null ) { $ this -> auth = $ auth ; } return $ this -> auth ; } | Sets auth key |
9,573 | public function user ( $ user = null ) { if ( $ user !== null ) { $ this -> user = $ user ; } return $ this -> user ; } | Sets user identifier |
9,574 | public static function cleanRut ( string $ rut , bool $ forceUppercase = true ) { $ filtered = preg_filter ( '/(?!\d|k)./i' , '' , $ rut ) ?? $ rut ; if ( ! empty ( $ filtered ) ) return $ forceUppercase ? strtoupper ( $ filtered ) : strtolower ( $ filtered ) ; } | Cleans a RUT string |
9,575 | public static function separateRut ( string $ rut , bool $ uppercase = true ) { if ( empty ( $ cleaned = self :: cleanRut ( $ rut , $ uppercase ) ) ) { throw new InvalidRutException ( $ rut ) ; } $ array = self :: explodeByLastChar ( $ cleaned ) ; $ array [ 0 ] = ( int ) $ array [ 0 ] ; return $ array ; } | Cleans a RUT from invalid characters and separates it |
9,576 | public static function validate ( ... $ ruts ) { if ( is_array ( $ ruts [ 0 ] ) && func_num_args ( ) === 1 ) { $ ruts = $ ruts [ 0 ] ; } return self :: performValidate ( $ ruts ) ; } | Returns if a RUT or an array of RUTs are valid |
9,577 | public static function validateStrict ( ... $ ruts ) { if ( is_array ( $ ruts [ 0 ] ) && func_num_args ( ) === 1 ) { $ ruts = $ ruts [ 0 ] ; } return self :: performValidateStrict ( $ ruts ) ; } | Returns if a RUT or an array of RUTs are strictly valid |
9,578 | protected static function performValidate ( array $ ruts ) { foreach ( $ ruts as $ rut ) { if ( ! self :: validateRut ( $ rut ) ) { return false ; } ; } return true ; } | Performs the lazy validation of the RUTs |
9,579 | protected static function performValidateStrict ( array $ ruts ) { foreach ( $ ruts as $ rut ) { if ( ! preg_match ( '/(\d){1,2}.\d{3}.\d{3}\-[\dkK]/' , $ rut ) ) { return false ; } if ( ! self :: validateRut ( $ rut ) ) { return false ; } ; } return true ; } | Performs the strict validation of the RUTs |
9,580 | protected static function validateRut ( string $ rut ) { try { [ $ num , $ vd ] = self :: separateRut ( $ rut ) ; } catch ( InvalidRutException $ exception ) { return false ; } if ( $ vd != self :: getVd ( $ num ) ) { return false ; } return true ; } | Validates a RUT |
9,581 | public static function isEqual ( ... $ ruts ) { if ( is_array ( $ ruts [ 0 ] ) && func_num_args ( ) === 1 ) { $ ruts = $ ruts [ 0 ] ; } $ ruts = array_values ( $ ruts ) ; foreach ( $ ruts as & $ rut ) { $ rut = self :: cleanRut ( $ rut ) ; } return count ( $ ruts = array_unique ( $ ruts ) ) === 1 && ! empty ( $ ruts [ ... | Return if two or more RUTs are equal |
9,582 | public static function filter ( ... $ ruts ) { if ( is_array ( $ ruts [ 0 ] ) && func_num_args ( ) === 1 ) { $ ruts = $ ruts [ 0 ] ; } return array_filter ( $ ruts , function ( $ rut ) { return self :: validate ( $ rut ) ; } ) ; } | Filter a given array of RUTs for the correct ones . |
9,583 | public static function isPerson ( string $ rut ) { list ( $ num ) = self :: separateRut ( $ rut ) ; return $ num < self :: COMPANY_RUT_BASE && $ num > 1000000 ; } | Return if the given RUT is for a person |
9,584 | public static function getVd ( int $ num ) { $ i = 2 ; $ sum = 0 ; foreach ( array_reverse ( str_split ( $ num ) ) as $ v ) { if ( $ i === 8 ) $ i = 2 ; $ sum += $ v * $ i ; ++ $ i ; } $ dig = 11 - ( $ sum % 11 ) ; if ( $ dig === 11 ) $ dig = 0 ; if ( $ dig === 10 ) $ dig = 'K' ; return $ dig ; } | Get the Verification Digit from a given number |
9,585 | public function sortQuestion ( $ data ) { $ arr = explode ( "," , $ data ) ; foreach ( $ arr as $ k => $ v ) { $ question = $ this -> getQuizQuestionMapper ( ) -> findById ( $ v ) ; $ question -> setPosition ( $ k ) ; $ this -> getQuizQuestionMapper ( ) -> update ( $ question ) ; } return true ; } | This function update the sort order of the questions in a Quiz |
9,586 | public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; $ has_one = $ this -> owner -> has_one ( ) ; foreach ( $ has_one as $ name => $ class ) { if ( $ class == 'WidgetArea' ) { $ dbName = $ name . 'ID' ; $ wa = $ this -> owner -> $ name ( ) ; if ( ! $ wa -> exists ( ) ) { $ this -> owner -> $ dbName = $ wa ... | Creates WidgetArea DataObjects in not aleready done . |
9,587 | public function getHeaders ( ) { $ this -> getOptions ( ) -> getAuthenticate ( ) -> setPostData ( $ this -> getPayload ( ) ) ; $ headers = [ 'Content-Type: application/json' , 'Host: tts.eu-west-1.ivonacloud.com' , 'User-Agent: ' . $ this -> getOptions ( ) -> getUserAgent ( ) ] ; return array_merge ( $ headers , $ this... | Get service headers |
9,588 | public function createPayload ( ) { $ payloadArray = ( object ) array ( ) ; $ payloadArray -> Input [ 'Data' ] = $ this -> getQueryText ( ) ; $ payloadArray -> Input [ 'Type' ] = 'text/plain' ; $ payloadArray -> OutputFormat [ 'Codec' ] = $ this -> getOptions ( ) -> getOutputFormatCodec ( ) ; $ payloadArray -> OutputFo... | Create json object with post parameters |
9,589 | protected function checkServiceType ( $ serviceType ) { $ reflection = new \ ReflectionObject ( $ this ) ; $ constants = $ reflection -> getConstants ( ) ; if ( ! in_array ( $ serviceType , $ constants ) ) { throw new RuntimeException ( 'The type of service does not support: ' . $ serviceType ) ; } return $ serviceType... | Check available name for service |
9,590 | protected function findTargetFilename ( $ target ) { if ( file_exists ( $ target ) ) { $ dirname = dirname ( $ target ) . DS ; $ filename = pathinfo ( $ target , PATHINFO_FILENAME ) ; $ extension = pathinfo ( $ target , PATHINFO_EXTENSION ) ; $ tmp = $ dirname . $ filename ; for ( $ i = 1 ; ; $ i ++ ) { $ target = $ tm... | Internal method to find the target filename |
9,591 | public function mimetype ( $ acceptedMimetype ) { is_true_or_fail ( $ this -> file , __d ( 'me_tools' , 'There are no uploaded file information' ) , RuntimeException :: class ) ; switch ( $ acceptedMimetype ) { case 'image' : $ acceptedMimetype = [ 'image/gif' , 'image/jpeg' , 'image/png' ] ; break ; case 'text' : $ ac... | Checks if the mimetype is correct |
9,592 | public function all ( $ tag ) { $ i = $ this -> image = new Image ; $ images = $ this -> get ( $ tag , 'basename' ) ; $ results = array ( ) ; foreach ( $ images as $ image ) { try { $ results [ ] = $ i -> get ( $ image [ 'uid' ] ) ; } catch ( \ Exception $ e ) { if ( $ e -> getCode ( ) != 403 ) { throw new \ Exception ... | All images with tag |
9,593 | public function removeAll ( $ id , $ sid = NULL ) { $ user = new User ; $ current = $ user -> current ( $ sid ) ; if ( $ current [ 'type' ] < 2 ) throw new \ JohnVanOrange \ Core \ Exception \ NotAllowed ( 'Must be an admin to access method' , 401 ) ; $ query = new \ Peyote \ Delete ( 'resources' ) ; $ query -> where (... | Remove tag from all images |
9,594 | function build ( Container $ container ) { if ( ! $ container instanceof Container ) throw new \ Exception ( sprintf ( 'Container must instanceof "ContainerManager", you given "%s".' , ( is_object ( $ container ) ) ? get_class ( $ container ) : gettype ( $ container ) ) ) ; $ this -> _buildNamespace ( $ container ) ; $... | Configure container manager |
9,595 | function setExtends ( $ options ) { foreach ( $ options as $ key => $ v ) { if ( ! is_int ( $ key ) ) $ v = array ( $ key => $ v ) ; $ this -> addExtend ( $ v ) ; } return $ this ; } | extends = > [ newName = > serviceOrAlias |
9,596 | public static function decodeJsonContent ( $ block , $ assoc = true ) { $ content = $ block ; $ blockType = null ; if ( is_object ( $ block ) ) { $ content = $ block -> getContent ( ) ; $ blockType = $ block -> getType ( ) ; } $ content = json_decode ( $ content , $ assoc ) ; if ( null === $ content ) { $ blockTypeInfo... | Decodes a json content |
9,597 | public static function buildStructure ( $ array , Structure $ structure ) { switch ( $ structure -> getType ( ) ) { case Structure :: TYPE_LIST : $ result = self :: buildList ( $ array , $ structure ) ; break ; case Structure :: TYPE_ARRAY : $ result = self :: buildArray ( $ array , $ structure ) ; break ; default : th... | Render array displayed as structure |
9,598 | private static function __s_list2 ( $ list ) { $ structure = new Structure ( Structure :: TYPE_LIST , '-' , Structure :: FOUR_SPACE_TAB ) ; return static :: buildStructure ( $ list , $ structure ) ; } | Shortcut to render a list |
9,599 | private static function __s_array ( $ array ) { $ border = new Border ( Border :: TYPE_FRAME ) ; $ structure = new Structure ( Structure :: TYPE_ARRAY , '' , null , '|' , $ border ) ; return static :: buildStructure ( $ array , $ structure ) ; } | Shortcut to render an array with borders |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.