idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
36,300 | public function get ( $ key ) { $ key = $ this -> getScalarKey ( $ key ) ; if ( isset ( $ this -> list [ $ key ] ) ) { return $ this -> list [ $ key ] -> value ; } throw new \ OutOfBoundsException ( 'The key ' . $ key . ' is not existed.' ) ; } | Get item from map |
36,301 | public function has ( $ key ) { $ key = $ this -> getScalarKey ( $ key ) ; return isset ( $ this -> list [ $ key ] ) ; } | Check if item in map |
36,302 | private function ascSortStrategy ( $ declaration1 , $ declaration2 ) { if ( $ declaration1 -> priority === $ declaration2 -> priority ) { return $ declaration1 -> sequence < $ declaration2 -> sequence ? 1 : - 1 ; } return $ declaration1 -> priority > $ declaration2 -> priority ? 1 : - 1 ; } | ASC sort strategy |
36,303 | private function descSortStrategy ( $ declaration1 , $ declaration2 ) { if ( $ declaration1 -> priority === $ declaration2 -> priority ) { return $ declaration1 -> sequence < $ declaration2 -> sequence ? 1 : - 1 ; } return $ declaration1 -> priority < $ declaration2 -> priority ? 1 : - 1 ; } | DESC sort strategy |
36,304 | protected function getStatus ( ) { if ( $ this -> detail instanceof \ Throwable ) { $ this -> status = $ this -> createStatusFromException ( ) ; } return $ this -> status ; } | Retrieve the API - Problem HTTP status code |
36,305 | protected function getTitle ( ) { if ( null !== $ this -> title ) { return $ this -> title ; } if ( null === $ this -> title && $ this -> type == 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html' && array_key_exists ( $ this -> getStatus ( ) , $ this -> problemStatusTitles ) ) { return $ this -> problemStatusTitles [ $ this -> status ] ; } if ( $ this -> detail instanceof \ Throwable ) { return get_class ( $ this -> detail ) ; } if ( null === $ this -> title ) { return 'Unknown' ; } return $ this -> title ; } | Retrieve the title |
36,306 | protected function createDetailFromException ( ) { $ e = $ this -> detail ; if ( ! $ this -> detailIncludesStackTrace ) { return $ this -> getExceptionMessage ( $ e ) ; } $ message = $ this -> getExceptionMessage ( $ e ) ; $ this -> additionalDetails [ 'trace' ] = $ e -> getTrace ( ) ; $ previous = [ ] ; $ e = $ e -> getPrevious ( ) ; while ( $ e ) { $ previous [ ] = [ 'code' => ( int ) $ e -> getCode ( ) , 'message' => $ this -> getExceptionMessage ( $ e ) , 'trace' => $ e -> getTrace ( ) , ] ; $ e = $ e -> getPrevious ( ) ; } if ( count ( $ previous ) ) { $ this -> additionalDetails [ 'exception_stack' ] = $ previous ; } return $ message ; } | Create detail message from an exception . |
36,307 | protected function createStatusFromException ( ) { $ e = $ this -> detail ; $ status = $ e -> getCode ( ) ; if ( empty ( $ status ) || ( $ status < 100 ) || ( $ status > 599 ) ) { return 500 ; } return $ status ; } | Create HTTP status from an exception . |
36,308 | public function formField ( $ kwargs = [ ] ) { $ fieldClass = ArrayHelper :: pop ( $ kwargs , 'fieldClass' , \ Eddmash \ PowerOrm \ Form \ Fields \ CharField :: class ) ; $ defaults = [ 'required' => ! $ this -> formBlank , 'label' => $ this -> verboseName , 'helpText' => $ this -> helpText , ] ; if ( $ this -> hasDefault ( ) ) { $ defaults [ 'initial' ] = $ this -> getDefault ( ) ; } if ( $ this -> choices ) { $ include_blank = true ; if ( $ this -> formBlank || empty ( $ this -> hasDefault ( ) ) || ! in_array ( 'initial' , $ kwargs ) ) { $ include_blank = false ; } $ defaults [ 'choices' ] = $ this -> getChoices ( [ 'include_blank' => $ include_blank ] ) ; $ defaults [ 'coerce' ] = [ $ this , 'toPhp' ] ; $ fieldClass = ArrayHelper :: getValue ( $ kwargs , 'formChoicesClass' , TypedChoiceField :: class ) ; } $ defaults = array_merge ( $ defaults , $ kwargs ) ; return $ fieldClass :: instance ( $ defaults ) ; } | Returns an Eddmash \ PowerOrm \ Form \ Fields \ Field instance that represents this database field . |
36,309 | public function validate ( Model $ model , $ value ) { if ( ! empty ( $ this -> choices ) && ! empty ( $ value ) ) { foreach ( $ this -> choices as $ key => $ choice ) { if ( is_array ( $ choice ) ) { foreach ( $ choice as $ inkey => $ inchoice ) { if ( $ value === $ inchoice ) { return ; } } } else { if ( $ value === $ choice ) { return ; } } } throw new ValidationError ( sprintf ( 'Value %s is not a valid choice.' , $ value ) , 'invalid_choice' ) ; } if ( is_null ( $ value ) && ! $ this -> isNull ( ) ) { throw new ValidationError ( 'This field cannot be null.' , 'null' ) ; } if ( empty ( $ value ) && ! $ this -> formBlank ) { throw new ValidationError ( 'This field cannot be blank.' , 'blank' ) ; } } | Validates value and throws ValidationError . Subclasses should override this to provide validation logic . |
36,310 | public function runValidators ( $ value ) { if ( empty ( $ value ) ) { return ; } $ validationErrors = [ ] ; foreach ( $ this -> getFieldValidators ( ) as $ validator ) { try { $ validator ( $ value ) ; } catch ( ValidationError $ error ) { $ validationErrors = array_merge ( $ validationErrors , $ error -> getErrorList ( ) ) ; } } if ( ! empty ( $ validationErrors ) ) { throw new ValidationError ( $ validationErrors ) ; } } | Passes the value through all the validators for this field . |
36,311 | protected function soapClient ( array $ classMap , $ parameters = array ( ) ) { $ endpoint = $ this -> client -> getEndpoint ( ) ; if ( $ this -> soapClient === null ) { $ extensions = get_loaded_extensions ( ) ; $ errors = array ( ) ; if ( ! class_exists ( 'SoapClient' ) || ! in_array ( 'soap' , $ extensions ) ) { $ errors [ ] = 'The PHP SOAP extension doesn\'t seem to be installed. You need to install the PHP SOAP extension. (See: http://www.php.net/manual/en/book.soap.php)' ; } if ( ! in_array ( 'openssl' , $ extensions ) ) { $ errors [ ] = 'The PHP OpenSSL extension doesn\'t seem to be installed. You need to install PHP with the OpenSSL extension. (See: http://www.php.net/manual/en/book.openssl.php)' ; } if ( ! empty ( $ errors ) ) { die ( '<p>' . implode ( "</p>\n<p>" , $ errors ) . '</p>' ) ; } $ options = array ( 'classmap' => $ classMap , 'encoding' => 'utf-8' , 'features' => SOAP_SINGLE_ELEMENT_ARRAYS , 'trace' => false , ) ; $ wsdlUri = "https://{$endpoint}/wsdl/?service=" . $ this -> service ; try { $ this -> soapClient = new \ SoapClient ( $ wsdlUri , $ options ) ; } catch ( \ SoapFault $ sf ) { throw new \ Exception ( "Unable to connect to endpoint '{$endpoint}'" ) ; } $ this -> soapClient -> __setCookie ( 'login' , $ this -> client -> getLogin ( ) ) ; $ this -> soapClient -> __setCookie ( 'mode' , $ this -> client -> getMode ( ) ) ; } $ timestamp = time ( ) ; $ nonce = uniqid ( '' , true ) ; $ this -> soapClient -> __setCookie ( 'timestamp' , $ timestamp ) ; $ this -> soapClient -> __setCookie ( 'nonce' , $ nonce ) ; $ this -> soapClient -> __setCookie ( 'clientVersion' , $ this -> apiVersion ) ; $ this -> soapClient -> __setCookie ( 'signature' , $ this -> _urlencode ( $ this -> _sign ( array_merge ( $ parameters , array ( '__service' => $ this -> service , '__hostname' => $ endpoint , '__timestamp' => $ timestamp , '__nonce' => $ nonce ) ) ) ) ) ; return $ this -> soapClient ; } | Gets the singleton SoapClient which is used to connect to the TransIP Api . |
36,312 | protected function _sign ( $ parameters ) { if ( ! preg_match ( '/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si' , $ this -> client -> getPrivateKey ( ) , $ matches ) ) { die ( '<p>Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.</p>' ) ; } $ key = $ matches [ 2 ] ; $ key = preg_replace ( '/\s*/s' , '' , $ key ) ; $ key = chunk_split ( $ key , 64 , "\n" ) ; $ key = "-----BEGIN PRIVATE KEY-----\n" . $ key . "-----END PRIVATE KEY-----" ; $ digest = $ this -> _sha512Asn1 ( $ this -> _encodeParameters ( $ parameters ) ) ; if ( ! @ openssl_private_encrypt ( $ digest , $ signature , $ key ) ) { die ( '<p>Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.</p>' ) ; } return base64_encode ( $ signature ) ; } | Calculates the hash to sign our request with based on the given parameters . |
36,313 | public function make ( $ controller , $ path , array $ options = array ( ) ) { $ stub = $ this -> addMethods ( $ this -> getController ( $ controller ) , $ options ) ; $ this -> writeFile ( $ stub , $ controller , $ path ) ; return false ; } | Create a new resourceful controller file . |
36,314 | protected function writeFile ( $ stub , $ controller , $ path ) { if ( str_contains ( $ controller , '\\' ) ) { $ this -> makeDirectory ( $ controller , $ path ) ; } $ controller = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ controller ) ; if ( ! $ this -> files -> exists ( $ fullPath = $ path . "/{$controller}.php" ) ) { return $ this -> files -> put ( $ fullPath , $ stub ) ; } } | Write the completed stub to disk . |
36,315 | protected function makeDirectory ( $ controller , $ path ) { $ directory = $ this -> getDirectory ( $ controller ) ; if ( ! $ this -> files -> isDirectory ( $ full = $ path . '/' . $ directory ) ) { $ this -> files -> makeDirectory ( $ full , 0777 , true ) ; } } | Create the directory for the controller . |
36,316 | protected function getController ( $ controller ) { $ stub = $ this -> files -> get ( __DIR__ . '/stubs/controller.stub' ) ; $ segments = explode ( '\\' , $ controller ) ; $ stub = $ this -> replaceNamespace ( $ segments , $ stub ) ; return str_replace ( '{{class}}' , last ( $ segments ) , $ stub ) ; } | Get the controller class stub . |
36,317 | protected function replaceNamespace ( array $ segments , $ stub ) { if ( count ( $ segments ) > 1 ) { $ namespace = implode ( '\\' , array_slice ( $ segments , 0 , - 1 ) ) ; return str_replace ( '{{namespace}}' , ' namespace ' . $ namespace . ';' , $ stub ) ; } else { return str_replace ( '{{namespace}}' , '' , $ stub ) ; } } | Replace the namespace on the controller . |
36,318 | protected function addMethods ( $ stub , array $ options ) { $ stubs = $ this -> getMethodStubs ( $ options ) ; $ methods = implode ( PHP_EOL . PHP_EOL , $ stubs ) ; return str_replace ( '{{methods}}' , $ methods , $ stub ) ; } | Add the method stubs to the controller . |
36,319 | protected function getMethodStubs ( $ options ) { $ stubs = array ( ) ; foreach ( $ this -> getMethods ( $ options ) as $ method ) { $ stubs [ ] = $ this -> files -> get ( __DIR__ . "/stubs/{$method}.stub" ) ; } return $ stubs ; } | Get all of the method stubs for the given options . |
36,320 | protected function getMethods ( $ options ) { if ( isset ( $ options [ 'only' ] ) && count ( $ options [ 'only' ] ) > 0 ) { return $ options [ 'only' ] ; } elseif ( isset ( $ options [ 'except' ] ) && count ( $ options [ 'except' ] ) > 0 ) { return array_diff ( $ this -> defaults , $ options [ 'except' ] ) ; } return $ this -> defaults ; } | Get the applicable methods based on the options . |
36,321 | public function register ( Container $ app ) { $ app [ "serializer.namingStrategy" ] = "CamelCase" ; $ app [ "serializer.namingStrategy.separator" ] = "_" ; $ app [ "serializer.namingStrategy.lowerCase" ] = true ; $ app [ "serializer.propertyNamingStrategy" ] = new PropertyNamingStrategyService ( ) ; $ app [ "serializer.builder" ] = new BuilderService ( ) ; $ app [ "serializer" ] = function ( Container $ app ) { return $ app [ "serializer.builder" ] -> build ( ) ; } ; } | Register the serializer and serializer . builder services |
36,322 | public function index ( BlogRequest $ request ) { $ view = $ this -> response -> theme -> listView ( ) ; if ( $ this -> response -> typeIs ( 'json' ) ) { $ function = camel_case ( 'get-' . $ view ) ; return $ this -> repository -> setPresenter ( \ Litecms \ Blog \ Repositories \ Presenter \ BlogPresenter :: class ) -> $ function ( ) ; } $ blogs = $ this -> repository -> paginate ( ) ; return $ this -> response -> title ( trans ( 'blog::blog.names' ) ) -> view ( 'blog::blog.index' , true ) -> data ( compact ( 'blogs' ) ) -> output ( ) ; } | Display a list of blog . |
36,323 | public function show ( BlogRequest $ request , Blog $ blog ) { if ( $ blog -> exists ) { $ view = 'blog::blog.show' ; } else { $ view = 'blog::blog.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'blog::blog.name' ) ) -> data ( compact ( 'blog' ) ) -> view ( $ view , true ) -> output ( ) ; } | Display blog . |
36,324 | public function edit ( BlogRequest $ request , Blog $ blog ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'blog::blog.name' ) ) -> view ( 'blog::blog.edit' , true ) -> data ( compact ( 'blog' ) ) -> output ( ) ; } | Show blog for editing . |
36,325 | public function update ( BlogRequest $ request , Blog $ blog ) { try { $ attributes = $ request -> all ( ) ; $ blog -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'blog::blog.name' ) ] ) ) -> code ( 204 ) -> status ( 'success' ) -> url ( guard_url ( 'blog/blog/' . $ blog -> getRouteKey ( ) ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'blog/blog/' . $ blog -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Update the blog . |
36,326 | public function destroy ( BlogRequest $ request , Blog $ blog ) { try { $ blog -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'blog::blog.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'blog/blog/0' ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'blog/blog/' . $ blog -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Remove the blog . |
36,327 | protected function getAdminsRoleEntity ( Table $ table ) : ? EntityInterface { $ result = $ table -> find ( ) -> enableHydration ( true ) -> where ( [ 'name' => $ this -> role ] ) -> first ( ) ; Assert :: nullOrIsInstanceOf ( $ result , EntityInterface :: class ) ; return $ result ; } | Get Admins role with its capabilities . |
36,328 | protected function getAllCapabilities ( RolesTable $ table ) : array { $ result = [ ] ; $ allCapabilities = Utils :: getAllCapabilities ( ) ; if ( empty ( $ allCapabilities ) ) { $ this -> abort ( 'No capabilities at all found in the system!' ) ; } foreach ( $ allCapabilities as $ groupName => $ groupCaps ) { if ( empty ( $ groupCaps ) ) { continue ; } foreach ( $ groupCaps as $ type => $ caps ) { foreach ( $ caps as $ cap ) { $ result = array_merge ( $ result , [ $ cap -> getName ( ) ] ) ; } } } $ result = array_fill_keys ( $ result , '1' ) ; $ result = $ table -> prepareCapabilities ( $ result ) ; if ( empty ( $ result ) ) { $ this -> abort ( 'No capabilities found in the system!' ) ; } return $ result ; } | Get all capabilities . |
36,329 | public static function initClientScript ( $ view , $ method = self :: METHOD_POLL ) { $ asset = NfyAsset :: register ( $ view ) ; return $ asset -> baseUrl ; } | Registers required JS libraries and CSS files . |
36,330 | public function getContentItemArray ( ) { return [ 'content' => $ this -> content , 'id' => $ this -> id , 'created' => $ this -> created , 'updated' => $ this -> updated , 'contenttype' => $ this -> contenttype , 'language' => $ this -> language , 'parentid' => $ this -> parentid , 'reply' => $ this -> reply , 'forward' => $ this -> forward , ] ; } | Returns an representation of the content item |
36,331 | public function matchCategory ( $ category ) { $ result = empty ( $ this -> categories ) ; foreach ( $ this -> categories as $ allowedCategory ) { if ( $ this -> categoryContains ( $ allowedCategory , $ category ) ) { $ result = true ; } } foreach ( $ this -> exceptions as $ deniedCategory ) { if ( $ this -> categoryContains ( $ deniedCategory , $ category ) ) { $ result = false ; } } return $ result ; } | Tests if specified category matches any category and doesn t match any exception of this subscription . |
36,332 | function set_theme_option ( ) { $ optionsframework_settings = get_option ( 'optionsframework' ) ; if ( function_exists ( 'optionsframework_option_name' ) ) { optionsframework_option_name ( ) ; } elseif ( has_action ( 'optionsframework_option_name' ) ) { do_action ( 'optionsframework_option_name' ) ; } else { $ default_themename = get_option ( 'stylesheet' ) ; $ default_themename = preg_replace ( "/\W/" , "_" , strtolower ( $ default_themename ) ) ; $ default_themename = 'optionsframework_' . $ default_themename ; if ( isset ( $ optionsframework_settings [ 'id' ] ) ) { if ( $ optionsframework_settings [ 'id' ] == $ default_themename ) { } else { $ optionsframework_settings [ 'id' ] = $ default_themename ; update_option ( 'optionsframework' , $ optionsframework_settings ) ; } } else { $ optionsframework_settings [ 'id' ] = $ default_themename ; update_option ( 'optionsframework' , $ optionsframework_settings ) ; } } } | Sets option defaults |
36,333 | public function guessCommandName ( ) { $ prefix = $ this -> makePrefix ( ) ; if ( $ prefix ) { $ prefix = sprintf ( '%s:' , $ prefix ) ; } return sprintf ( '%s%s' , $ prefix , $ this -> makeName ( ) ) ; } | Returns the name of the current class in lower case and strips off the Command . |
36,334 | public function getKeywords ( ) { $ return = array ( ) ; $ keywords = $ this -> entry -> get_categories ( ) ; if ( is_array ( $ keywords ) && count ( $ keywords ) > 0 ) { foreach ( $ keywords as $ keyword ) { $ return [ ] = $ this -> decodeString ( $ keyword -> get_label ( ) ) ; } } return $ return ; } | Get categories as keywords |
36,335 | public static function verify ( $ password , $ hash ) { if ( $ password === $ hash ) { return true ; } if ( APR1 :: verify ( $ password , $ hash ) ) { return true ; } if ( $ hash === self :: sha1 ( $ password ) ) { return true ; } if ( self :: cryptVerify ( $ password , $ hash ) ) { return true ; } if ( substr ( $ hash , 0 , 2 ) === '$2' ) { if ( BCrypt :: verify ( $ password , $ hash ) ) { return true ; } } return false ; } | Checks if a password matches a hash |
36,336 | public static function cryptVerify ( $ password , $ hash ) { $ salt = substr ( $ hash , 0 , 2 ) ; try { $ actual = crypt ( $ password , $ salt ) ; } catch ( \ Exception $ e ) { return false ; } return ( $ actual === $ hash ) ; } | Verifies a hash of CRYPT algorithm |
36,337 | public static function cryptHash ( $ password ) { $ salt = substr ( base64_encode ( chr ( mt_rand ( 0 , 255 ) ) ) , 0 , 2 ) ; $ salt = str_replace ( '+' , '.' , $ salt ) ; return crypt ( $ password , $ salt ) ; } | Hash a password using CRYPT algorithm |
36,338 | protected function checkValue ( $ multipleUploads ) { if ( $ this -> getRequired ( ) && ! $ multipleUploads && ( is_null ( $ this -> value ) || $ this -> value == '' ) ) { $ this -> error = $ this -> getLabel ( ) . ' is required.' ; return false ; } if ( $ this -> getPattern ( ) && ! preg_match ( '/' . $ this -> getPattern ( ) . '/' , $ this -> value ) ) { $ this -> error = 'Invalid value entered.' ; return false ; } return true ; } | Check whether the correct value has been entered based on multiple or single upload |
36,339 | protected function callValidator ( $ validator ) { if ( is_callable ( $ validator ) ) { try { call_user_func_array ( $ validator , array ( $ this -> value ) ) ; } catch ( \ Exception $ ex ) { $ this -> error = $ ex -> getMessage ( ) ; return false ; } } } | Call the custom validator |
36,340 | public static function sendPost ( $ url , array $ data , $ client_ip = '' ) { $ ch = curl_init ( ) ; $ params = http_build_query ( $ data ) ; $ opt = [ CURLOPT_URL => $ url , CURLOPT_POST => 1 , CURLOPT_POSTFIELDS => $ params , CURLOPT_RETURNTRANSFER => 1 , ] ; if ( $ client_ip ) { $ opt [ CURLOPT_HTTPHEADER ] = [ "CLIENT-IP: {$client_ip}" , "X-FORWARDED-FOR: {$client_ip}" ] ; } curl_setopt_array ( $ ch , $ opt ) ; $ json = curl_exec ( $ ch ) ; return $ json ; } | Curl post . |
36,341 | public static function sendRequest ( $ url , $ options ) { $ context = stream_context_create ( $ options ) ; $ result = file_get_contents ( $ url , false , $ context ) ; return $ result ; } | Send request and fetch page . |
36,342 | public static function isMobileRequest ( ) { $ _SERVER [ 'ALL_HTTP' ] = isset ( $ _SERVER [ 'ALL_HTTP' ] ) ? $ _SERVER [ 'ALL_HTTP' ] : '' ; $ mobile_browser = '0' ; if ( preg_match ( '/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i' , strtolower ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ) ) $ mobile_browser ++ ; if ( ( isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ) and ( strpos ( strtolower ( $ _SERVER [ 'HTTP_ACCEPT' ] ) , 'application/vnd.wap.xhtml+xml' ) !== false ) ) $ mobile_browser ++ ; if ( isset ( $ _SERVER [ 'HTTP_X_WAP_PROFILE' ] ) ) $ mobile_browser ++ ; if ( isset ( $ _SERVER [ 'HTTP_PROFILE' ] ) ) $ mobile_browser ++ ; $ mobile_ua = strtolower ( substr ( $ _SERVER [ 'HTTP_USER_AGENT' ] , 0 , 4 ) ) ; $ mobile_agents = array ( 'w3c ' , 'acs-' , 'alav' , 'alca' , 'amoi' , 'audi' , 'avan' , 'benq' , 'bird' , 'blac' , 'blaz' , 'brew' , 'cell' , 'cldc' , 'cmd-' , 'dang' , 'doco' , 'eric' , 'hipt' , 'inno' , 'ipaq' , 'java' , 'jigs' , 'kddi' , 'keji' , 'leno' , 'lg-c' , 'lg-d' , 'lg-g' , 'lge-' , 'maui' , 'maxo' , 'midp' , 'mits' , 'mmef' , 'mobi' , 'mot-' , 'moto' , 'mwbp' , 'nec-' , 'newt' , 'noki' , 'oper' , 'palm' , 'pana' , 'pant' , 'phil' , 'play' , 'port' , 'prox' , 'qwap' , 'sage' , 'sams' , 'sany' , 'sch-' , 'sec-' , 'send' , 'seri' , 'sgh-' , 'shar' , 'sie-' , 'siem' , 'smal' , 'smar' , 'sony' , 'sph-' , 'symb' , 't-mo' , 'teli' , 'tim-' , 'tosh' , 'tsm-' , 'upg1' , 'upsi' , 'vk-v' , 'voda' , 'wap-' , 'wapa' , 'wapi' , 'wapp' , 'wapr' , 'webc' , 'winw' , 'winw' , 'xda' , 'xda-' ) ; if ( in_array ( $ mobile_ua , $ mobile_agents ) ) $ mobile_browser ++ ; if ( strpos ( strtolower ( $ _SERVER [ 'ALL_HTTP' ] ) , 'operamini' ) !== false ) $ mobile_browser ++ ; if ( strpos ( strtolower ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) , 'windows' ) !== false ) $ mobile_browser = 0 ; if ( strpos ( strtolower ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) , 'windows phone' ) !== false ) $ mobile_browser ++ ; if ( $ mobile_browser > 0 ) return true ; else return false ; } | Is Wap . |
36,343 | private function getUpdateData ( InputInterface $ input ) { $ update_data = $ input -> getOption ( 'update-data' ) ; if ( empty ( $ update_data ) ) { return null ; } if ( mb_substr ( $ update_data , 0 , 1 ) == '{' && mb_substr ( $ update_data , mb_strlen ( $ update_data ) - 1 ) == '}' ) { $ update_data = json_decode ( $ update_data , true ) ; if ( json_last_error ( ) ) { $ error_message = 'Failed to parse JSON' ; if ( function_exists ( 'json_last_error_msg' ) ) { $ error_message .= '. Reason: ' . json_last_error_msg ( ) ; } throw new InvalidArgumentException ( 'Failed to parse updata data value. Error: ' . $ error_message ) ; } return $ update_data ; } else { throw new InvalidArgumentException ( "Invalid JSON: '$update_data'" ) ; } } | Get update data values . |
36,344 | public function getContent ( AppInterface $ app ) { $ imports = [ ] ; $ stringedOperations = [ ] ; foreach ( $ this -> migration -> getOperations ( ) as $ op ) { list ( $ opString , $ importString ) = FormatFileContent :: formatObject ( $ op ) ; array_push ( $ stringedOperations , $ opString ) ; $ imports = array_merge ( $ imports , $ importString ) ; } $ imports = array_unique ( $ imports ) ; $ importPaths = '' ; foreach ( $ imports as $ import ) { $ import = sprintf ( 'use %s;' , $ import ) ; $ importPaths .= $ import . PHP_EOL ; } $ opContent = '[' . PHP_EOL ; foreach ( $ stringedOperations as $ op ) { $ opContent .= sprintf ( "\t\t\t%s," . PHP_EOL , $ op ) ; } $ opContent .= "\t\t]" ; $ dependencies = $ this -> migration -> getDependency ( ) ; $ namespace = $ this -> migration -> getNamespace ( $ app ) ; return sprintf ( $ this -> getFileTemplate ( ) , $ namespace , $ importPaths , $ this -> migration -> getName ( ) , "\n" . rtrim ( Tools :: stringify ( $ dependencies , 3 , 0 , true , false ) , PHP_EOL ) , $ opContent ) ; } | Converts migration object into a string and adds it to the migration file template ready to be written on disk . |
36,345 | private function getFileTemplate ( ) { $ content = FormatFileContent :: createObject ( ) ; $ content -> addItem ( '<?php' ) ; $ content -> addItem ( sprintf ( '/**Migration file generated at %s on %s by PowerOrm(%s)*/' , date ( 'h:m:i' ) , date ( 'D, jS F Y' ) , POWERORM_VERSION ) . PHP_EOL ) ; $ content -> addItem ( 'namespace %s;' . PHP_EOL ) ; $ content -> addItem ( 'use Eddmash\\PowerOrm\\Migration\\Migration;' ) ; $ content -> addItem ( '%s' ) ; $ content -> addItem ( 'class %s extends Migration{' . PHP_EOL ) ; $ content -> addIndent ( ) ; $ content -> addItem ( 'public function getDependency(){' ) ; $ content -> addIndent ( ) ; $ content -> addItem ( 'return [' ) ; $ content -> addItem ( '%s' ) ; $ content -> addItem ( '];' ) ; $ content -> reduceIndent ( ) ; $ content -> addItem ( '}' . PHP_EOL ) ; $ content -> addItem ( 'public function getOperations(){' ) ; $ content -> addIndent ( ) ; $ content -> addItem ( 'return %s ;' ) ; $ content -> reduceIndent ( ) ; $ content -> addItem ( '}' . PHP_EOL ) ; $ content -> reduceIndent ( ) ; $ content -> addItem ( '}' ) ; return $ content ; } | Creates the template for the migration file . |
36,346 | protected function getModel ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> models ) ) { list ( $ namespace , $ key ) = $ this -> splitNamespaceAndKey ( $ key ) ; $ this -> models [ $ key ] = Config :: query ( ) -> where ( Config :: FIELD_NAMESPACE , $ namespace ) -> where ( Config :: FIELD_KEY , $ key ) -> first ( ) ; if ( $ this -> models [ $ key ] !== null ) { $ this -> cache -> forever ( $ key , $ this -> models [ $ key ] -> value ) ; } } return $ this -> models [ $ key ] ; } | Get config model by key |
36,347 | protected function generateView ( $ view , $ path ) { $ this -> call ( 'generate:view' , array ( 'name' => $ view , '--path' => $ path , '--template' => $ this -> getViewTemplatePath ( $ view ) ) ) ; } | Generate a view |
36,348 | protected function generateController ( ) { $ controller = $ this -> input -> getArgument ( 'name' ) ; $ path = $ this -> getPath ( ) ; $ options = $ this -> getBuildOptions ( ) ; $ this -> generator -> make ( $ controller , $ path , $ options ) ; $ this -> info ( 'Controller created successfully!' ) ; } | Generate a new resourceful controller file . |
36,349 | protected function getPath ( ) { if ( ! is_null ( $ this -> input -> getOption ( 'path' ) ) ) { return $ this -> flyphp [ 'path.base' ] . '/' . $ this -> input -> getOption ( 'path' ) ; } elseif ( $ bench = $ this -> input -> getOption ( 'bench' ) ) { return $ this -> getWorkbenchPath ( $ bench ) ; } return $ this -> path ; } | Get the path in which to store the controller . |
36,350 | protected function getWorkbenchPath ( $ bench ) { $ path = $ this -> flyphp [ 'path.base' ] . '/workbench/' . $ bench . '/src/controllers' ; if ( ! $ this -> flyphp [ 'files' ] -> isDirectory ( $ path ) ) { $ this -> flyphp [ 'files' ] -> makeDirectory ( $ path ) ; } return $ path ; } | Get the workbench path for the controller . |
36,351 | protected function explodeOption ( $ name ) { $ option = $ this -> input -> getOption ( $ name ) ; return is_null ( $ option ) ? array ( ) : explode ( ',' , $ option ) ; } | Get and explode a given input option . |
36,352 | public static function createSubscriptions ( $ dbSubscriptions ) { if ( ! is_array ( $ dbSubscriptions ) ) { $ dbSubscriptions = [ $ dbSubscriptions ] ; } $ result = [ ] ; foreach ( $ dbSubscriptions as $ dbSubscription ) { $ attributes = $ dbSubscription -> getAttributes ( ) ; unset ( $ attributes [ 'id' ] ) ; unset ( $ attributes [ 'queue_id' ] ) ; unset ( $ attributes [ 'is_deleted' ] ) ; $ subscription = new components \ Subscription ( ) ; $ subscription -> setAttributes ( $ attributes ) ; foreach ( $ dbSubscription -> categories as $ category ) { if ( ! $ category -> is_exception ) { $ subscription -> categories [ ] = $ category -> category ; } else { $ subscription -> exceptions [ ] = $ category -> category ; } } $ result [ ] = $ subscription ; } return $ result ; } | Creates an array of Subscription objects from DbSubscription objects . |
36,353 | public function getResponseData ( ) { $ data = null ; if ( $ body = $ this -> getResponseBody ( ) ) { if ( ( $ decoded = json_decode ( $ body , true ) ) ) { $ data = $ decoded ; } } return $ data ; } | Gets the response body as an array if the response body is JSON - encoded data . Otherwise returns null . |
36,354 | public static function lookupDevice ( $ key , $ value ) { $ devices = static :: find ( ) ; foreach ( $ devices as $ device ) { if ( $ value === $ device [ $ key ] ) { return $ device ; } } return null ; } | Lookup a device by key - value |
36,355 | protected static function getDeviceInfo ( $ devices ) { $ infos = [ ] ; foreach ( $ devices as $ device ) { $ sender = $ device [ '_sender' ] ; $ port = static :: getPort ( $ device [ 'data' ] ) ; $ ip = substr ( $ sender , 0 , strpos ( $ sender , ':' ) ) ; $ client = static :: getClientByDevice ( $ device ) ; $ info = static :: getClientInfo ( $ client ) ; $ info = $ info [ 'root' ] [ 'device' ] ; if ( $ info [ 'deviceType' ] !== 'urn:MakerMusingsArif:device:controllee:1' ) { $ id = str_replace ( ' ' , '_' , strtolower ( $ info [ 'friendlyName' ] ) ) ; $ data = [ 'id' => $ id , 'ip' => $ ip , 'port' => $ port , 'deviceType' => $ info [ 'deviceType' ] , 'friendlyName' => $ info [ 'friendlyName' ] , 'modelName' => $ info [ 'modelName' ] , 'UDN' => $ info [ 'UDN' ] ] ; if ( static :: isBridge ( $ info [ 'modelName' ] ) ) { $ bridge = new Bridge ( $ ip , $ client ) ; $ bridgeDevices = $ bridge -> getPairedDevices ( true ) ; foreach ( $ bridgeDevices as $ i => $ bridgeDevice ) { $ bridgeDevice [ 'id' ] = str_replace ( ' ' , '_' , strtolower ( $ bridgeDevice [ 'FriendlyName' ] ) ) ; $ bridgeDevices [ $ i ] = $ bridgeDevice ; } $ data [ 'class_name' ] = Bridge :: class ; $ data [ 'device' ] = $ bridgeDevices ; } else if ( static :: isLightSwitch ( $ info [ 'modelName' ] ) ) { $ data [ 'class_name' ] = LightSwitch :: class ; } else if ( static :: isWemoSwitch ( $ info [ 'modelName' ] ) ) { $ data [ 'class_name' ] = WemoSwitch :: class ; } else if ( static :: isInsightSwitch ( $ info [ 'modelName' ] ) ) { $ data [ 'class_name' ] = InsightSwitch :: class ; } else if ( static :: isEmulatedWemoSwitch ( $ info [ 'modelName' ] ) ) { $ data [ 'class_name' ] = WemoSwitch :: class ; } else { static :: resolveOtherDevices ( $ data , $ info , $ device ) ; } $ infos [ ] = $ data ; } } return $ infos ; } | Fetches device details |
36,356 | protected static function setDevicesInStorage ( $ devices ) { try { $ data = [ ] ; $ file = ( static :: $ deviceFile !== null ) ? static :: $ deviceFile : WS :: config ( ) -> get ( 'device_storage' ) ; $ content = @ file_get_contents ( $ file ) ; if ( ! empty ( $ content ) ) { $ data = json_decode ( $ content , true ) ; } if ( ! isset ( $ data [ 'state' ] ) ) { $ data = [ 'state' => [ ] , 'device' => [ ] ] ; } $ data [ 'device' ] = $ devices ; $ json = json_encode ( $ data , JSON_UNESCAPED_SLASHES ) ; @ file_put_contents ( $ file , $ json ) ; return true ; } catch ( \ Exception $ e ) { return false ; } } | Caches devices in file . |
36,357 | protected static function getDevicesFromStorage ( ) { try { $ file = ( static :: $ deviceFile !== null ) ? static :: $ deviceFile : WS :: config ( ) -> get ( 'device_storage' ) ; $ content = @ file_get_contents ( $ file ) ; if ( ! empty ( $ content ) ) { $ devices = json_decode ( $ content , true ) ; if ( isset ( $ devices [ 'device' ] ) ) { return $ devices [ 'device' ] ; } return $ devices ; } else { return null ; } } catch ( \ Exception $ e ) { return null ; } } | Retrieves devices from cache |
36,358 | public function getAttributeByName ( Request $ request , string $ name ) : array { $ matches = \ array_filter ( $ this -> getReleasedAttributes ( $ request ) , function ( $ key ) use ( $ name ) { return \ strtoupper ( $ name ) == \ strtoupper ( $ key ) ; } , ARRAY_FILTER_USE_KEY ) ; if ( empty ( $ matches ) ) { return [ ] ; } else { return \ current ( $ matches ) ; } } | Returns values for authentication related special attributes . |
36,359 | public function filterByUserCapabilities ( Event $ event , Query $ query , ArrayObject $ options ) : void { if ( isset ( $ options [ 'accessCheck' ] ) && ! $ options [ 'accessCheck' ] ) { return ; } $ table = $ event -> getSubject ( ) ; Assert :: isInstanceOf ( $ table , \ Cake \ ORM \ Table :: class ) ; $ filterQuery = new FilterQuery ( $ query , $ table , User :: getCurrentUser ( ) ) ; $ filterQuery -> execute ( ) ; } | Query filtering method based on current user capabilities . |
36,360 | protected function softDelete ( ) { $ column = $ this -> model -> getDeletedAtColumn ( ) ; return $ this -> update ( array ( $ column => $ this -> model -> freshTimestampString ( ) ) ) ; } | Soft delete the record in the database . |
36,361 | public function restore ( ) { if ( $ this -> model -> isSoftDeleting ( ) ) { $ column = $ this -> model -> getDeletedAtColumn ( ) ; return $ this -> update ( array ( $ column => null ) ) ; } } | Restore the soft - deleted model instances . |
36,362 | public function withTrashed ( ) { $ column = $ this -> model -> getQualifiedDeletedAtColumn ( ) ; foreach ( ( array ) $ this -> query -> wheres as $ key => $ where ) { if ( $ this -> isSoftDeleteConstraint ( $ where , $ column ) ) { unset ( $ this -> query -> wheres [ $ key ] ) ; $ this -> query -> wheres = array_values ( $ this -> query -> wheres ) ; } } return $ this ; } | Include the soft deleted models in the results . |
36,363 | public function onlyTrashed ( ) { $ this -> withTrashed ( ) ; $ this -> query -> whereNotNull ( $ this -> model -> getQualifiedDeletedAtColumn ( ) ) ; return $ this ; } | Force the result set to only included soft deletes . |
36,364 | public function eagerLoadRelations ( array $ models ) { foreach ( $ this -> eagerLoad as $ name => $ constraints ) { if ( strpos ( $ name , '.' ) === false ) { $ models = $ this -> loadRelation ( $ models , $ name , $ constraints ) ; } } return $ models ; } | Eager load the relationships for the models . |
36,365 | protected function parseNested ( $ name , $ results ) { $ progress = array ( ) ; foreach ( explode ( '.' , $ name ) as $ segment ) { $ progress [ ] = $ segment ; if ( ! isset ( $ results [ $ last = implode ( '.' , $ progress ) ] ) ) { $ results [ $ last ] = function ( ) { } ; } } return $ results ; } | Parse the nested relationships in a relation . |
36,366 | static function timer_delete ( $ timer ) { if ( isset ( self :: $ timers [ $ timer ] ) ) { unset ( self :: $ timers [ $ timer ] ) ; return true ; } return false ; } | Deletes the timer . |
36,367 | static function timers_stop ( ) { $ time = microtime ( true ) ; foreach ( self :: $ timers as & $ timer ) { if ( $ timer [ "started" ] ) { $ timer [ "started" ] = false ; $ timer [ "value" ] = $ time - $ timer [ "value" ] ; } } return false ; } | Stops all running timers . |
36,368 | static function init ( $ time = null ) { if ( self :: $ start == null || $ time != null ) { if ( $ time == null ) { $ time = microtime ( true ) ; } self :: $ start = $ time ; } if ( self :: $ hostname == null ) { self :: $ hostname = gethostname ( ) ; } if ( self :: $ script_name == null && isset ( $ _SERVER [ 'SCRIPT_NAME' ] ) ) { self :: $ script_name = $ _SERVER [ 'SCRIPT_NAME' ] ; } if ( self :: $ server_name == null && isset ( $ _SERVER [ 'SERVER_NAME' ] ) ) { self :: $ server_name = $ _SERVER [ 'SERVER_NAME' ] ; } if ( ! self :: $ shutdown_registered ) { self :: $ shutdown_registered = true ; register_shutdown_function ( 'pinba::flush' ) ; } } | A function not in the pinba extension api needed to calculate total req . time |
36,369 | protected final function split ( $ text , $ keepEmpty = false ) { $ lines = array_map ( function ( $ line ) { return trim ( $ line ) ; } , explode ( "\n" , $ text ) ) ; if ( ! $ keepEmpty ) { $ lines = array_filter ( $ lines ) ; return array_values ( $ lines ) ; } return $ lines ; } | Splits text on newlines filtering out empty lines . |
36,370 | public function getTotal ( $ useConnection = 'read' ) { $ query = 'SELECT COUNT(*) AS cnt FROM contact' ; $ stmt = Database :: getConnection ( $ useConnection ) -> prepare ( $ query ) ; if ( $ stmt -> execute ( ) ) { if ( $ data = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ) { return $ data [ 'cnt' ] ; } } return 0 ; } | Get the total number of submissions in the system . |
36,371 | function commitQuery ( ) { $ result = oci_commit ( $ this -> DBConnection ) ; $ this -> Mode = OCI_COMMIT_ON_SUCCESS ; if ( $ this -> OutputSQL ) { $ this -> reportQuery ( 'eZOracleDB' , 'commit transaction' , false , 0 ) ; } return $ result ; } | We trust the eZDBInterface to count nested transactions and only call this method when trans counter reaches 0 |
36,372 | public function sendReminder ( RemindableInterface $ user , $ token , Closure $ callback = null ) { $ view = $ this -> reminderView ; return $ this -> mailer -> send ( $ view , compact ( 'token' , 'user' ) , function ( $ m ) use ( $ user , $ token , $ callback ) { $ m -> to ( $ user -> getReminderEmail ( ) ) ; if ( ! is_null ( $ callback ) ) call_user_func ( $ callback , $ m , $ user , $ token ) ; } ) ; } | Send the password reminder e - mail . |
36,373 | public function current ( ) { $ data = $ this -> dbi -> current ( ) ; $ class_name = $ this -> __class_name ; $ object = new $ class_name ( $ data [ 'id' ] ) ; $ object -> data = $ data ; $ object -> set_is_loaded ( true ) ; return $ object ; } | Can return any type . |
36,374 | public function delete ( ) { if ( $ this -> exists && $ deleted = $ this -> service -> delete ( $ this -> getId ( ) ) ) { $ this -> setAttributes ( $ deleted -> toArray ( ) ) ; return ! $ this -> exists = false ; } return false ; } | Deletes the resource from Flow |
36,375 | protected function entityToArray ( ) : array { $ array = [ "id" => ( string ) $ this -> id , "label" => $ this -> label ( ) , "attributes" => $ this -> attributes -> toArray ( ) ] ; if ( isset ( $ this -> listeners ) && isset ( $ this -> listeners_flat ) ) { $ array [ "listeners" ] = $ this -> listeners_flat ; } return $ array ; } | Converts the object to array |
36,376 | function error ( $ msg , $ section = 'bors' , $ trace = false , $ extra = array ( ) ) { static $ entered = false ; if ( $ entered ) throw new Exception ( 'Reentered logger with ' . $ msg . ' in section ' . $ section ) ; $ entered = true ; try { $ this -> logger ( $ section , Logger :: ERROR , $ trace ) -> addError ( $ msg , $ extra ) ; } catch ( Exception $ e ) { echo "Exception while error logging:\n<code><xmp>" . $ e -> getMessage ( ) . "</xmp></code>\nFirst error is:\n<xmp>$msg\nin" . bors_debug :: trace ( ) . "</xmp>" ; } $ entered = false ; } | should typically be logged and monitored . |
36,377 | public function init ( ) { $ this -> config -> set ( 'http' , [ 'request' => & $ this -> request , 'response' => & $ this -> response , ] ) ; Event :: trigger ( 'BeforeSystemInit' , $ this ) ; if ( ! defined ( 'IS_CONSOLE' ) ) { $ this -> initHttpRequest ( ) ; } Event :: trigger ( 'AfterSystemInit' , $ rtn ) ; return $ rtn ; } | Setup the application and register basic routes |
36,378 | public function registerRouter ( $ route , $ defaults , $ request , $ denied ) { $ bypass = $ this -> config -> get ( 'Octo.bypass_auth' ) ; $ this -> router -> register ( $ route , $ defaults , function ( & $ route , Response & $ response ) use ( & $ bypass , & $ request , & $ denied ) { define ( 'OCTO_ADMIN' , true ) ; if ( ! empty ( $ _GET [ 'session_auth' ] ) ) { session_id ( $ _GET [ 'session_auth' ] ) ; } if ( session_status ( ) != PHP_SESSION_ACTIVE ) { session_start ( ) ; } if ( array_key_exists ( $ route [ 'controller' ] , $ bypass ) ) { $ bypass = $ bypass [ $ route [ 'controller' ] ] ; if ( $ bypass === true ) { return true ; } if ( is_array ( $ bypass ) && in_array ( $ route [ 'action' ] , $ bypass ) ) { return true ; } } if ( ! empty ( $ _SESSION [ 'user_id' ] ) ) { return $ this -> setupUserProperties ( $ route , $ response , $ denied ) ; } if ( $ request -> isAjax ( ) ) { $ response -> setResponseCode ( 401 ) ; $ response -> setContent ( '' ) ; } else { $ _SESSION [ 'previous_url' ] = $ this -> config -> get ( 'site.url' ) . $ _SERVER [ 'REQUEST_URI' ] ; $ response = new RedirectResponse ( $ this -> response ) ; $ response -> setHeader ( 'Location' , $ this -> config -> get ( 'site.full_admin_url' ) . '/session/login' ) ; } return false ; } ) ; } | Register advanced routers |
36,379 | protected function setupUserProperties ( $ route , $ response , $ denied ) { $ user = Store :: get ( 'User' ) -> getByPrimaryKey ( $ _SESSION [ 'user_id' ] ) ; if ( $ user && $ user -> getActive ( ) ) { $ _SESSION [ 'user' ] = $ user ; $ user -> setDateActive ( new \ DateTime ( ) ) ; Store :: get ( 'User' ) -> save ( $ user ) ; $ uri = '/' ; if ( $ route [ 'controller' ] != 'Dashboard' ) { $ uri .= $ route [ 'controller' ] ; } if ( $ route [ 'action' ] != 'index' ) { $ uri .= '/' . $ route [ 'action' ] ; } if ( in_array ( $ route [ 'controller' ] , [ 'categories' , 'media' ] ) && isset ( $ route [ 'args' ] [ 0 ] ) ) { $ uri .= '/' . $ route [ 'args' ] [ 0 ] ; } if ( ! $ user -> canAccess ( $ uri ) && is_callable ( $ denied ) ) { $ denied ( $ user , $ uri , $ response ) ; return false ; } return true ; } } | Setup the user s permissions etc . for the route |
36,380 | protected function handleHttpError ( $ code ) { try { $ template = new Template ( 'Error/' . $ code , ( defined ( 'OCTO_ADMIN' ) && OCTO_ADMIN ? 'admin' : null ) ) ; $ template -> set ( 'page' , [ 'title' => 'Error ' . $ code . ' - ' . Response :: $ codes [ $ code ] ] ) ; $ content = $ template -> render ( ) ; $ this -> response -> setResponseCode ( $ code ) ; $ this -> response -> setContent ( $ content ) ; } catch ( \ Exception $ ex ) { } return $ this -> response ; } | Handle HTTP error |
36,381 | protected function permissionDenied ( $ user , $ uri , & $ response ) { $ _SESSION [ 'GlobalMessage' ] [ 'error' ] = 'You do not have permission to access: ' . $ uri ; $ log = Log :: create ( Log :: TYPE_PERMISSION , 'user' , 'Unauthorised access attempt.' ) ; $ log -> setUser ( $ user ) ; $ log -> setLink ( $ uri ) ; $ log -> save ( ) ; $ response = new RedirectResponse ( $ response ) ; $ response -> setHeader ( 'Location' , $ this -> config -> get ( 'site.full_admin_url' ) ) ; $ response -> flush ( ) ; } | Callback if permission denied to access |
36,382 | protected function setBlockProperties ( $ block , $ args ) { $ block -> setTemplateParams ( $ args ) ; if ( $ block -> hasUriExtensions ( ) ) { $ this -> uriExtensionsHandled = true ; $ block -> setUriExtension ( $ this -> uri ) ; } if ( isset ( $ this -> page ) ) { $ block -> setPage ( $ this -> page ) ; } if ( isset ( $ this -> version ) ) { $ block -> setPageVersion ( $ this -> version ) ; } $ block -> setDataStore ( $ this -> dataStore ) ; return $ block ; } | Set template parameters and other properties on a block |
36,383 | public static function fromSeconds ( $ seconds ) { $ interval = new static ( 'PT0S' ) ; foreach ( array ( 'y' => self :: SECONDS_YEAR , 'm' => self :: SECONDS_MONTH , 'd' => self :: SECONDS_DAY , 'h' => self :: SECONDS_HOUR , 'i' => self :: SECONDS_MINUTE ) as $ property => $ increment ) { if ( - 1 !== bccomp ( $ seconds , $ increment ) ) { $ count = floor ( bcdiv ( $ seconds , $ increment , 1 ) ) ; $ interval -> $ property = $ count ; $ seconds = bcsub ( $ seconds , bcmul ( $ count , $ increment ) ) ; } } $ interval -> s = ( int ) $ seconds ; return $ interval ; } | Returns the DateInterval instance for the number of seconds . |
36,384 | public function toSpec ( \ DateInterval $ interval = null ) { if ( ( null === $ interval ) && isset ( $ this ) ) { $ interval = $ this ; } $ string = 'P' ; foreach ( self :: $ date as $ property => $ suffix ) { if ( $ interval -> { $ property } ) { $ string .= $ interval -> { $ property } . $ suffix ; } } if ( $ interval -> h || $ interval -> i || $ interval -> s ) { $ string .= 'T' ; foreach ( self :: $ time as $ property => $ suffix ) { if ( $ interval -> { $ property } ) { $ string .= $ interval -> { $ property } . $ suffix ; } } } return $ string ; } | Returns the interval specification . |
36,385 | public function getName ( ) { $ ref = new \ ReflectionObject ( $ this ) ; $ name = $ ref -> getNamespaceName ( ) ; $ name = rtrim ( $ name , '\\' ) ; return str_replace ( '\\' , '_' , strtolower ( $ name ) ) ; } | Name to use when querying this component . |
36,386 | public function create ( Authenticatable $ user , Content $ content ) { $ type = $ content -> getAttribute ( 'type' ) ; return $ this -> can ( "create {$type}" ) || $ this -> can ( "manage {$type}" ) ; } | Create content policy . |
36,387 | public function update ( Authenticatable $ user , Content $ content ) { $ type = $ content -> getAttribute ( 'type' ) ; $ owner = $ content -> ownedBy ( $ user ) ; return ( $ this -> can ( "manage {$type}" ) || ( $ owner && $ this -> can ( "update {$type}" ) ) ) ; } | Update content policy . |
36,388 | public function manage ( Authenticatable $ user , Content $ content ) { $ type = $ content -> getAttribute ( 'type' ) ; return $ this -> can ( "manage {$type}" ) ; } | Manage content policy . |
36,389 | public function hasMany ( array $ keys ) { $ values = $ this -> getMany ( $ keys ) ; return array_map ( function ( $ value ) { return ! is_null ( $ value ) ; } , $ values ) ; } | Determine if an array of items exists in the cache . |
36,390 | public function getMany ( array $ keys , $ default = null ) { $ keys = array_fill_keys ( $ keys , $ default ) ; if ( ! method_exists ( $ this -> store , 'getMany' ) ) { return array_combine ( array_keys ( $ keys ) , array_map ( [ $ this , 'get' ] , array_keys ( $ keys ) , array_values ( $ keys ) ) ) ; } $ values = array_combine ( array_keys ( $ keys ) , $ this -> store -> getMany ( array_keys ( $ keys ) ) ) ; foreach ( $ values as $ key => & $ value ) { if ( is_null ( $ value ) ) { $ this -> fireCacheEvent ( 'missed' , [ $ key ] ) ; $ value = value ( array_get ( $ keys , $ key , $ default ) ) ; } else { $ this -> fireCacheEvent ( 'hit' , [ $ key , $ value ] ) ; } } return $ values ; } | Retrieve an array of items from the cache by keys . |
36,391 | public function pullMany ( array $ keys , $ default = null ) { $ values = $ this -> getMany ( $ keys , $ default ) ; $ this -> forgetMany ( $ keys ) ; return $ values ; } | Retrieve an array of items from the cache and delete them . |
36,392 | public function addMany ( array $ items , $ minutes ) { $ values = $ this -> getMany ( array_keys ( $ items ) ) ; $ fill = Arr :: where ( $ values , function ( $ key , $ value ) { return is_null ( $ value ) ; } ) ; $ items = array_intersect_key ( $ items , $ fill ) ; $ this -> putMany ( $ items , $ minutes ) ; return array_map ( function ( $ value ) { return is_null ( $ value ) ; } , $ values ) ; } | Store an array of items in the cache if the key does not exist . |
36,393 | public function rememberMany ( array $ keys , $ minutes , Closure $ callback ) { $ values = $ this -> getMany ( $ keys ) ; $ items = Arr :: where ( $ values , function ( $ key , $ value ) { return is_null ( $ value ) ; } ) ; if ( ! empty ( $ items ) ) { $ items = array_combine ( array_keys ( $ items ) , $ callback ( array_keys ( $ items ) ) ) ; $ this -> putMany ( $ items , $ minutes ) ; $ values = array_replace ( $ values , $ items ) ; } return $ values ; } | Get an array of items from the cache or store the default value . |
36,394 | public function rememberManyForever ( array $ keys , Closure $ callback ) { $ values = $ this -> getMany ( $ keys ) ; $ items = Arr :: where ( $ values , function ( $ key , $ value ) { return is_null ( $ value ) ; } ) ; if ( ! empty ( $ items ) ) { $ items = array_combine ( array_keys ( $ items ) , $ callback ( array_keys ( $ items ) ) ) ; $ this -> foreverMany ( $ items ) ; $ values = array_replace ( $ values , $ items ) ; } return $ values ; } | Get an array of items from the cache or store the default value forever . |
36,395 | protected function findWorkbenches ( ) { $ results = array ( ) ; foreach ( $ this -> getWorkbenchComposers ( ) as $ file ) { $ results [ ] = array ( 'name' => $ file -> getRelativePath ( ) , 'path' => $ file -> getPath ( ) ) ; } return $ results ; } | Get all of the workbench directories . |
36,396 | protected function getWorkbenchComposers ( ) { $ workbench = $ this -> flyphp [ 'path.base' ] . '/workbench' ; if ( ! is_dir ( $ workbench ) ) return array ( ) ; return Finder :: create ( ) -> files ( ) -> in ( $ workbench ) -> name ( 'composer.json' ) -> depth ( '< 3' ) ; } | Get all of the workbench composer files . |
36,397 | public function shutdown ( $ callback = null ) { if ( is_null ( $ callback ) ) { $ this -> fireAppCallbacks ( $ this -> shutdownCallbacks ) ; } else { $ this -> shutdownCallbacks [ ] = $ callback ; } } | Register a shutdown callback . |
36,398 | protected function getStackedClient ( ) { $ sessionReject = $ this -> bound ( 'session.reject' ) ? $ this [ 'session.reject' ] : null ; $ client = with ( new \ Stack \ Builder ) -> push ( 'Fly\Cookie\Guard' , $ this [ 'encrypter' ] ) -> push ( 'Fly\Cookie\Queue' , $ this [ 'cookie' ] ) -> push ( 'Fly\Session\Middleware' , $ this [ 'session' ] , $ sessionReject ) ; $ this -> mergeCustomMiddlewares ( $ client ) ; return $ client -> resolve ( $ this ) ; } | Get the stacked HTTP kernel for the application . |
36,399 | protected function mergeCustomMiddlewares ( \ Stack \ Builder $ stack ) { foreach ( $ this -> middlewares as $ middleware ) { list ( $ class , $ parameters ) = array_values ( $ middleware ) ; array_unshift ( $ parameters , $ class ) ; call_user_func_array ( array ( $ stack , 'push' ) , $ parameters ) ; } } | Merge the developer defined middlewares onto the stack . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.