idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
237,100 | public function httpVersion ( $ version ) { if ( false === defined ( $ version ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() is not a valid HTTP protocol version' , __METHOD__ ) , E_USER_ERROR ) ; } $ this -> options [ CURLOPT_HTTP_VERSION ] = constant ( $ version ) ; return $ this ; } | Set the HTTP version protocol |
237,101 | public function addCookie ( $ key , $ value ) { if ( false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ value ) ) { return trigger_error ( sprintf ( 'Ar... | Add a cookie to the request |
237,102 | private function formatUrl ( ) { $ jar = [ ] ; $ query = $ this -> url -> getQuery ( ) ; if ( null !== $ query ) { $ jar [ ] = $ query ; } $ query = '' ; if ( count ( $ this -> params ) > 0 || count ( $ jar ) > 0 ) { if ( $ this -> method === 'get' ) { foreach ( $ this -> params as $ param ) { $ key = $ param -> encode... | Adds new params to existing params to format the url |
237,103 | private function formatParams ( ) { $ params = [ ] ; foreach ( $ this -> params as $ param ) { $ key = $ param -> encode ? urlencode ( $ param -> key ) : $ param -> key ; $ value = $ param -> encode ? urlencode ( $ param -> value ) : $ param -> value ; $ params [ $ key ] = $ value ; } foreach ( $ this -> files as $ fil... | Formats all the parameters |
237,104 | public function send ( ) { $ this -> response -> setStatus ( [ 'code' => 0 , 'protocol' => '' , 'status' => '' , 'text' => '' ] ) ; $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , $ this -> createOptions ( ) ) ; $ response = curl_exec ( $ curl ) ; if ( false !== $ response ) { $ header_size = curl_getinfo ( $ cur... | Sends the request and sets all the response data |
237,105 | private function parseHeaders ( $ str ) { if ( false === is_string ( $ str ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ str ) ) , E_USER_ERROR ) ; } $ headers = [ ] ; $ status = [ ] ; foreach ( explode ( "\n" , $ str ) as $ header )... | Parses headers and forms it into an Array |
237,106 | private function parseCookies ( $ str ) { if ( false === is_string ( $ str ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ str ) ) , E_USER_ERROR ) ; } $ jar = [ ] ; $ headers = explode ( "\n" , trim ( $ str ) ) ; foreach ( $ headers a... | Parses the cookies from the headers and forms it into an Array |
237,107 | private function createOptions ( ) { $ default = [ CURLOPT_RETURNTRANSFER => true , CURLOPT_HEADER => true , CURLOPT_TIMEOUT => 30 , CURLOPT_URL => $ this -> formatUrl ( ) , CURLOPT_COOKIE => $ this -> formatCookies ( ) , CURLOPT_HTTPHEADER => $ this -> headers ] ; if ( 'get' !== $ this -> method ) { $ this -> options ... | Generates and returns all the options |
237,108 | private function method ( $ url , $ closure , $ method ) { if ( false === is_string ( $ url ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ url ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ method ) ) { return trigger_error ( s... | Sets the method and url and executes a user closure function if given |
237,109 | public function addInstances ( array $ instances ) : self { foreach ( $ instances as $ _key => $ _instance ) { if ( is_string ( $ _key ) ) { $ _class_name = ltrim ( $ _key , '\\' ) ; } else { $ _class_name = get_class ( $ _instance ) ; } $ _class_key = strtolower ( $ _class_name ) ; $ this -> instances [ $ _class_key ]... | Add new instances . |
237,110 | public function addRule ( string $ name , array $ rule ) : self { $ name = ltrim ( $ name , '\\' ) ; $ key = strtolower ( $ name ) ; $ global_default_rule = $ this -> rules [ '*' ] ; $ this -> rules [ $ key ] = array_merge ( $ global_default_rule , $ rule ) ; $ this -> rules [ $ key ] = array_intersect_key ( $ this -> ... | Add a new rule . |
237,111 | protected function getRule ( string $ name , string $ key , array $ parent_names = [ ] ) : array { if ( isset ( $ this -> rules [ $ key ] ) ) { return $ this -> rules [ $ key ] ; } if ( $ this -> total_rules === 1 || ! $ parent_names ) { return $ this -> rules [ '*' ] ; } foreach ( array_map ( 'strtolower' , $ parent_n... | Gets a specific rule . |
237,112 | protected function resolveJitClosures ( array $ array ) { if ( isset ( $ array [ 'di::jit' ] ) ) { return $ array [ 'di::jit' ] ( $ this ) ; } foreach ( $ array as $ _key => & $ _value ) { if ( is_array ( $ _value ) ) { $ _value = $ this -> resolveJitClosures ( $ _value ) ; } } return $ array ; } | Resolve just - in - time closures . |
237,113 | protected function getClosure ( string $ class_name , string $ class_key ) : callable { $ parent_class_names = class_parents ( $ class_name ) ; $ all_class_names = $ parent_class_names ; $ all_class_names [ ] = $ class_name ; $ class = new \ ReflectionClass ( $ class_name ) ; $ constructor = $ class -> getConstructor (... | Get closure for a specific class . |
237,114 | protected function getParamsClosure ( \ ReflectionMethod $ constructor , array $ class_rule ) : callable { $ param_details = [ ] ; foreach ( $ constructor -> getParameters ( ) as $ _parameter ) { $ _name = $ _parameter -> getName ( ) ; $ _class = $ _parameter -> getClass ( ) ; $ _class_name = $ _class -> name ?? '' ; $... | Magic happens here . |
237,115 | protected function file ( $ key ) { return $ this -> dir . DIRECTORY_SEPARATOR . $ this -> key ( $ key ) . "." . $ this -> fileExtension ; } | Generates the filename to store based on the cachePrefix and given key |
237,116 | protected function isExpired ( $ key , $ storageArray = null ) { if ( ! empty ( $ key ) ) { if ( ! $ this -> containsKey ( $ key ) ) return true ; $ storageArray = $ this -> readFile ( $ this -> file ( $ key ) ) ; } if ( is_array ( $ storageArray ) ) { if ( $ storageArray [ 'expires' ] >= time ( ) && $ storageArray [ '... | Determines if the key or storage array specified is expired |
237,117 | protected function getData ( $ key ) { $ filename = $ this -> file ( $ key ) ; if ( ! file_exists ( $ filename ) ) return false ; else { $ data = $ this -> readFile ( $ filename ) ; if ( $ this -> isExpired ( null , $ data ) ) return false ; else { $ expire = $ data [ 'expires' ] ; $ value = $ data [ 'value' ] ; $ dura... | Performs a fetch of our data from the filecache without logging in the logger . That allows this method to be used in other locations . |
237,118 | protected function writeFile ( $ filename , $ value ) { try { FileSystemUtils :: safeFilePutContents ( $ filename , serialize ( $ value ) ) ; return true ; } catch ( Exception $ e ) { return false ; } } | Performs a write to the filesystem of our data . |
237,119 | public function flushExpired ( ) { $ this -> Logger -> debug ( 'Flush all expired called.' ) ; try { foreach ( new DirectoryIterator ( $ this -> dir ) as $ item ) { $ filename = $ item -> getPath ( ) . DIRECTORY_SEPARATOR . $ item -> getFilename ( ) ; $ pathinfo = pathinfo ( $ filename ) ; if ( $ pathinfo [ 'extension'... | Removes all expired items from the cache store |
237,120 | public function matches ( $ uri ) { if ( ! preg_match ( $ this -> compiledRegex , $ uri , $ matches ) ) { return false ; } $ params = array ( ) ; foreach ( $ matches as $ key => $ value ) { if ( $ key == 'controller' && substr_count ( $ value , '_' ) ) { $ temp = explode ( '_' , $ value ) ; $ value = array_pop ( $ temp... | Tests if the route matches a given URI . A successful match will return all of the routed parameters as an array . A failed match will return boolean FALSE . |
237,121 | protected function compile ( ) { $ regex = preg_replace ( '#' . self :: REGEX_ESCAPE . '#' , '\\\\$0' , $ this -> uri ) ; if ( strpos ( $ regex , '(' ) !== false ) { $ regex = str_replace ( array ( '(' , ')' ) , array ( '(?:' , ')?' ) , $ regex ) ; } $ regex = str_replace ( array ( '<' , '>' ) , array ( '(?P<' , '>' . ... | Returns the compiled regular expression for the route . This translates keys and optional groups to a proper PCRE regular expression . |
237,122 | final protected function _getTimeZone ( $ timezone = null ) { if ( $ timezone = strtoupper ( $ timezone ) and defined ( "\\DateTimeZone::{$timezone}" ) ) { $ timezone = new \ DateTimeZone ( $ timezone ) ; } elseif ( ! ( $ timezone instanceof \ DateTimeZone ) ) { @ date_default_timezone_set ( date_default_timezone_get (... | Attempts to get timezone with fallback to default which in turn defaults to UTC |
237,123 | protected function check ( ) { try { $ options = $ this -> getOptions ( ) ; $ response = $ this -> mcStatus -> query ( true ) ; if ( ! is_array ( $ response ) || ! array_key_exists ( 'player_count' , $ response ) ) { $ this -> setMessage ( 'No response from Minecraft server query.' ) ; $ this -> setCode ( self :: STATE... | Check the amount of players on the Minecraft server . |
237,124 | public function build ( ModelInterface $ model , $ relation ) { list ( $ current , $ further ) = $ this -> splitRelationName ( $ relation ) ; $ definition = $ this -> fetchDefinition ( $ model , $ current ) ; switch ( $ definition -> type ( ) ) { case self :: RELATION_ONE : $ instance = new OneRelation ( $ this -> stor... | Sets model and its relation |
237,125 | public function toStringFromYaml ( array $ parseResult ) { $ this -> parameters = $ parseResult ; $ this -> removeNullValues ( ) ; $ this -> removeInvalidKeys ( ) ; $ this -> ensureDefaultBrush ( ) ; $ brush = SyntaxHighlighterBrush :: fromIdentifierOrAlias ( $ this -> parameters [ 'brush' ] ) ; $ this -> eventContext ... | Parse to scalar string from YAML . |
237,126 | private function formatValues ( ) { array_walk ( $ this -> parameters , function ( & $ value , $ key ) { $ parameterValue = $ value ; if ( is_bool ( $ parameterValue ) ) { $ parameterValue = var_export ( $ parameterValue , true ) ; } $ formattedValue = sprintf ( self :: DEFAULT_PAIR_FORMAT , $ key , $ parameterValue ) ... | Applies formats formatting to values . |
237,127 | public function getObject ( $ forceInstance = false ) { if ( false === $ forceInstance && true === $ this -> getValidationResult ( ) -> hasErrors ( ) ) { throw new Exception ( 'Trying to access a configuration object which contains errors. You should first check if it is error free, then use it: "$yourObject->getValida... | Returns the real instance of the configuration object . |
237,128 | public function setValidationResult ( Result $ result ) { if ( false === $ this -> mapperResult -> hasErrors ( ) ) { $ this -> validationResult = $ result ; } } | Manually set the validation result . Used in the cache service . |
237,129 | public function refreshValidationResult ( ) { if ( false === $ this -> mapperResult -> hasErrors ( ) ) { $ validator = Core :: get ( ) -> getValidatorResolver ( ) -> getBaseValidatorConjunction ( get_class ( $ this -> object ) ) ; $ this -> validationResult = $ validator -> validate ( $ this -> object ) ; } return $ th... | If the mapping result which was passed as a constructor argument of this class contains error the validation result will be the same . Otherwise a recursive validation of the object is processed . |
237,130 | public function getPublisherHTML ( $ config = array ( ) ) { $ session_secret = "" ; $ fields = array ( 'config' => $ config ) ; $ webservice_url = '/ws/setruntimeoptions/' . $ this -> publisherKey ; if ( ! empty ( $ config ) ) { if ( array_key_exists ( "gameid" , $ config ) ) { $ webservice_url .= '/' . $ config [ 'gam... | Returns the markup for PlayThru . = |
237,131 | public function scoreResult ( ) { $ result = false ; if ( $ this -> sessionSecret ) { $ fields = array ( 'session_secret' => urlencode ( $ this -> sessionSecret ) , 'scoring_key' => $ this -> scoringKey ) ; $ resp = $ this -> doHttpsPostReturnJSONArray ( $ this -> webService , '/ws/scoreGame' , $ fields ) ; if ( $ resp... | Check whether the user is a human . Wrapper for the scoreGame API call |
237,132 | protected function doHttpsPostReturnJSONArray ( $ hostname , $ path , $ fields ) { $ result = $ this -> doHttpsPost ( $ hostname , $ path , $ fields ) ; if ( $ result ) { $ result = json_decode ( $ result ) ; } else { error_log ( "AYAH::doHttpsPostGetJSON: Post to https://$hostname$path returned no result." ) ; $ resul... | Do an HTTPS POST return some JSON decoded as array . |
237,133 | protected function doHttpsPost ( $ hostname , $ path , $ fields ) { $ result = '' ; $ fields_string = '' ; foreach ( $ fields as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( ! empty ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ fields_string .= $ key . '[' . $ k . ']=' . $ v . '&' ; } } else { $ fiel... | Initiate a request to the AYAH web service through curl or using a socket if the system does not have curl available . |
237,134 | public static function tableExists ( $ tableName ) { $ query = "SELECT 1 FROM $tableName LIMIT 1" ; try { $ result = Connection :: db ( ) -> query ( $ query ) ; } catch ( Exception $ e ) { return false ; } return $ result !== false ; } | Checks if a given table exists in the database |
237,135 | public static function getAll ( $ fields = null ) { $ table = self :: getTableNameFromClass ( ) ; if ( $ fields != null && is_array ( $ fields ) ) { $ query = "SELECT " . implode ( ', ' , $ fields ) . " FROM $table" ; } else { $ query = "SELECT * FROM $table" ; } $ res = [ ] ; $ results = Connection :: db ( ) -> query ... | Get all records from the record table |
237,136 | public static function getOne ( $ id , $ fields = null ) { $ table = self :: getTableNameFromClass ( ) ; if ( $ fields != null && is_array ( $ fields ) ) { $ query = "SELECT " . implode ( ', ' , $ fields ) . " FROM $table WHERE id = $id" ; } else { $ query = "SELECT * FROM $table WHERE id = $id" ; } $ res = [ ] ; $ res... | Get one record from the table based on the id provided |
237,137 | public function save ( ) { $ result ; if ( ! self :: $ id ) { $ query = "INSERT INTO $this->tableName (" . implode ( ", " , array_keys ( $ this -> props ) ) . ") VALUES(" ; for ( $ i = 0 ; $ i < count ( $ this -> props ) ; $ i ++ ) { $ query .= "?" ; if ( $ i != count ( $ this -> props ) - 1 ) { $ query .= "," ; } } $ ... | Save either a new or existing record |
237,138 | public static function destroy ( $ id ) { $ table = self :: getTableNameFromClass ( ) ; self :: getOne ( $ id ) ; $ query = "DELETE FROM $table WHERE id = " . $ id ; try { Connection :: db ( ) -> query ( $ query ) ; return true ; } catch ( Exception $ e ) { return false ; } } | Delete a record by id from the table in context |
237,139 | public function transform ( $ value ) : string { if ( null === $ value || '' === $ value ) { return '' ; } if ( ! is_numeric ( $ value ) ) { throw new TransformationFailedException ( 'Expected a numeric or null.' ) ; } if ( $ value >= PHP_INT_MAX || $ value <= - PHP_INT_MAX ) { throw new TransformationFailedException (... | Transforms a number type into number . |
237,140 | public function reverseTransform ( $ value ) { if ( ! is_scalar ( $ value ) ) { throw new TransformationFailedException ( 'Expected a scalar.' ) ; } if ( '' === $ value ) { return null ; } $ result = $ value ; if ( ! is_numeric ( $ result ) ) { throw new TransformationFailedException ( 'Value is not numeric.' ) ; } if ... | Transforms a normalized number into an integer or float . |
237,141 | protected function locateFile ( $ file ) { $ this -> locateFile && $ file = call_user_func ( $ this -> locateFile , $ file ) ; return $ file ; } | Convert file name by callback |
237,142 | public function getRevMap ( ) { if ( $ this -> revMap === null ) { if ( $ this -> revFile && is_file ( $ this -> revFile ) ) { $ this -> revMap = ( array ) json_decode ( file_get_contents ( $ this -> revFile ) ) ; } else { $ this -> revMap = [ ] ; } } return $ this -> revMap ; } | Returns rev file content that parsed to array |
237,143 | public function addRevFile ( $ file ) { $ this -> getRevMap ( ) ; if ( is_file ( $ file ) ) { $ this -> revMap = json_decode ( file_get_contents ( $ file ) , true ) + $ this -> revMap ; } return $ this ; } | Add rev map from file |
237,144 | public function getRevFile ( $ file ) { $ map = $ this -> getRevMap ( ) ; if ( isset ( $ map [ $ file ] ) ) { $ index = strrpos ( $ file , '.' ) ; $ file = $ this -> revPrefix . substr ( $ file , 0 , $ index ) . '-' . $ map [ $ file ] . substr ( $ file , $ index ) ; } return $ file ; } | Returns the file path contains revision |
237,145 | public function conectar ( $ destino , $ usuario , $ password = false ) { parent :: conectar ( $ destino , $ usuario , $ password ) ; $ this -> destino = $ destino ; $ this -> usuario = $ usuario ; $ this -> password = $ password ; $ this -> objeto = 'objetosLdap' ; } | Sobreescribirlo a este nivel obedece a que es en los objetos donde por ahora he visto la necesidad de acceder a las credenciales de conexion para tratar con diferentes objetos |
237,146 | public function actualizarObjetoLdap ( ) { if ( $ this -> existe ) { $ dn = $ this -> entrada [ 'dn' ] ; $ cambios = array ( ) ; foreach ( $ this -> cambios as $ atributos ) { $ cambios [ $ atributos ] = $ this -> entrada [ $ atributos ] ; } return $ this -> modificarEntradaLdap ( $ dn , $ cambios ) ; } else { $ this -... | Actualiza una entrada LDAP existente |
237,147 | protected function borrarObjetoLdap ( ) { if ( $ this -> existe ) { $ dn = $ this -> dnObjeto ; return $ this -> borrarEntradaLdap ( $ dn ) ; } else { $ this -> configurarErrorLdap ( 'Actualizacion' , 'Esa entrada no existe' ) ; return false ; } } | Borra el objeto que se ha consultado |
237,148 | public function setAppRoot ( array $ config ) { $ this -> app_name = $ config [ 'app_name' ] ; $ this -> app_dir = rtrim ( $ config [ 'app_dir' ] , '/' ) ; $ this -> debug = $ config [ 'debug' ] ; $ this -> config_dir = $ config [ 'config_dir' ] ; $ this -> view_dir = $ config [ 'view_dir' ] ; $ this -> vars_dir = $ co... | set up working directories . |
237,149 | public function loadConfig ( $ env_file = null ) { $ this -> configure ( $ this -> config_dir . '/configure' ) ; if ( $ this -> debug ) { $ this -> configure ( $ this -> config_dir . '/configure-debug' ) ; } $ this -> loadEnvironment ( $ env_file ) ; return $ this ; } | loads the main configuration for the application . |
237,150 | public function loadEnvironment ( $ env_file ) { $ env_file .= '.php' ; if ( ! file_exists ( $ env_file ) ) { return $ this ; } $ environments = ( array ) include ( $ env_file ) ; foreach ( $ environments as $ env ) { $ this -> configure ( $ this -> config_dir . "/{$env}/configure" ) ; } return $ this ; } | loads the environment based configuration . |
237,151 | public function catchError ( array $ error_files ) { $ this -> app -> set ( Web :: ERROR_VIEWS , $ error_files ) ; $ whoops = new Run ; if ( $ this -> debug ) { error_reporting ( E_ALL ) ; $ whoops -> pushHandler ( new PrettyPageHandler ) ; } else { error_reporting ( E_ERROR ) ; $ whoops -> pushHandler ( $ this -> getE... | set up global exception handler . |
237,152 | public function getLog ( ) { if ( $ this -> app -> exists ( LoggerInterface :: class ) ) { return $ this -> app -> get ( LoggerInterface :: class ) ; } $ var_dir = $ this -> vars_dir . '/log/app.log' ; $ logger = new Logger ( 'log' ) ; $ logger -> pushHandler ( new FingersCrossedHandler ( new StreamHandler ( $ var_dir ... | get shared logger . use Monolog as default . |
237,153 | public function lock ( $ id , $ value , array $ parameters = array ( ) ) { $ id = ltrim ( $ id , '\\' ) ; $ obj = $ this -> set ( $ id , $ value , $ parameters ) ; $ this -> offsetSet ( "lock.{$id}" , true ) ; return $ obj ; } | Set a value and prevent modification to return value |
237,154 | private function getUndefined ( $ fqClassName , array $ parameters ) { if ( ! empty ( $ parameters ) ) { $ reflectionClass = new ReflectionClass ( $ fqClassName ) ; return $ reflectionClass -> newInstanceArgs ( $ parameters ) ; } return new $ fqClassName ; } | If the service has not been defined within the container attempt to instantiate the class directly |
237,155 | private function getFiles ( $ path ) { $ files = array ( ) ; foreach ( new \ DirectoryIterator ( $ path ) as $ file ) { if ( $ file -> isDot ( ) || ( null != $ this -> scriptName && sprintf ( '%s.php' , $ this -> scriptName ) != $ file -> getFilename ( ) ) ) { continue ; } $ files [ $ file -> getFilename ( ) ] = sprint... | Get files for a specific path |
237,156 | public static function fromNative ( \ DateTimeInterface $ dateTime ) : Date { return new self ( ( int ) $ dateTime -> format ( 'Y' ) , ( int ) $ dateTime -> format ( 'm' ) , ( int ) $ dateTime -> format ( 'd' ) ) ; } | Creates a date object from the date part of the supplied date time . |
237,157 | public static function fromFormat ( string $ format , string $ dateString ) : Date { return self :: fromNative ( \ DateTimeImmutable :: createFromFormat ( $ format , $ dateString ) ) ; } | Creates a date object from the supplied format string |
237,158 | public function daysBetween ( Date $ other ) : int { return $ this -> dateTime -> diff ( $ other -> dateTime , true ) -> days ; } | Returns the amount of days between the supplied dates . |
237,159 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { if ( ! $ serviceLocator -> has ( 'ServiceListener' ) ) { $ serviceLocator -> setFactory ( 'ServiceListener' , 'HumusMvc\Service\ServiceListenerFactory' ) ; } if ( ! $ serviceLocator -> has ( 'Zf1MvcListener' ) ) { $ serviceLocator -> setFactor... | Creates and returns the module manager |
237,160 | public function toArray ( $ ignoreEmpty = false ) { if ( ! $ ignoreEmpty ) { return $ this -> data ; } return array_filter ( $ this -> data , function ( $ value ) { return ! empty ( $ value ) ; } ) ; } | Extract data to an array |
237,161 | public function toString ( $ ignoreEmpty = false , $ numPrefix = null , $ separator = null ) { if ( empty ( $ separator ) ) { $ separator = '&' ; } return http_build_query ( $ this -> toArray ( $ ignoreEmpty ) , $ numPrefix , $ separator ) ; } | Extract data as a query string . |
237,162 | protected function fromArray ( $ data ) { if ( empty ( $ data ) ) { return $ this ; } $ this -> data = array_replace_recursive ( $ this -> data , $ data ) ; return $ this ; } | Set data from an array |
237,163 | protected function fromString ( $ queryString ) { if ( empty ( $ queryString ) ) { return $ this ; } $ data = array ( ) ; parse_str ( $ queryString , $ data ) ; $ this -> fromArray ( $ data ) ; return $ this ; } | Set data from a query string |
237,164 | private function getThemeAttributes ( ) { $ theme = Cii :: getConfig ( 'theme' , 'default' ) ; if ( ! file_exists ( Yii :: getPathOfAlias ( 'webroot.themes.' . $ theme ) . DIRECTORY_SEPARATOR . 'Theme.php' ) ) throw new CHttpException ( 400 , Yii :: t ( 'Api.setting' , 'The requested theme type is not set. Please set a... | Retrieves the appropriate model for the theme |
237,165 | private function loadData ( $ post , & $ model ) { $ model -> populate ( $ _POST , false ) ; if ( $ model -> save ( ) ) return $ this -> getModelAttributes ( $ model ) ; return $ this -> returnError ( 400 , NULL , $ model -> getErrors ( ) ) ; } | Populates and saves model attributes |
237,166 | private function getModelAttributes ( & $ model ) { $ response = array ( ) ; $ reflection = new ReflectionClass ( $ model ) ; $ properties = $ reflection -> getProperties ( ReflectionProperty :: IS_PROTECTED ) ; foreach ( $ properties as $ property ) $ response [ $ property -> name ] = $ model [ $ property -> name ] ; ... | Retrieves model attributes for a particular model |
237,167 | private function InitModule ( array $ idParts ) { if ( count ( $ idParts ) < 1 || count ( $ idParts ) > 2 ) { Response :: Redirect ( BackendRouter :: ModuleUrl ( new TemplateList ( ) ) ) ; } $ this -> module = ClassFinder :: CreateFrontendModule ( $ idParts [ 0 ] ) ; if ( ! $ this -> module instanceof FrontendModule ||... | Initializes the bundle and module names |
237,168 | protected function OnSuccess ( ) { $ newTemplate = $ this -> Value ( 'Name' ) ; $ action = Action :: Create ( ) ; if ( $ this -> template ) { $ action = Action :: Update ( ) ; $ this -> UpdateUsages ( $ newTemplate ) ; $ oldFile = $ this -> CalcFile ( $ this -> template ) ; if ( File :: Exists ( $ oldFile ) ) { File ::... | Saves the template into the given file name |
237,169 | public function getLocales ( ) { $ currentLocales = array ( ) ; foreach ( $ this -> localeCategories as $ category ) { if ( $ category === LC_ALL ) continue ; $ currentLocales [ $ category ] = setlocale ( $ category , 0 ) ; } return $ currentLocales ; } | Get all categories with its corresponding locale set |
237,170 | public function pad ( $ length = 0 , $ chars = ' ' , $ type = STR_PAD_BOTH ) { return new static ( str_pad ( $ this -> subject , $ length , $ chars , $ type ) ) ; } | Pad a string to a certain length with another string . |
237,171 | private function doRead ( string $ read , int $ length ) : string { if ( null === $ this -> handle ) { throw new \ LogicException ( 'Can not read from closed input stream.' ) ; } $ data = @ $ read ( $ this -> handle , $ length ) ; if ( false === $ data ) { $ error = lastErrorMessage ( 'unknown error' ) ; if ( ! @ feof ... | do actual read |
237,172 | public function bytesLeft ( ) : int { if ( null === $ this -> handle || ! is_resource ( $ this -> handle ) ) { throw new \ LogicException ( 'Can not read from closed input stream.' ) ; } $ bytesRead = ftell ( $ this -> handle ) ; if ( ! is_int ( $ bytesRead ) ) { return 0 ; } return $ this -> getResourceLength ( ) - $ ... | returns the amount of bytes left to be read |
237,173 | public function getUser ( $ id ) { $ request = $ this -> client -> get ( $ this -> customer [ 'url' ] . '/api/users/' . $ id ) ; $ request -> setAuth ( $ this -> customer [ 'username' ] , $ this -> customer [ 'password' ] ) ; $ response = $ request -> send ( ) ; return json_decode ( ( string ) $ response -> getBody ( t... | Get a specific user |
237,174 | public function patchUser ( $ id , array $ fields ) { $ request = $ this -> client -> patch ( $ this -> customer [ 'url' ] . '/api/users/' . $ id ) ; $ request -> setAuth ( $ this -> customer [ 'username' ] , $ this -> customer [ 'password' ] ) ; $ request -> setBody ( json_encode ( $ fields ) ) ; $ response = $ reques... | Edit an user fields . |
237,175 | public function setURLFromServerVars ( ) { if ( $ this -> server -> get ( 'REQUEST_SCHEME' ) ) { $ base = $ this -> server [ 'REQUEST_SCHEME' ] . '://' . $ this -> server [ 'SERVER_NAME' ] ; $ this -> url = new URL ( $ base . $ this -> server [ 'REQUEST_URI' ] ) ; $ this -> webroot = new URL ( $ base . rtrim ( dirname ... | Determine the webroot and the URL from server variables . Webroot is based on the location of the index . php that is executing which we consider to be the webroot . |
237,176 | public function startSession ( URL $ domain , Dictionary $ config ) { if ( $ this -> session === null ) { $ this -> session = new Session ( $ domain , $ config , $ this -> server ) ; $ this -> session -> start ( ) ; } return $ this ; } | Start the HTTP Session and initalize the session object |
237,177 | public function register ( FixtureLoader $ loader ) { $ value = new Pair ( $ loader -> getName ( ) , $ loader ) ; $ this -> loaders -> add ( $ value ) ; return $ this ; } | Register the loader of fixture |
237,178 | private static function getBasePath ( ) { if ( empty ( self :: $ basePath ) ) { self :: $ basePath = sprintf ( '%s%s%s' , sys_get_temp_dir ( ) , DIRECTORY_SEPARATOR , self :: BASE_PATH_NAME ) ; } return self :: $ basePath ; } | Get Base Path |
237,179 | private static function getWorkbenchPath ( ) { if ( empty ( self :: $ workbenchPath ) ) { self :: $ workbenchPath = sprintf ( '%s%s%s%s' , self :: getBasePath ( ) , DIRECTORY_SEPARATOR , time ( ) , rand ( 100 , 999 ) ) ; } return self :: $ workbenchPath ; } | Get Workbench Path |
237,180 | protected function getGenericDatabases ( array $ databases ) { $ genericDatabases = array ( ) ; foreach ( $ databases as $ database ) { $ genericDatabases [ ] = $ this -> getGenericDatabase ( $ database ) ; } return $ genericDatabases ; } | Gets the generic databases . |
237,181 | protected function getGenericSequences ( array $ sequences ) { $ genericSequences = array ( ) ; foreach ( $ sequences as $ sequence ) { $ genericSequences [ ] = $ this -> getGenericSequence ( $ sequence ) ; } return $ genericSequences ; } | Gets the generic sequences . |
237,182 | protected function getGenericSequence ( $ sequence ) { $ name = $ sequence [ 'name' ] ; $ initialValue = ( int ) $ sequence [ 'initial_value' ] ; $ incrementSize = ( int ) $ sequence [ 'increment_size' ] ; return new Sequence ( $ name , $ initialValue , $ incrementSize ) ; } | Gets the generic sequence . |
237,183 | protected function getGenericViews ( array $ views ) { $ genericViews = array ( ) ; foreach ( $ views as $ view ) { $ genericViews [ ] = $ this -> getGenericView ( $ view ) ; } return $ genericViews ; } | Gets the generic views . |
237,184 | protected function getGenericTableNames ( array $ tableNames ) { $ genericTableNames = array ( ) ; foreach ( $ tableNames as $ tableName ) { $ genericTableNames [ ] = $ this -> getGenericTableName ( $ tableName ) ; } return $ genericTableNames ; } | Gets the generic table names . |
237,185 | protected function getGenericColumns ( array $ columns ) { $ genericColumns = array ( ) ; foreach ( $ columns as $ column ) { $ genericColumns [ ] = $ this -> getGenericColumn ( $ column ) ; } return $ genericColumns ; } | Gets the generic table columns . |
237,186 | protected function getGenericColumn ( array $ column ) { $ name = $ column [ 'name' ] ; list ( $ column [ 'comment' ] , $ typeName ) = $ this -> extractTypeFromComment ( $ column [ 'comment' ] ) ; if ( $ typeName === null ) { $ typeName = $ this -> getConnection ( ) -> getPlatform ( ) -> getMappedType ( $ column [ 'typ... | Gets the generic table column . |
237,187 | protected function getGenericPrimaryKey ( array $ primaryKey ) { $ genericPrimaryKey = new PrimaryKey ( $ primaryKey [ 0 ] [ 'name' ] ) ; foreach ( $ primaryKey as $ primaryKeyColumn ) { $ genericPrimaryKey -> addColumnName ( $ primaryKeyColumn [ 'column_name' ] ) ; } return $ genericPrimaryKey ; } | Gets the generic table primary key . |
237,188 | protected function getGenericForeignKeys ( array $ foreignKeys ) { $ genericForeignKeys = array ( ) ; foreach ( $ foreignKeys as $ foreignKey ) { $ name = $ foreignKey [ 'name' ] ; if ( ! isset ( $ genericForeignKeys [ $ name ] ) ) { $ genericForeignKeys [ $ name ] = new ForeignKey ( $ foreignKey [ 'name' ] , array ( $... | Gets the generic table foreign keys . |
237,189 | protected function getGenericIndexes ( array $ indexes ) { $ genericIndexes = array ( ) ; foreach ( $ indexes as $ index ) { $ name = $ index [ 'name' ] ; if ( ! isset ( $ genericIndexes [ $ name ] ) ) { $ genericIndexes [ $ name ] = new Index ( $ name , array ( $ index [ 'column_name' ] ) , ( bool ) $ index [ 'unique'... | Gets the generic table indexes . |
237,190 | protected function getGenericChecks ( array $ checks ) { $ genericChecks = array ( ) ; foreach ( $ checks as $ check ) { $ genericChecks [ ] = new Check ( $ check [ 'name' ] , $ check [ 'definition' ] ) ; } return $ genericChecks ; } | Gets the generic table checks . |
237,191 | protected function extractTypeFromComment ( $ comment ) { if ( preg_match ( '/^(.*)\(FridgeType::([a-zA-Z0-9]+)\)$/' , $ comment , $ matches ) ) { if ( empty ( $ matches [ 1 ] ) ) { $ matches [ 1 ] = null ; } return array ( $ matches [ 1 ] , strtolower ( $ matches [ 2 ] ) ) ; } return array ( $ comment , null ) ; } | Extracts the type from the comment if it exists . |
237,192 | protected function tryMethod ( $ method , array $ arguments = array ( ) ) { try { call_user_func_array ( array ( $ this , $ method ) , $ arguments ) ; return true ; } catch ( \ Exception $ e ) { return false ; } } | Tries to execute a method . |
237,193 | protected function restoreState ( array $ data ) { if ( isset ( $ data [ 'status' ] ) ) { $ this -> status = array_merge ( $ this -> status , $ data [ 'status' ] ) ; } if ( isset ( $ data [ 'jobUuid' ] ) ) { $ this -> jobUuid = $ data [ 'jobUuid' ] ; $ this -> logContext [ 'jobUuid' ] = $ data [ 'jobUuid' ] ; } else { ... | Restore state of task from data supplied by command |
237,194 | public function onKernelResponse ( FilterResponseEvent $ event ) { $ locale = $ this -> localeProvider -> determinePreferredLocale ( ) ; if ( empty ( $ locale ) ) { return ; } $ requestCookie = $ this -> cookieHelper -> read ( $ event -> getRequest ( ) ) ; if ( $ requestCookie && $ requestCookie -> getValue ( ) === $ l... | If there is a logged in user with a preferred language set it as a cookie . |
237,195 | public function beforeAuthenticate ( \ Magento \ Customer \ Model \ AccountManagement $ subject , $ username , $ password ) { try { $ mlmId = trim ( $ username ) ; $ found = $ this -> daoDwnlCust -> getByMlmId ( $ mlmId ) ; if ( $ found ) { $ custId = $ found -> getCustomerRef ( ) ; $ customer = $ this -> daoCust -> ge... | Look up for customer s email by MLM ID on authentication . |
237,196 | public function beforeCreateAccount ( \ Magento \ Customer \ Model \ AccountManagement $ subject , \ Magento \ Customer \ Api \ Data \ CustomerInterface $ customer , $ password = null , $ redirectUrl = '' ) { $ addrs = $ customer -> getAddresses ( ) ; if ( is_array ( $ addrs ) ) { foreach ( $ addrs as $ addr ) { $ coun... | Extract country code and save into Magento registry when customer is created through adminhtml . |
237,197 | public static function formatAsMoney ( $ value , $ currencySymbol = "£" , $ roundToInteger = false ) { if ( is_numeric ( $ value ) ) return $ currencySymbol . number_format ( $ value , $ roundToInteger ? 0 : 2 , "." , "" ) ; else return null ; } | Convenience function for formatting a number as money using the supplied currency symbol |
237,198 | public function setCreatedResourceLink ( TimelineLinkEvent $ event ) : void { $ action = $ event -> getAction ( ) ; if ( 'created_resource' != $ action -> getVerb ( ) ) { return ; } $ production = $ action -> getComponent ( 'indirectComplement' ) -> getData ( ) ; $ resource = $ action -> getComponent ( 'directComplemen... | Set the link for the created resource . |
237,199 | private function setTableCell ( $ aElements , $ features = null ) { $ sReturn = null ; foreach ( $ aElements as $ key => $ value ) { $ value = str_replace ( [ '& ' , '\"' , "\'" ] , [ '& ' , '"' , "'" ] , $ value ) ; if ( ( isset ( $ features [ 'grouping_cell' ] ) ) && ( $ features [ 'grouping_cell' ] == $ key ) ) ... | Generates a table cell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.