idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
11,400 | public function getConfig ( ) : array { $ redis = $ this -> getDI ( ) -> getRedis ( ) ; if ( ! empty ( $ redisConfig = $ redis -> hGetAll ( $ this -> getNotificationKey ( ) ) ) ) { return $ redisConfig ; } $ config = [ ] ; $ userConfiguration = $ this -> getConfigs ( [ 'hydration' => \ Phalcon \ Mvc \ Model \ Resultset... | Give the user a order array with the user configuration |
11,401 | public function getSessionId ( ) : string { return empty ( $ this -> session_id ) ? $ this -> getSession ( [ 'order' => 'time desc' ] ) -> session_id : $ this -> session_id ; } | get the user session id |
11,402 | public function hasConfig ( string $ key ) { $ redis = $ this -> getDI ( ) -> getRedis ( ) ; $ hashKey = $ this -> getNotificationKey ( ) ; return $ redis -> hGet ( $ hashKey , $ key ) ; } | does the user as the configuration on? |
11,403 | public function getLanguage ( bool $ short = false ) : ? string { $ request = new Request ( ) ; if ( $ this -> isLoggedIn ( ) && ! empty ( $ this -> language ) ) { $ lang = ! $ short ? strtolower ( $ this -> language ) . '_' . $ this -> language : strtolower ( $ this -> language ) ; } elseif ( $ this -> getDI ( ) -> ge... | get the user language |
11,404 | protected function generateDisplayName ( string $ displayname , $ randNo = 200 ) : string { $ usernameParts = array_filter ( explode ( ' ' , strtolower ( $ displayname ) ) ) ; $ usernameParts = array_slice ( $ usernameParts , 0 , 2 ) ; $ part1 = ( ! empty ( $ usernameParts [ 0 ] ) ) ? substr ( $ usernameParts [ 0 ] , 0... | Given a firstname give me a random username |
11,405 | public function updatePassword ( string $ currentPassword , string $ newPassword , string $ verifyPassword ) : bool { $ currentPassword = trim ( $ currentPassword ) ; if ( password_verify ( $ currentPassword , $ this -> password ) ) { $ newPassword = trim ( $ newPassword ) ; $ verifyPassword = trim ( $ verifyPassword )... | Update the password for a current user |
11,406 | public function afterCreate ( ) { $ company = new Companies ( ) ; $ company -> name = $ this -> defaultCompanyName ; $ company -> users_id = $ this -> getId ( ) ; if ( ! $ company -> save ( ) ) { throw new Exception ( current ( $ company -> getMessages ( ) ) ) ; } $ this -> default_company = $ company -> getId ( ) ; if... | What to do after the creation of a new users - Company - add notification for this user |
11,407 | protected function createHandle ( $ filePath ) { try { return $ this -> flysystem -> readStream ( $ filePath ) ; } catch ( FileNotFoundException $ e ) { throw new ResourceNotFoundException ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | This can only be used for read operations ... |
11,408 | public function augmentSQL ( SQLQuery & $ query ) { $ base = ClassInfo :: baseDataClass ( $ this -> owner ) ; $ simple = DB :: getConn ( ) instanceof SQLite3Database ? true : false ; if ( $ simple ) { $ bound = "(($base.Up / $base.Down) / ($base.Up + $base.Down))" ; } else { $ bound = "(($base.Up + 1.9208) / ($base.Up ... | Add in rating information |
11,409 | public function getAllActivity ( ) { $ file = JL :: open ( FEnv :: get ( "framework.config" ) . "smarty_config/smarty.json" ) ; foreach ( $ file as $ one => $ value ) { $ value -> edit = $ this -> generateRoute ( "iumio_manager_smarty_manager_edit" , array ( "config" => $ one ) , null , true ) ; $ value -> save = $ thi... | Get all SmartyConfig |
11,410 | public function editActivity ( string $ config ) { $ file = ( array ) JL :: open ( FEnv :: get ( "framework.config" ) . 'smarty_config/smarty.json' ) ; foreach ( $ file as $ one => $ val ) { if ( $ one == $ config ) { return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 200 , "results" => $ val ) ) ) ; } }... | Get one smarty config |
11,411 | public function saveActivity ( string $ config ) { $ debug = $ this -> get ( "request" ) -> get ( "debug" ) ; $ cache = $ this -> get ( "request" ) -> get ( "cache" ) ; $ compile = $ this -> get ( "request" ) -> get ( "compile" ) ; $ force = $ this -> get ( "request" ) -> get ( "force" ) ; $ sdebug = $ this -> get ( "r... | Save one smarty config |
11,412 | private function setRealBoolean ( string $ val ) : bool { if ( $ val === "true" ) { $ val = true ; } else { $ val = false ; } return ( $ val ) ; } | Set real boolean type |
11,413 | protected function rowToObject ( $ row ) { if ( 'array' == $ this -> returnDataType ) { return $ row ; } if ( $ row ) { $ object = $ this -> createEntity ( ) ; $ this -> loadObjectFromArray ( $ object , $ row ) ; return $ object ; } return ; } | Convert array to entity . |
11,414 | protected function describeWhereFields ( $ where ) { return implode ( ', ' , array_map ( function ( $ v , $ k ) { return sprintf ( "%s='%s'" , $ k , $ v ) ; } , $ where , array_keys ( $ where ) ) ) ; } | Return human - readable representation of where array keys and values . Used in Exceptions . |
11,415 | private function extractDataOfLanguage ( $ lang ) { $ found = [ ] ; preg_match ( '/([a-z]{1,2})(-([a-z0-9]+))?(;q=([0-9\.]+))?/' , $ lang , $ found ) ; $ code = isset ( $ found [ 1 ] ) ? $ found [ 1 ] : null ; $ morecode = isset ( $ found [ 3 ] ) ? $ found [ 3 ] : null ; $ fullcode = $ morecode ? $ code . '-' . $ morec... | Get the language browser data |
11,416 | private function ensureValidImportAndReplace ( array $ matches , callable $ contentReplaceFunction ) : string { $ path = $ matches [ "path" ] ; $ openingQuote = substr ( $ matches [ "path" ] , 0 , 1 ) ; $ closingQuote = \ substr ( $ matches [ "path" ] , - 1 ) ; $ usedQuotes = "" ; if ( $ openingQuote === "'" || $ openi... | Replaces all valid imports with the result of the content replace function |
11,417 | public function getContent ( ) { $ api = $ this -> getApi ( ) ; $ response = $ api -> get ( $ this -> getApiUrl ( ) ) ; $ content = $ api -> decode ( $ response ) ; $ links = [ ] ; $ title = $ this -> getConfig ( 'log_title' ) ; $ log = "# $title\n\n" ; foreach ( $ content as $ release ) { $ date = substr ( $ release -... | Returns the content of the change log to be parsed . The returned data should be an array of strings one entry for each file line . |
11,418 | protected function initializeBundleOptionValue ( array $ attr ) { $ parentId = $ this -> mapSku ( $ this -> getValue ( ColumnKeys :: BUNDLE_PARENT_SKU ) ) ; $ name = $ this -> getValue ( ColumnKeys :: BUNDLE_VALUE_NAME ) ; $ storeId = $ this -> getRowStoreId ( StoreViewCodes :: ADMIN ) ; if ( $ this -> loadBundleOption... | Initialize the bundle option value with the passed attributes and returns an instance . |
11,419 | public function expressions ( ) { $ expressions = [ ] ; if ( $ this -> operand instanceof ExpressionContract ) { $ expressions [ ] = $ this -> operand ; } if ( $ this -> constraint instanceof ExpressionContract ) { $ expressions [ ] = $ this -> constraint ; } return $ expressions ; } | Return all expressions |
11,420 | protected function checkOperand ( $ operand ) { if ( ! is_scalar ( $ operand ) && ! $ operand instanceof ExpressionContract ) { throw new InvalidArgumentException ( 'Condition only acceps scalars and Expression, not ' . Type :: of ( $ operand ) ) ; } return $ operand ; } | Checks the type of the operand |
11,421 | public function checkConstraint ( $ constraint ) { if ( ! $ constraint instanceof ConstraintContract && ! $ constraint instanceof ConstraintGroupContract ) { throw new InvalidArgumentException ( "Constraint has to be Constraint or ConstraintGroup, not " . Type :: of ( $ constraint ) ) ; } if ( $ this -> allowedOperator... | Checks the type of the constraint |
11,422 | public function addRow ( $ row ) { if ( is_array ( $ row ) ) { $ cells = array_values ( $ row ) ; $ row = new Row ( $ cells ) ; } elseif ( $ row instanceof Row ) { $ cells = $ row -> getCells ( ) ; } else { throw new \ InvalidArgumentException ( 'Argument supplied to Table::addRow should be an array or an instance of R... | Add a row to the bottom of the table |
11,423 | public function signUri ( $ uri , $ secret , $ paramName , $ params ) { $ join = ( bool ) parse_url ( $ uri , PHP_URL_QUERY ) ? '&' : '?' ; return $ uri . $ join . $ paramName . '=' . $ this -> createSignature ( $ secret , $ params ) ; } | Sign a URI |
11,424 | public function verifySignature ( $ uri , $ secret , $ paramName ) { $ getParams = array ( ) ; parse_str ( parse_url ( $ uri , PHP_URL_QUERY ) , $ getParams ) ; if ( ! isset ( $ getParams [ $ paramName ] ) ) { return false ; } $ parts = explode ( '.' , $ getParams [ $ paramName ] ) ; $ data = array_pop ( $ parts ) ; $ ... | Verify Signature and get Signed Data |
11,425 | public function createForm ( $ type , $ data = null , array $ options = [ ] ) { return $ this -> application [ 'form.factory' ] -> create ( $ type , $ data , $ options ) ; } | Creates a new form . |
11,426 | public function getUser ( ) { $ token = $ this -> application [ 'security.token_storage' ] -> getToken ( ) ; if ( null === $ token ) { return null ; } $ user = $ token -> getUser ( ) ; if ( ! is_object ( $ user ) ) { return null ; } return $ user ; } | Gets a user from the Security Token Storage . |
11,427 | public function redirect ( $ route , $ parameters = [ ] , $ status = 302 ) { return $ this -> application -> redirect ( $ this -> path ( $ route , $ parameters ) , $ status ) ; } | Redirects the user to another route . |
11,428 | public function getDirectoryList ( $ path = null , $ showHidden = true ) { $ uri = 'directory.list' ; $ uriData = [ ] ; if ( $ path ) { $ uriData [ 'path' ] = $ path ; } if ( $ showHidden ) { $ uriData [ 'show_hidden' ] = true ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ ... | Return the directory list of a given directory |
11,429 | public function getLoggingGet ( $ nr = 0 ) { $ uri = 'logging.get' ; $ uriData = [ 'nr' => $ nr ] ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody (... | Get the full log file by number |
11,430 | public function getLoggingPartial ( $ lines = 30 , $ type = 'all' ) { $ uri = 'logging.partial' ; $ uriData = [ 'lines' => $ lines , 'type' => $ type ] ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e ... | Get a partial log |
11,431 | public function getManageUpdate ( $ full = false ) { $ uri = 'manage.update' ; $ uriData = [ ] ; if ( $ full ) { $ uriData [ 'full' ] = true ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => [ ] ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage (... | Update the library by scanning for new movies |
11,432 | public function getMediaDelete ( $ id , $ deleteFrom = 'all' ) { $ uri = 'media.delete' ; $ uriData = [ 'id' => $ id , 'delete_from' => $ deleteFrom ] ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -... | Delete a media from the wanted list |
11,433 | public function getSearch ( $ query , $ type = null ) { $ uri = 'search' ; $ uriData = [ 'q' => $ query ] ; if ( $ type ) { $ uriData [ 'type' ] = $ type ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( ... | Search the info in providers for a movie |
11,434 | public function createRequest ( $ method , $ url = '' , array $ headers = [ ] ) { return $ this -> client -> createRequest ( $ method , $ url , $ headers ) ; } | Create decoration rely to given client |
11,435 | public function actionAll ( ) { Output :: title ( "Domain units generator" ) ; $ event = $ this -> forgeEvent ( ) ; $ this -> getParams ( $ event ) ; $ this -> generateUnits ( $ event ) ; Output :: block ( 'Success generated' ) ; } | Generate domain units |
11,436 | private function generateGenericFileDebugInfo ( Asset $ asset , string $ filePath , string $ openingComment , string $ closingComment ) : string { return <<<HEADER{$openingComment} Embed asset {$asset->getAssetPath()} from file {$filePath}{$closingComment}HEADER ; } | Returns a generic file header |
11,437 | public function orderByItemId ( $ item_id ) { if ( ! ( $ item_id = ( int ) $ item_id ) ) { return null ; } $ WpDb = $ this -> s :: wpDb ( ) ; $ table = $ WpDb -> prefix . 'woocommerce_order_items' ; $ sql = ' SELECT `order_id` FROM `' . esc_sql ( $ table ) . '` WHERE `order_item_id` = %s LIMIT 1'... | Get order containing item . |
11,438 | public function orderItemById ( $ item_id , \ WC_Abstract_Order $ WC_Order = null ) { if ( ! ( $ item_id = ( int ) $ item_id ) ) { return [ ] ; } elseif ( ! ( $ WC_Order = $ WC_Order ? : $ this -> orderByItemId ( $ item_id ) ) ) { return [ ] ; } foreach ( $ WC_Order -> get_items ( ) as $ _item_id => $ _WC_Order_Item ) ... | Get order item by ID . |
11,439 | public function productIdFromItem ( $ WC_Order_Item ) : int { if ( $ WC_Order_Item instanceof \ WC_Order_Item_Product ) { if ( ( $ variation_id = $ WC_Order_Item -> get_variation_id ( ) ) ) { return ( int ) $ variation_id ; } return ( int ) $ WC_Order_Item -> get_product_id ( ) ; } elseif ( $ WC_Order_Item instanceof \... | Get product ID from item . |
11,440 | public function productByOrderItemId ( $ item_id , \ WC_Abstract_Order $ WC_Order = null ) { if ( ! ( $ item_id = ( int ) $ item_id ) ) { return null ; } elseif ( ! ( $ WC_Order = $ WC_Order ? : $ this -> orderByItemId ( $ item_id ) ) ) { return null ; } foreach ( $ WC_Order -> get_items ( ) as $ _item_id => $ _WC_Orde... | Get product by order item ID . |
11,441 | protected function streamContextArray ( ) { return [ 'http' => [ 'method' => $ this -> method , 'header' => $ this -> header , 'content' => $ this -> content , 'protocol_version' => $ this -> protocolVersion , 'ignore_errors' => $ this -> getOption ( 'ignore_errors' ) , 'follow_location' => $ this -> getOption ( 'max_r... | Build the beautiful array for stream_context_create |
11,442 | public function certonly ( $ email , $ webroot , $ domains ) { $ result = $ this -> command . ' certonly --webroot --debug --agree-tos' ; $ result .= ' --email ' . $ email ; $ result .= ' -w ' . $ webroot ; foreach ( $ domains as $ domain ) { $ result .= ' -d ' . $ domain ; } return $ result ; } | Issue certificate using standalone webroot |
11,443 | public function send ( $ method , array $ headers = [ ] , $ content = null , $ protocolVersion = '1.1' ) { $ headers = $ this -> addCredentials ( $ headers ) ; $ this -> callBeforeListeners ( 'send' , [ $ this -> url , $ method , & $ headers ] ) ; $ this -> close ( ) ; $ header = implode ( "\r\n" , $ headers ) ; $ stre... | Send a http request with file_file_get_contents . |
11,444 | protected function parseMessage ( $ message ) { $ headerAndBody = explode ( "\r\n\r\n" , $ message , 2 ) ; $ headers = explode ( "\r\n" , $ headerAndBody [ 0 ] ) ; return [ $ this -> parseHeader ( $ headers ) , $ headerAndBody [ 1 ] ] ; } | Splits the received message in header and body . |
11,445 | protected function popCredentials ( UrlContract $ url ) { if ( $ url -> user && $ url -> password ) { $ this -> user = $ url -> user ; $ this -> password = $ url -> password ; return $ url -> user ( '' ) -> password ( '' ) ; } $ this -> user = '' ; $ this -> password = '' ; return $ url ; } | Remove the credentials from url and assign them to |
11,446 | protected function addCredentials ( array $ headers ) { if ( ! $ this -> user || ! $ this -> password ) { return $ headers ; } foreach ( $ headers as $ line ) { if ( stripos ( trim ( $ line ) , 'authorization: basic' ) === 0 ) { return $ headers ; } } $ auth = $ this -> user . ':' . $ this -> password ; $ headers [ ] =... | Add the assigned credentials as Basic Auth headers . |
11,447 | private function setCasEnvironment ( $ environment ) { switch ( $ environment ) { case 'development' : $ this -> setCasHost ( 'authtest.it.usf.edu' ) ; $ this -> setCasPort ( 443 ) ; $ this -> setCasContext ( '/' ) ; $ this -> configureCasClient ( ) ; $ this -> setCasCaCertPath ( '/etc/USF-CA-chain.pem' ) ; phpCAS :: h... | Configures the phpCAS object for the USF CAS environments . |
11,448 | private function setCasCaCertPath ( $ ca_file ) { if ( $ ca_file === 'none' ) { phpCAS :: setNoCasServerValidation ( ) ; } else { if ( file_exists ( $ ca_file ) && is_readable ( $ ca_file ) ) { phpCAS :: setCasServerCACert ( $ ca_file ) ; } else { throw new Exception ( "Unable to read CAS CA-Cert file: " . $ ca_file , ... | Set the location of the CA cert file for the CAS server . |
11,449 | private function checkConfigOptions ( $ config ) { if ( ! isset ( $ config [ 'cas_host' ] ) ) { throw new Exception ( "CAS host required!" , 500 ) ; } if ( ! isset ( $ config [ 'cas_port' ] ) ) { throw new Exception ( "CAS port required!" , 500 ) ; } if ( ! isset ( $ config [ 'cas_context' ] ) ) { throw new Exception (... | Check passed config options for errors . |
11,450 | public static function listDirectories ( string $ directory , int $ depth = 1 ) : array { $ path = $ directory . str_repeat ( '*/' , $ depth ) ; $ files = array ( ) ; foreach ( glob ( $ path , GLOB_ONLYDIR ) as $ filepath ) { $ files [ ] = $ filepath . '/' ; } return $ files ; } | List all subdirectories of the specified directory . |
11,451 | public static function listFiles ( string $ directory , string $ regex = "*" ) : array { $ files = array ( ) ; foreach ( glob ( $ directory . $ regex ) as $ filepath ) { $ files [ ] = $ filepath ; } return $ files ; } | List all files in the specified directory . |
11,452 | public static function listFilesRecursively ( string $ directory , bool $ absolutePath = true , string ... $ extensions ) : array { $ paths = array ( ) ; if ( ! is_dir ( $ directory ) ) { return $ paths ; } $ directoryIterator = new \ RecursiveDirectoryIterator ( $ directory ) ; $ recursiveIterator = new \ RecursiveIte... | List all files in the specified directory and its subdirectories . |
11,453 | public static function getMimetype ( string $ file ) : string { $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mimetype = finfo_file ( $ finfo , $ file ) ; finfo_close ( $ finfo ) ; return $ mimetype ; } | Get the mimetype of the file at the specified path . |
11,454 | public static function getContent ( string $ path , $ default = null ) { if ( is_file ( $ path ) && ( ( $ content = file_get_contents ( $ path ) ) !== false ) ) { return $ content ; } return $ default ; } | Get content of the file at the specified path . |
11,455 | public static function setContent ( string $ path , $ data , bool $ createIfDoesntExist = false ) { if ( $ createIfDoesntExist && ! is_dir ( dirname ( $ path ) ) ) { mkdir ( dirname ( $ path ) , 0777 , true ) ; } if ( empty ( $ data ) ) { file_put_contents ( $ path , $ data ) ; return ; } if ( ! file_put_contents ( $ p... | Set content of the file at the specified path . |
11,456 | public static function redirect ( string $ page , bool $ permanent = false , bool $ callExit = false ) { $ httpStatus = 302 ; if ( $ permanent === true ) { $ httpStatus = 301 ; } http_response_code ( $ httpStatus ) ; header ( 'Location: ' . $ page ) ; if ( $ callExit === true ) { exit ; } } | Create a http redirect and kill the script |
11,457 | public function register ( ) { $ this -> app [ 'squanto.cache_path' ] = $ this -> getSquantoCachePath ( ) ; $ this -> app [ 'squanto.lang_path' ] = $ this -> getSquantoLangPath ( ) ; $ this -> registerTranslator ( ) ; $ this -> app -> bind ( CachedTranslationFile :: class , function ( $ app ) { return new CachedTransla... | Register our translator |
11,458 | protected function _rrmdir ( $ path ) { $ i = new DirectoryIterator ( $ path ) ; foreach ( $ i as $ f ) { if ( $ f -> isFile ( ) ) { $ this -> warn ( 'Permanently removed file ' . str_replace ( base_path ( ) , null , $ f -> getRealPath ( ) ) ) ; unlink ( $ f -> getRealPath ( ) ) ; } else if ( ! $ f -> isDot ( ) && $ f ... | Recursively removes a folder along with all its files and directories |
11,459 | public function urlAdd ( string $ url , string $ action = '-1' ) : string { return $ this -> c :: addUrlQueryArgs ( [ '_wpnonce' => wp_create_nonce ( $ action ) ] , $ url ) ; } | Add an nonce to a URL . |
11,460 | public function apply ( ) : bool { $ path = FEnv :: get ( "framework.root" ) . "apps/" . $ this -> appname . "/config.json" ; if ( false === JsonListener :: exists ( $ path ) ) { AppConfig :: createHimSelf ( $ this -> appname ) ; } $ file = JsonListener :: open ( $ path ) ; $ file -> locale_enabled = $ this -> enabled ... | Apply object persist |
11,461 | private function getValue ( $ tag_name ) { return is_null ( $ this -> tag ) ? $ this -> empty : $ this -> tag -> getChildValue ( $ tag_name ) ; } | Fetch the character data contained in some element . This function is for internal usage only . |
11,462 | public function getPhoto ( ) { if ( is_null ( $ photo = $ this -> tag -> getChild ( 'PHOTO' ) ) ) { return NULL ; } else { try { return new Avatar ( $ photo ) ; } catch ( Exception $ e ) { return NULL ; } } } | Get the avatar from the vCard . Avatar is represented by an instance of BSMAvatar class . |
11,463 | public static function getTranslations ( string $ locale ) { if ( stripos ( $ locale , '_' ) !== false ) { $ locale = str_ireplace ( "_" , "-" , $ locale ) ; } $ locale = strtolower ( $ locale ) ; $ localePart = explode ( '-' , $ locale ) [ 0 ] ; $ languageFilesToCheck = array ( "root" , $ localePart , $ locale ) ; $ d... | Get all available translations for the given locale . |
11,464 | public static function getLocale ( bool $ reload = false ) { if ( ! empty ( self :: $ runtimeLocale ) && ! $ reload ) { return self :: $ runtimeLocale ; } $ defaultLocale = Config :: getConfigurationValueOrDefault ( 'defaultLocale' , Language :: ENGLISH_US ) ; if ( Request :: hasCookie ( Language :: LANGUAGE_COOKIE_NAM... | Get the locale for the current client . The default is currently set to English . |
11,465 | public static function setLocale ( string $ locale ) { self :: $ runtimeLocale = self :: getCompatibleLocale ( $ locale ) ; Response :: setCookieHttpOnly ( Language :: LANGUAGE_COOKIE_NAME , self :: $ runtimeLocale ) ; } | Set the locale for the current client . |
11,466 | private static function getCompatibleLocale ( string $ locale ) : string { if ( ! class_exists ( 'Locale' , true ) ) { return $ locale ; } return \ Locale :: acceptFromHttp ( $ locale ) ; } | Tries to find out best available locale for the given value but with additional checking if intl module is available . |
11,467 | protected function checkData ( $ method , & $ data , $ checksum ) { $ freshChecksum = $ this -> createChecksum ( $ method , $ data ) ; if ( $ freshChecksum != $ checksum ) { throw new DataIntegrityException ( 'Checksum of file ' . $ this -> getUrl ( ) . " failed. ($freshChecksum != $checksum)" ) ; } } | Check the data integrity by the passed checksum . If invalid throw an exception |
11,468 | protected function fileExtension ( ) { if ( ! $ this -> fileExtension ) { $ mimeType = $ this -> serializer -> mimeType ( ) ; $ this -> fileExtension = $ this -> mimetypes -> fileExtensions ( $ mimeType ) [ 0 ] ; } ; return $ this -> fileExtension ; } | Get the file extension for the cache files |
11,469 | protected function completeServerInfos ( array & $ infos ) { $ infosKeyDefaultValues = [ 'host' => null , 'port' => null , 'weight' => 0 ] ; foreach ( $ infosKeyDefaultValues as $ infosKey => $ defaultValue ) { if ( ! isset ( $ infos [ $ infosKey ] ) ) { $ infos [ $ infosKey ] = $ defaultValue ; } } } | Read the server information and add not existing keys |
11,470 | private function createMessage ( $ message , int $ code ) : string { if ( is_array ( $ message ) ) { if ( ! array_key_exists ( 'code' , $ message ) ) { $ message [ 'code' ] = $ code ; } $ callback = function ( $ m ) use ( $ message ) { $ key = trim ( $ m [ 1 ] ) ; if ( ! isset ( $ message [ $ key ] ) ) { return '' ; } ... | Creates the message for the exception instance |
11,471 | public function parse ( $ rawData ) { $ rawData = trim ( $ rawData ) ; $ start = substr ( $ rawData , 0 , 4 ) ; if ( $ start === '<!--' ) { $ stop = ' ; } elseif ( substr ( $ start , 0 , 2 ) === '/*' ) { $ start = '/*' ; $ stop = '*/' ; } else { return [ ] ; } $ meta = trim ( substr ( $ rawData , strlen ( $ start ) , s... | parse the content and extract meta information |
11,472 | protected function convertKeys ( array $ meta ) { $ return = [ ] ; foreach ( $ meta as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = $ this -> convertKeys ( $ value ) ; } $ newKey = strtolower ( $ key ) ; $ newKey = preg_replace ( '/[^\w+]/' , '_' , $ newKey ) ; $ return [ $ newKey ] = $ value ; } return... | convert meta data keys |
11,473 | protected function parsePhileFormat ( $ string ) { if ( empty ( $ string ) ) { return null ; } $ meta = [ ] ; $ lines = explode ( "\n" , $ string ) ; foreach ( $ lines as $ line ) { $ parts = explode ( ':' , $ line , 2 ) ; if ( count ( $ parts ) !== 2 ) { continue ; } $ parts = array_map ( 'trim' , $ parts ) ; $ meta [... | Phile meta format parser . |
11,474 | public static function definer ( string $ env ) : int { $ base = realpath ( __DIR__ . "/../../../../../../" ) . "/" ; define ( 'IUMIO_ENV' , $ env ) ; define ( 'IUMIO_ROOT' , $ base ) ; $ current = self :: getProtocol ( ) . "://" . $ _SERVER [ 'HTTP_HOST' ] . dirname ( $ _SERVER [ 'PHP_SELF' ] ) ; $ current_temp = subs... | Define all environment constants |
11,475 | protected static function __setPaths ( string $ base , string $ env , string $ current , $ isfcm = false ) { self :: $ framework_paths = [ "framework.env" => $ env , "framework.root" => $ base , "framework.elements" => $ base . "elements/" , "framework.bin" => $ base . "bin/" , "framework.config" => $ base . "elements/... | Create all framework paths |
11,476 | public static function getFileEnv ( string $ env ) : string { $ env = strtolower ( $ env ) ; if ( in_array ( $ env , array ( "dev" , "prod" ) ) ) { return ( self :: $ env_file ) ; } else { throw new \ Exception ( "Environment Error : Environment $env doesn't exist" ) ; } } | Get environment file |
11,477 | public static function enableComponents ( string $ env ) { $ base = realpath ( __DIR__ . "/../../../../../../" ) . "/" ; $ f = json_decode ( file_get_contents ( $ base . "elements/config_files/core/framework.config.json" ) ) ; if ( in_array ( $ env , array ( "dev" , "prod" ) ) ) { if ( "dev" === $ env ) { TaskBar :: sw... | Enable framework components |
11,478 | public function equals ( $ other , $ considerAffix = false ) { if ( $ other instanceof self ) { return $ considerAffix ? ( $ other -> toString ( ) == $ this -> toString ( ) ) : ( $ other -> getSource ( ) == $ this -> source ) ; } $ other = "$other" ; if ( $ considerAffix ) { return $ other == $ this -> toString ( ) ; }... | Test if this StringList is equal to a string another StringList . |
11,479 | public function copy ( ) { return parent :: copy ( ) -> setGlue ( $ this -> glue ) -> setPrefix ( $ this -> prefix ) -> setSuffix ( $ this -> suffix ) ; } | Copies the list or its extended class . |
11,480 | protected function hasDifferentAffixes ( ) { if ( $ this -> prefix && $ this -> prefix != $ this -> glue ) { return false ; } if ( $ this -> suffix && $ this -> suffix != $ this -> glue ) { return false ; } return true ; } | Returns true if no prefix or suffix setted or if one of them differes from the glue . |
11,481 | public function isUnreadByUser ( $ member = null ) { if ( ! $ member ) { $ member = $ this -> securityContext -> getMember ( ) ; } if ( $ member && $ member -> ID ) { return strtotime ( $ this -> Created ) > strtotime ( $ member -> LastPostView ) ; } } | Has this post been read by the given user? |
11,482 | public function ConvertedContent ( ) { $ content = $ this -> Content ; if ( preg_match_all ( '/#([a-z0-9_-]+)/is' , $ content , $ matches ) ) { foreach ( $ matches [ 1 ] as $ tag ) { $ link = Controller :: join_links ( TimelineController :: URL_SEGMENT , '?tags=' . urlencode ( $ tag ) ) ; $ content = str_replace ( '#' ... | Get the content of this post with hash - tags converted to links |
11,483 | public function currentContext ( ) { $ tgt = Controller :: curr ( ) -> getRequest ( ) -> getVar ( 'target' ) ; return strlen ( $ tgt ) > 0 && $ this -> Target == $ tgt ; } | Whether the current context is that of the post target . |
11,484 | public function mentionedMembers ( ) { $ members = array ( ) ; if ( preg_match_all ( '/@(.*?):(\d+)/' , $ this -> Content , $ matches ) ) { foreach ( $ matches [ 2 ] as $ match ) { $ member = Member :: get ( ) -> byID ( ( int ) $ match ) ; if ( $ member && $ member -> ID ) { $ members [ ] = $ member ; } } } return $ me... | Get the list of members mentioned in this post |
11,485 | public function tag ( $ tags , $ clearExisting = false ) { if ( ! is_array ( $ tags ) ) { $ tags = array ( $ tags ) ; } if ( $ clearExisting ) { $ this -> Tags ( ) -> removeAll ( ) ; } $ created = array ( ) ; foreach ( $ tags as $ tag ) { if ( ! preg_match ( '/[a-z0-9_-]/i' , $ tag ) ) { continue ; } $ existing = PostT... | Tag this post with a particular tag |
11,486 | public function currentVotesByUser ( $ user = null ) { if ( ! $ user ) { $ user = $ this -> securityContext -> getMember ( ) ; } $ votes = MicroPostVote :: get ( ) -> filter ( array ( 'UserID' => $ user -> ID , 'PostID' => $ this -> ID ) ) ; return $ votes -> toArray ( ) ; } | Gets the list of current votes on this object by the current user |
11,487 | public function delete ( ) { $ this -> RenderedContent = '' ; if ( $ this -> checkPerm ( 'Delete' ) ) { $ this -> Tags ( ) -> removeAll ( ) ; if ( $ this -> config ( ) -> soft_delete || ( $ this -> Replies ( ) -> exists ( ) && $ this -> Replies ( ) -> count ( ) > 0 ) ) { $ count = $ this -> Replies ( ) -> count ( ) ; $... | When deleting an object we actually just remove all its content |
11,488 | public function permissionSource ( ) { if ( $ this -> ParentID ) { return $ this -> Parent ( ) ; } if ( $ this -> PermSourceID ) { return $ this -> PermSource ( ) ; } if ( $ this -> ID && $ this -> Target && strpos ( $ this -> Target , ',' ) ) { list ( $ type , $ id ) = explode ( ',' , $ this -> Target ) ; $ item = Dat... | We need to define a permission source to ensure the ParentID isn t used for permission inheritance |
11,489 | public function form ( Classes \ SCore \ Base \ Widget $ Widget , array $ args = [ ] ) : Classes \ SCore \ WidgetForm { return $ this -> App -> Di -> get ( Classes \ SCore \ WidgetForm :: class , compact ( 'Widget' , 'args' ) ) ; } | A widget form class instance . |
11,490 | public function toArray ( array $ fields = [ ] , array $ expand = [ ] , $ recursive = true ) { $ data = [ ] ; foreach ( $ this -> resolveFields ( $ fields , $ expand ) as $ field => $ definition ) { $ data [ $ field ] = is_string ( $ definition ) ? $ this -> $ definition : call_user_func ( $ definition , $ this , $ fie... | Converts the model into an array . |
11,491 | public function isAuthorized ( $ authZ ) { if ( is_array ( $ authZ ) ) { foreach ( $ authZ as $ currentAuthZ ) { if ( $ this -> checkEntitlement ( $ currentAuthZ ) ) { return true ; } } } else { return $ this -> checkEntitlement ( $ authZ ) ; } return false ; } | Compare the user s entitlements to one or more entitlements for authorizing access in an application . |
11,492 | protected function checkEntitlement ( $ entitlement_value ) { if ( $ entitlement_value == 'permitAll' ) { return true ; } if ( $ entitlement_value == 'denyAll' ) { return false ; } if ( is_array ( $ this -> entitlements ) ) { return ( in_array ( $ entitlement_value , $ this -> entitlements ) ) ; } else { return ( $ ent... | Searches for a given entitlement in the list of entitlements belonging to the user . |
11,493 | public function anyLanguageValues ( $ values , $ attribute = null ) { $ model = new $ this -> owner -> modelClass ( ) ; $ languageClass = $ model -> getRelation ( $ model -> languageRelation ) -> modelClass ; $ this -> owner -> innerJoinWith ( $ model -> languageRelation , false ) -> andWhere ( [ $ languageClass :: tab... | Gets entities by any languages . |
11,494 | public function allLanguageValues ( $ values , $ attribute = null ) { $ model = new $ this -> owner -> modelClass ( ) ; return $ this -> anyLanguageValues ( $ values , $ attribute ) -> andHaving ( new Expression ( 'COUNT(*) = ' . count ( $ model -> filterLanguageValues ( $ values ) ) ) ) ; } | Gets entities by all languages . |
11,495 | public function relatedByLanguageValues ( $ values , $ attribute = null ) { return $ this -> anyLanguageValues ( $ values , $ attribute ) -> addOrderBy ( new Expression ( 'COUNT(*) DESC' ) ) ; } | Gets entities related by languages . |
11,496 | public function create ( array $ fields ) { $ this -> assertValidFields ( $ fields ) ; $ request = new Request ( 'customizations' ) ; $ request -> setParams ( [ 'fields' => $ fields ] ) ; $ response = $ this -> client -> post ( $ request ) ; $ this -> assertSuccessResponse ( $ response ) ; return $ response -> getData ... | Create fields . |
11,497 | public function getList ( $ limit = 100 ) { $ request = new Request ( 'customizations' ) ; $ request -> setQuery ( [ 'limit' => $ limit ] ) ; $ response = $ this -> client -> get ( $ request ) ; $ this -> assertSuccessResponse ( $ response ) ; return $ response -> getData ( ) ; } | Get groups . |
11,498 | public function get ( $ id ) { $ request = new Request ( 'customizations' ) ; $ request -> setIdParam ( urlencode ( $ id ) ) ; $ response = $ this -> client -> get ( $ request ) ; $ this -> assertSuccessResponse ( $ response ) ; return $ response -> getData ( ) ; } | Get group fields |
11,499 | private function assertValidFields ( $ fields ) { if ( ! isset ( $ fields ) ) { throw new InvalidArgumentException ( "Fields are empty" ) ; } foreach ( $ fields as $ field ) { if ( count ( explode ( '.' , $ field [ 'key' ] ) ) != 2 ) { throw new InvalidArgumentException ( 'Key has wrong format' ) ; } } } | Check if fields are valid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.