idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
15,000 | public function get ( $ scheme = self :: REL ) { $ data = $ this -> data ; if ( $ scheme == self :: REL ) { unset ( $ data [ 'scheme' ] , $ data [ 'host' ] , $ data [ 'user' ] , $ data [ 'pass' ] , $ data [ 'port' ] ) ; return $ this -> build ( $ data ) ; } if ( ! isset ( $ data [ 'host' ] ) ) { $ data [ 'host' ] = $ t... | Returns formatted URL . |
15,001 | public function offsetSet ( $ key , $ value ) { if ( $ key === 'query' && isset ( $ value ) ) { $ value = $ this -> _queryToArray ( $ value ) ; } $ this -> data [ $ key ] = $ value ; } | Sets a URL - data by key . |
15,002 | public function toResponse ( ) : Response { return new Response ( $ this -> status , $ this -> headers , $ this -> body , $ this -> httpVersion , $ this -> reason ) ; } | Generates HTTP Response . |
15,003 | public static function view ( $ package ) { $ settings = static :: get ( $ package ) ; if ( $ settings and array_key_exists ( 'view' , $ settings ) ) { return view ( $ settings [ 'view' ] ) ; } return '' ; } | Returns the settings view of the package . |
15,004 | protected function _processTemplateVars ( array $ options ) { $ templateVars = isset ( $ options [ 'options' ] [ 'templateVars' ] ) ? $ options [ 'options' ] [ 'templateVars' ] : [ ] ; if ( empty ( $ templateVars ) ) { return $ templateVars ; } if ( isset ( $ templateVars [ 'formRowLabel' ] ) && $ options [ 'options' ]... | Process templateVars to wrap info elements in a small tag and apply the for attribute to form row labels . |
15,005 | public function getLabel ( $ text , $ info = null ) { $ options = [ 'text' => $ text , 'templateVars' => [ ] ] ; if ( $ info !== null ) { $ options [ 'templateVars' ] [ 'labelInfo' ] = '<small>' . $ info . '</small>' ; } return $ options ; } | Get the options array for a label . This handles the optional placement of an info text below the label . |
15,006 | public function timeZoneSelect ( $ field , array $ options = [ ] ) { $ regions = [ 'Europe' => DateTimeZone :: EUROPE , 'America' => DateTimeZone :: AMERICA , 'Africa' => DateTimeZone :: AFRICA , 'Antarctica' => DateTimeZone :: ANTARCTICA , 'Asia' => DateTimeZone :: ASIA , 'Atlantic' => DateTimeZone :: ATLANTIC , 'Indi... | Render a grouped time zone select box . |
15,007 | public function toggleSwitch ( $ fieldName , array $ options = [ ] ) { $ options += [ 'hiddenField' => true , 'value' => 1 , 'id' => true ] ; $ value = $ options [ 'value' ] ; unset ( $ options [ 'value' ] ) ; $ options = $ this -> _initInputField ( $ fieldName , $ options ) ; $ options [ 'value' ] = $ value ; $ output... | Creates a toggleSwitch input widget . |
15,008 | public function save ( $ pConditions = NULL ) { foreach ( $ this -> _fields as & $ value ) { if ( is_array ( $ value ) ) { $ value = implode ( ',' , $ value ) ; } } return parent :: save ( $ pConditions ) ; } | Save the item in the database . |
15,009 | public static function IsAbsolute ( string $ path , bool $ dependToOS = true ) : bool { if ( \ is_null ( $ path ) || \ strlen ( $ path ) < 1 ) { return false ; } if ( $ dependToOS ) { if ( ! \ IS_WIN ) { return $ path [ 0 ] == '/' ; } if ( \ strlen ( $ path ) < 2 ) { return false ; } return $ path [ 1 ] == ':' || ( $ p... | Returns if the defined path is a absolute path definition . |
15,010 | protected function resolveModule ( $ controller ) { $ modules = $ this -> getModules ( ) ; $ module = get_class ( $ controller ) ; while ( false !== $ pos = strrpos ( $ module , '\\' ) ) { $ module = substr ( $ module , 0 , $ pos ) ; if ( $ modules -> has ( $ module ) ) { return $ module ; } } throw new RuntimeExceptio... | Resolves the module namespace of received controller . |
15,011 | public function sendJsonResponse ( & $ response_data , $ headers = [ ] ) { header ( 'Content-type: application/json' ) ; if ( ! empty ( $ headers ) ) { if ( is_array ( $ headers ) ) { foreach ( $ headers as $ header ) { header ( $ header ) ; } } } echo array_to_json ( $ response_data ) ; } | This is an auxiliary function for sending the response in JSON format . |
15,012 | public function exitWithException ( $ ex ) { $ response_data = [ ] ; $ response_data [ "result" ] = "error" ; $ response_data [ "errors" ] = [ [ "error_code" => "system_error" , "error_text" => $ ex -> getMessage ( ) ] ] ; $ this -> sendJsonResponse ( $ response_data ) ; exit ; } | This is an auxiliary function for sending the response in JSON format by an exception . |
15,013 | public function getApiRequest ( ) { if ( empty ( $ _SERVER [ 'REQUEST_URI' ] ) ) { return "" ; } $ api_request = $ _SERVER [ 'REQUEST_URI' ] ; if ( ! empty ( $ _SERVER [ 'QUERY_STRING' ] ) ) { $ api_request = str_replace ( $ _SERVER [ 'QUERY_STRING' ] , "" , $ api_request ) ; } $ api_request = rtrim ( $ api_request , "... | Defines the current API request name . |
15,014 | public function registerApiRequestHandler ( $ api_request , $ handler_class_name ) { if ( empty ( $ api_request ) ) { throw new \ Exception ( "The API request is undefined (empty)!" ) ; } if ( ! empty ( $ this -> handler_table [ $ api_request ] ) ) { throw new \ Exception ( "The API request '$api_request' has already t... | Registers a handler action for an API request call . |
15,015 | protected function _renderExpressionAndTerms ( ExpressionInterface $ expression , $ context = null ) { $ renderedTerms = [ ] ; foreach ( $ expression -> getTerms ( ) as $ _term ) { $ renderedTerms [ ] = $ this -> _renderExpressionTerm ( $ _term , $ context ) ; } return $ this -> _compileExpressionTerms ( $ expression ,... | Renders a given expression and its terms . |
15,016 | public function getFormName ( $ data ) { $ context = $ data ; if ( $ data instanceof MediaCommonInterface ) { if ( $ data instanceof MediaProviderInterface ) { $ context = $ data -> getMedia ( ) -> getContext ( ) ; } else { $ context = $ data -> getContext ( ) ; } } return $ this -> providerService -> getProviderManage... | Get form name |
15,017 | public function getFormByContext ( $ context , array $ options = array ( ) ) { $ formName = $ this -> providerService -> getProviderManager ( $ context ) -> getFormName ( ) ; $ mediaProvider = $ this -> mediaService -> create ( $ context ) ; return $ this -> getForm ( $ formName , $ mediaProvider , $ options ) ; } | Get form by the context |
15,018 | public function getFormByMediaProvider ( MediaProviderInterface $ mediaProvider , array $ options = array ( ) ) { $ formName = $ this -> providerService -> getProviderManager ( $ mediaProvider -> getMedia ( ) -> getContext ( ) ) -> getFormName ( ) ; return $ this -> getForm ( $ formName , $ mediaProvider , $ options ) ... | Get form by mediaProvider |
15,019 | protected function getForm ( $ formName , MediaProviderInterface $ mediaProvider , array $ options = array ( ) ) { return $ this -> formFactory -> createBuilder ( $ formName , $ mediaProvider , $ options ) -> getForm ( ) ; } | Return the Form instance |
15,020 | public function getEnvVarsFromConsul ( array $ mappings ) { foreach ( $ mappings as $ environmentKey => $ consulPath ) { $ keyExists = $ this -> keyIsDefined ( $ environmentKey ) ; if ( $ keyExists && ! $ this -> overwriteEvenIfDefined ) { continue ; } $ consulValue = $ this -> getKeyValueFromConsul ( $ consulPath ) ; ... | Add missing environment variables from Consul . |
15,021 | public function exposeEnvironmentIntoContainer ( ContainerBuilder $ container , array $ mappings ) : ContainerBuilder { foreach ( $ mappings as $ environmentKey => $ consulPath ) { $ container -> setParameter ( "env({$environmentKey})" , getenv ( $ environmentKey ) ) ; } return $ container ; } | Expose a set of mappings into the container builder . |
15,022 | private function keyIsDefined ( string $ environmentKey ) : bool { $ keyValue = getenv ( $ environmentKey ) ; if ( false === $ keyValue ) { return false ; } return true ; } | Check if an environment key is defined . |
15,023 | private function getKeyValueFromConsul ( string $ kvPath ) : string { return $ this -> kv -> get ( $ kvPath , [ 'raw' => true ] ) -> getBody ( ) ; } | Get a key value from Consul . |
15,024 | function Send ( ) { if ( count ( $ this -> to ) < 1 ) { $ this -> error_handler ( "You must provide at least one recipient email address" ) ; return false ; } if ( ! empty ( $ this -> AltBody ) ) $ this -> ContentType = "multipart/alternative" ; $ header = $ this -> create_header ( ) ; if ( ! $ body = $ this -> create_... | Creates message and assigns Mailer . If the message is not sent successfully then it returns false . Returns bool . |
15,025 | function addr_append ( $ type , $ addr ) { $ addr_str = "" ; $ addr_str .= sprintf ( "%s: %s <%s>" , $ type , $ addr [ 0 ] [ 1 ] , $ addr [ 0 ] [ 0 ] ) ; if ( count ( $ addr ) > 1 ) { for ( $ i = 1 ; $ i < count ( $ addr ) ; $ i ++ ) { $ addr_str .= sprintf ( ", %s <%s>" , $ addr [ $ i ] [ 1 ] , $ addr [ $ i ] [ 0 ] ) ... | Creates recipient headers . Returns string . |
15,026 | function create_header ( ) { $ header = array ( ) ; $ header [ ] = sprintf ( "Date: %s\r\n" , $ this -> rfc_date ( ) ) ; if ( $ this -> Mailer != "mail" ) $ header [ ] = $ this -> addr_append ( "To" , $ this -> to ) ; $ header [ ] = sprintf ( "From: %s <%s>\r\n" , $ this -> FromName , trim ( $ this -> From ) ) ; if ( c... | Assembles message header . Returns a string if successful or false if unsuccessful . |
15,027 | function create_body ( ) { if ( $ this -> WordWrap ) $ this -> Body = $ this -> wordwrap ( $ this -> Body , $ this -> WordWrap ) ; if ( ( ! empty ( $ this -> AltBody ) ) && ( count ( $ this -> attachment ) < 1 ) ) { $ mime = array ( ) ; $ mime [ ] = "This is a MIME message. If you are reading this text, you\r\n" ; $ mi... | Assembles the message body . Returns a string if successful or false if unsuccessful . |
15,028 | function AddAttachment ( $ path , $ name = "" , $ encoding = "base64" , $ type = "application/octet-stream" ) { if ( ! @ is_file ( $ path ) ) { $ this -> error_handler ( sprintf ( "Could not find %s file on filesystem" , $ path ) ) ; return false ; } $ filename = basename ( $ path ) ; if ( $ name == "" ) $ name = $ fil... | Adds an attachment from the OS filesystem . Checks if attachment is valid and then adds the attachment to the list . Returns false if the file was not found . |
15,029 | function encode_file ( $ path , $ encoding = "base64" ) { if ( ! @ $ fd = fopen ( $ path , "rb" ) ) { $ this -> error_handler ( sprintf ( "File Error: Could not open file %s" , $ path ) ) ; return false ; } $ file = fread ( $ fd , filesize ( $ path ) ) ; $ encoded = $ this -> encode_string ( $ file , $ encoding ) ; fcl... | Encodes attachment in requested format . Returns a string if successful or false if unsuccessful . |
15,030 | function encode_string ( $ str , $ encoding = "base64" ) { switch ( strtolower ( $ encoding ) ) { case "base64" : $ encoded = chunk_split ( base64_encode ( $ str ) ) ; break ; case "7bit" : case "8bit" : $ encoded = $ this -> fix_eol ( $ str ) ; if ( substr ( $ encoded , - 2 ) != "\r\n" ) $ encoded .= "\r\n" ; break ; ... | Encodes string to requested format . Returns a string if successful or false if unsuccessful . |
15,031 | function rfc_date ( ) { $ tz = date ( "Z" ) ; $ tzs = ( $ tz < 0 ) ? "-" : "+" ; $ tz = abs ( $ tz ) ; $ tz = ( $ tz / 3600 ) * 100 + ( $ tz % 3600 ) / 60 ; $ date = sprintf ( "%s %s%04d" , date ( "D, j M Y H:i:s" ) , $ tzs , $ tz ) ; return $ date ; } | Returns the proper RFC 822 formatted date . Returns string . |
15,032 | function fix_eol ( $ str ) { $ str = str_replace ( "\r\n" , "\n" , $ str ) ; $ str = str_replace ( "\r" , "\n" , $ str ) ; $ str = str_replace ( "\n" , "\r\n" , $ str ) ; return $ str ; } | Changes every end of line from CR or LF to CRLF . Returns string . |
15,033 | function AddMSMailHeaders ( ) { $ MSHeader = "" ; if ( $ this -> Priority == 1 ) $ MSPriority = "High" ; elseif ( $ this -> Priority == 5 ) $ MSPriority = "Low" ; else $ MSPriority = "Medium" ; $ MSHeader .= sprintf ( "X-MSMail-Priority: %s\r\n" , $ MSPriority ) ; $ MSHeader .= sprintf ( "Importance: %s\r\n" , $ MSPrio... | Adds all the Microsoft message headers . Returns string . |
15,034 | public function context ( ContextInterface $ context ) { if ( ! empty ( $ this -> vary ) ) { $ this -> varyValue = $ context -> get ( $ this -> vary ) ; } } | We assume pack format specifier I is equal in size to PHP_INT_SIZE |
15,035 | protected function getRatioStatus ( ) { if ( $ this -> ratio == 0.0 ) { return Status :: INACTIVE ; } if ( $ this -> ratio >= 1.0 ) { return Status :: ACTIVE ; } $ value = unpack ( 'nint' , md5 ( ( string ) $ this -> varyValue , true ) ) [ 'int' ] ; $ filter = ( int ) floor ( self :: RESOLUTION * ( float ) $ this -> ra... | Gets whether the feature is enabled according to the ratio alone |
15,036 | public function setAdapter ( $ adapter ) { if ( is_array ( $ adapter ) ) { $ adapter = Yii :: createObject ( $ adapter ) ; } if ( interface_exists ( 'League\Flysystem\AdapterInterface' ) && $ adapter instanceof AdapterInterface ) { $ this -> adapter = $ adapter ; } else { throw new InaccessibleKeyPairException ( "Flysy... | Sets the adapter to use for the provider |
15,037 | public static function load ( $ name , $ options = array ( ) ) { if ( array_key_exists ( $ name , self :: $ _modules ) ) { throw new \ Exception ( "A module with the name $name has already been loaded." , 1 ) ; } $ module = new Module ( $ name , $ options ) ; self :: $ _modules [ $ name ] = $ module ; return $ module ;... | Load a Module |
15,038 | private function init ( $ config ) { $ this -> getParams = filter_input_array ( INPUT_GET ) ; $ this -> postParams = filter_input_array ( INPUT_POST ) ; $ this -> attributes = array ( ) ; $ this -> session = new Session ( $ config [ 'SESSION_AUTOSTART' ] ) ; $ this -> requestMethod = filter_input ( INPUT_SERVER , 'REQU... | Setea todas las propiedades de la instancia GET - POST - SERVER y FRAMEWORK |
15,039 | public function getParam ( $ name ) { if ( isset ( $ this -> getParams [ $ name ] ) ) { return $ this -> getParams [ $ name ] ; } else { return NULL ; } } | Devuelve un parametro GET si existe y si no devuelve NULL |
15,040 | public function postParam ( $ name ) { if ( isset ( $ this -> postParams [ $ name ] ) ) { return $ this -> postParams [ $ name ] ; } else { return NULL ; } } | Devuelve un parametro POST si existe y si no devuelve NULL |
15,041 | public function getCleanParam ( $ name ) { if ( isset ( $ this -> getParams [ $ name ] ) ) { return Security :: clean_vars ( $ this -> getParams [ $ name ] ) ; } else { return NULL ; } } | Devuelve un parametro GET limpiado si existe y si no devuelve NULL |
15,042 | public function postCleanParam ( $ name ) { if ( isset ( $ this -> postParams [ $ name ] ) ) { return Security :: clean_vars ( $ this -> postParams [ $ name ] ) ; } else { return NULL ; } } | Devuelve un parametro POST limpiado si existe y si no devuelve NULL |
15,043 | public function getHeader ( $ name ) { $ headers = $ this -> getHeaders ( ) ; if ( isset ( $ headers [ $ name ] ) ) { return $ headers [ $ name ] ; } else { return NULL ; } } | Retorna un header especifico o null si no existe |
15,044 | public function getToken ( ) { if ( ! $ this -> token ) { if ( $ this -> getHeader ( 'Authorization' ) != NULL ) { $ this -> token = $ this -> getHeader ( 'Authorization' ) ; } if ( ! $ this -> token && $ this -> getParam ( 'token' ) ) { $ this -> token = $ this -> getParam ( 'token' ) ; } } return $ this -> token ; } | Retorna el token actual de la peticion Busca en el header Authorization o una variable get token |
15,045 | public function addFormElement ( array $ element , $ options = array ( ) ) { if ( array_key_exists ( $ element [ 'name' ] , $ this -> formElements ) ) { throw new \ Exception ( 'Form element "' . $ element [ 'name' ] . '" is already added, use replaceFormElement() or removeElement() instead' ) ; } $ this -> formElement... | Add form element using short syntax |
15,046 | public function getFormElements ( ) { $ sm = $ this -> getServiceLocator ( ) ; $ formElements = array ( ) ; $ placeholders = $ this -> getPlaceholderParameters ( ) ; $ replacePlaceholderWithValues = array ( ) ; foreach ( $ this -> formElements as $ element ) { if ( in_array ( $ element [ 'name' ] , $ this -> removeElem... | Get form elements in array format with values merged from placeholder |
15,047 | protected function formatFormElement ( array $ element ) { $ sm = $ this -> getServiceLocator ( ) ; $ result = array ( ) ; if ( array_key_exists ( 'lazy-set' , $ element ) ) { $ result = $ sm -> get ( $ this -> moduleService ) -> lazySet ( $ element [ 'lazy-set' ] ) ; } $ result [ 'name' ] = $ element [ 'name' ] ; $ re... | Format form element by replacing keywords with values recognized by zend - form |
15,048 | protected function addInputFilter ( ) { $ sm = $ this -> getServiceLocator ( ) ; if ( empty ( $ sm ) ) { throw new \ Exception ( 'Form must be initialized using FormElementManager, refer document for more information' ) ; } $ config = $ sm -> get ( $ this -> moduleService ) -> config ( ) ; foreach ( $ this -> getFormEl... | Add input filter to form elements - Skip filters if value is set to false - If NotEmpty validator is available add required element with value true else set required value to false - Remove type from element to avoid conflict with input filter |
15,049 | public function setPlaceholderParameter ( $ name , $ value , $ elementName = null ) { if ( null != $ elementName ) { $ this -> placeholderParameters [ 'element' ] [ $ elementName ] [ $ name ] = $ value ; } else { $ this -> placeholderParameters [ 'global' ] [ $ name ] = $ value ; } return $ this ; } | Replace place holder with given value in validators filters attributes or options |
15,050 | protected function searchAndReplacePlaceHolders ( array $ element , array $ placeHolders ) { array_walk_recursive ( $ element , function ( & $ v , $ k , $ ph ) { if ( is_string ( $ v ) && array_key_exists ( $ v , $ ph ) ) { $ v = $ ph [ $ v ] ; } } , $ placeHolders ) ; return $ element ; } | Search and replace occurences of place holders in an element |
15,051 | public function handleSignal ( $ signal ) { switch ( $ signal ) { case SIGINT : $ this -> log ( 'Received SIGINT, shutting down.' . PHP_EOL , Net_Notifier_Logger :: VERBOSITY_ALL ) ; $ this -> moribund = true ; break ; case SIGTERM : $ this -> log ( 'Received SIGTERM, shutting down.' . PHP_EOL , Net_Notifier_Logger :: ... | Handles UNIX signals |
15,052 | protected function relayNotification ( $ message ) { $ message = json_encode ( $ message ) ; foreach ( $ this -> listenClients as $ client ) { if ( $ client -> getState ( ) < Net_Notifier_WebSocket_Connection :: STATE_CLOSING ) { $ this -> log ( sprintf ( ' ... relaying message "%s" to %s ... ' , $ message , $ client -... | Notifies all connected clients of an event |
15,053 | protected function connect ( ) { $ errstr = '' ; $ errno = 0 ; $ this -> log ( 'creating socket ... ' , Net_Notifier_Logger :: VERBOSITY_ALL ) ; try { $ this -> socket = new Net_Notifier_Socket_Server ( sprintf ( 'tcp://0.0.0.0:%s' , $ this -> port ) , null ) ; } catch ( Net_Notifier_Socket_Exception $ e ) { $ this -> ... | Sets up this server s listen socket |
15,054 | protected function disconnect ( ) { $ this -> log ( 'closing sockets ... ' , Net_Notifier_Logger :: VERBOSITY_ALL ) ; foreach ( $ this -> clients as $ client ) { $ client -> startClose ( Net_Notifier_WebSocket_Connection :: CLOSE_GOING_AWAY , 'Server shutting down.' ) ; } $ this -> clients = array ( ) ; $ this -> socke... | Closes all client sockets and the server listen socket |
15,055 | protected function closeClient ( Net_Notifier_WebSocket_Connection $ client ) { $ this -> log ( sprintf ( 'closing client %s ... ' , $ client -> getIPAddress ( ) ) , Net_Notifier_Logger :: VERBOSITY_CLIENT ) ; if ( $ client -> getState ( ) < Net_Notifier_WebSocket_Connection :: STATE_CLOSED ) { $ client -> close ( ) ; ... | Closes a client socket and removes the client from the list of clients |
15,056 | protected function startCloseClient ( Net_Notifier_WebSocket_Connection $ client , $ code = Net_Notifier_WebSocket_Connection :: CLOSE_NORMAL , $ reason = '' ) { $ this -> log ( sprintf ( 'disconnecting client from %s for reason "%s" ... ' , $ client -> getIPAddress ( ) , $ reason ) , Net_Notifier_Logger :: VERBOSITY_C... | Initiates the closing handshake for a client connection |
15,057 | protected function & getReadClients ( & $ read ) { $ clients = array ( ) ; foreach ( $ this -> clients as $ client ) { if ( in_array ( $ client -> getSocket ( ) -> getRawSocket ( ) , $ read ) ) { $ clients [ ] = $ client ; } } return $ clients ; } | Gets an array of client connections whose sockets were read |
15,058 | protected function & getReadArray ( ) { $ readArray = array ( ) ; $ readArray [ ] = $ this -> socket -> getRawSocket ( ) ; foreach ( $ this -> clients as $ client ) { if ( $ client -> getState ( ) < Net_Notifier_WebSocket_Connection :: STATE_CLOSED ) { $ readArray [ ] = $ client -> getSocket ( ) -> getRawSocket ( ) ; }... | Gets an array of sockets to check for reading |
15,059 | protected function log ( $ message , $ priority = Net_Notifier_Logger :: VERBOSITY_MESSAGES , $ timestamp = true ) { if ( $ this -> logger instanceof Net_Notifier_Logger ) { $ this -> logger -> log ( $ message , $ priority , $ timestamp ) ; } return $ this ; } | Logs a message with the specified priority |
15,060 | public static function Atic13 ( $ ri , $ di , $ date1 , $ date2 , & $ rc , & $ dc , & $ eo ) { $ astrom = new iauASTROM ( ) ; IAU :: Apci13 ( $ date1 , $ date2 , $ astrom , $ eo ) ; IAU :: Aticq ( $ ri , $ di , $ astrom , $ rc , $ dc ) ; } | - - - - - - - - - - i a u A t i c 1 3 - - - - - - - - - - |
15,061 | public function preSave ( ) { $ script = '' ; foreach ( $ this -> getColumns ( ) as $ column ) { $ script .= $ this -> renderTemplate ( 'preSave' , array ( 'column' => $ this -> getTable ( ) -> getColumn ( $ column ) -> getFullyQualifiedName ( ) , 'setter' => $ this -> getColumnSetter ( $ column ) , 'getter' => $ this ... | Checks if need to move any uploaded files |
15,062 | public function read ( ) { if ( ! $ this -> valid ( ) ) { return null ; } $ resource = $ this -> resource ; $ item = $ this -> current ( ) ; $ this -> next ( ) ; $ event = new ResourceSerializeEvent ( $ resource , $ item ) ; $ this -> eventDispatcher -> dispatch ( FeedEvents :: RESOURCE_PRE_SERIALIZE , $ event ) ; $ it... | Wrapper that implements various calls so you can use the iterator in a simple while loop . |
15,063 | public function decorate ( Style $ style , string $ value ) : string { if ( ! $ style -> isExpand ( ) ) { return $ value ; } $ lineWidth = $ style -> getLineWidth ( ) ; $ align = $ style -> getAlignValue ( ) ; return str_pad ( $ value , $ lineWidth , ' ' , $ align ) ; } | Decora un valor aplicando un estilo |
15,064 | public function inheritConfigure ( Samurai \ Application $ app ) { $ app -> setEnv ( $ this -> getEnvFromEnvironmentVariables ( ) ) ; $ app -> addAppPathUsePsr4 ( __DIR__ , __NAMESPACE__ , 'Samurai\\' , self :: PRIORITY_LOW ) ; } | configure from application console |
15,065 | public function before_insert ( Orm \ Model $ obj ) { if ( $ obj instanceof SortableInterface ) { $ max = $ obj -> getSortMax ( ) ; } else { $ max = $ obj -> query ( ) -> max ( $ this -> _property ) ; } $ obj -> { $ this -> _property } = $ max + $ this -> _offset ; } | Sets the sort property to the current sort value |
15,066 | public static function stucture ( $ table ) { $ drop = "DROP TABLE IF EXISTS `$table`;" ; $ res = Driver :: read ( 'SHOW CREATE TABLE ' . $ table ) ; $ struct = $ res [ 0 ] [ 'Create Table' ] ; return "\n\n-- $table\n\n-- '$table' Table Structure\n$drop\n" . $ struct . ";\n\n" ; } | Get SQL query of table stucture . |
15,067 | public static function tables ( ) { $ tables = false ; $ Tables = Driver :: read ( 'SHOW TABLES' , Driver :: INDEX ) ; foreach ( $ Tables as $ row ) { $ target_tables [ ] = $ row [ 0 ] ; } if ( $ tables !== false ) { $ target_tables = array_intersect ( $ target_tables , $ tables ) ; } return $ target_tables ; } | Get all data tables created in the current database . |
15,068 | public static function info ( ) { $ database = Config :: get ( 'database.database' ) ; $ host = Config :: get ( 'database.host' ) ; $ username = Config :: get ( 'database.username' ) ; return "\n\n-- Database : $database\n-- Host : $host\n-- User : $username\n" ; } | Get info about database server connection . |
15,069 | public static function save ( $ file , $ query ) { $ path = Application :: $ root . "database/backup/$file" ; return ( new Filesystem ( ) ) -> put ( $ path , $ query ) ; } | Save exported data in sql file . |
15,070 | public static function fetch ( $ tables ) { foreach ( $ tables as $ table ) { $ result = Driver :: query ( "SELECT * FROM $table" , Driver :: INDEX ) ; $ fields = $ result -> columnCount ( ) ; $ rows = $ result -> rowCount ( ) ; $ data = Driver :: read ( "SELECT * FROM $table" , Driver :: INDEX ) ; $ content = ( ! isse... | fetch data inside data tables . |
15,071 | public static function export ( $ name ) { $ now = time ( ) ; $ tables = self :: tables ( ) ; $ query = self :: time ( $ now ) . self :: info ( ) ; $ query .= self :: database ( ) ; $ query .= self :: fetch ( $ tables ) ; $ file = ( $ name ? : config ( 'database.database' ) . '_' . $ now ) . '.sql' ; self :: file ( $ f... | Export the current database . |
15,072 | protected function getUuidFromUrl ( Url $ url ) { $ segments = $ url -> getPathSegments ( ) ; if ( count ( $ segments ) < 1 ) { throw new Exception ( 'Invalid UUID' ) ; } if ( count ( $ segments ) < 2 ) { return $ segments [ 0 ] ; } return $ segments [ count ( $ segments ) - 2 ] ; } | Extract the last part of a URL |
15,073 | private static function _initializeCW ( $ table ) { if ( isset ( static :: $ authModel ) && static :: $ authModel !== false ) { $ myClass = trim ( get_called_class ( ) , '\\ ' ) ; $ myAuth = null ; foreach ( Auth :: all ( ) as $ auth ) { if ( trim ( $ auth -> model , '\\ ' ) == $ myClass ) { $ myAuth = $ auth ; break ;... | Initialize ChickenWire featues |
15,074 | public function resaltPassword ( $ password , $ salt = '' ) { $ auth = self :: $ auth ; if ( $ auth -> useSalt == false ) { throw new \ Exception ( "This Auth does not use salting." , 1 ) ; } $ this -> setAttributes ( array ( $ auth -> saltField => $ salt , $ auth -> passwordField => $ password ) ) ; } | Re - encrypt the password |
15,075 | public function cast ( $ value , $ connection ) { if ( $ value === null ) return null ; switch ( $ this -> type ) { case self :: STRING : return ( string ) $ value ; case self :: INTEGER : return ( int ) $ value ; case self :: DECIMAL : return ( double ) $ value ; case self :: DATETIME : case self :: DATE : if ( ! $ va... | Casts a value to the column s type . |
15,076 | public static function cast ( $ value , $ phpType ) { if ( $ phpType === null or $ value === null ) return $ value ; switch ( $ phpType ) { case 'string' : return ( string ) $ value ; case 'float' : return ( float ) $ value ; case 'int' : return ( int ) $ value ; case 'bool' : if ( is_bool ( $ value ) ) return $ value ... | Convert a value to the named PHP scalar type using PHP s default conversion . |
15,077 | public static function fieldPropertyValue ( EarthIT_Schema_Field $ f , $ propUri , $ nonFakeDefault = null , $ fakeDefault = null ) { $ v = $ f -> getFirstPropertyValue ( $ propUri ) ; if ( $ v !== null ) return $ v ; $ isFake = $ f -> getFirstPropertyValue ( EarthIT_CMIPREST_NS :: IS_FAKE_FIELD ) ; return $ isFake ? $... | Get a field property value taking into account whether the field is fake or not and defaults for either case . |
15,078 | public static function singleErrorResponse ( $ status , $ message , array $ notes = array ( ) , array $ headers = array ( ) ) { return self :: multiErrorResponse ( $ status , array ( self :: errorStructure ( $ message , $ notes ) ) , $ headers ) ; } | Create a response to indicate a single error from a status code message and list of notes . |
15,079 | protected function mapElementToModelData ( ElementInterface $ child ) { $ this -> setModelValueFromElement ( $ child ) ; $ children = $ child -> getChildren ( ) ; if ( $ children -> count ( ) ) { $ this -> mapElementCollectionToModelData ( $ children ) ; } } | Maps element value to model data |
15,080 | protected function mapModelDataToElementCollection ( ElementCollection $ children ) { foreach ( $ children -> all ( ) as $ child ) { $ this -> mapModelDataToElement ( $ child ) ; } } | Maps data using recursion to all children |
15,081 | protected function setDefaultElementValue ( ElementInterface $ element ) { $ propertyPath = $ element -> getPropertyPath ( ) ; if ( $ propertyPath instanceof PropertyPathInterface ) { if ( $ this -> propertyAccessor -> isReadable ( $ this -> data , $ propertyPath ) ) { $ value = $ this -> propertyAccessor -> getValue (... | Sets value for element |
15,082 | protected function setModelValueFromElement ( ElementInterface $ child ) { $ propertyPath = $ child -> getPropertyPath ( ) ; if ( $ propertyPath instanceof PropertyPathInterface ) { if ( $ this -> propertyAccessor -> isWritable ( $ this -> data , $ propertyPath ) ) { if ( $ child -> hasTransformer ( ) ) { $ transformer... | Transforms value if needed or directly changes model property |
15,083 | protected function registerProviders ( Collection $ providers ) { $ providers -> each ( function ( $ providerClass ) { $ this -> app -> register ( $ providerClass ) ; } ) ; } | Register Unit Custom ServiceProviders . |
15,084 | protected function unitPath ( $ append = null ) { $ reflection = new \ ReflectionClass ( $ this ) ; $ realPath = realpath ( dirname ( $ reflection -> getFileName ( ) ) . '/../' ) ; if ( ! $ append ) { return $ realPath ; } return $ realPath . '/' . $ append ; } | Detects the unit base path so resources can be proper loaded on child classes . |
15,085 | protected function appendSuffix ( Name $ class ) { if ( $ class -> isFullyQualified ( ) ) { if ( count ( $ class -> parts ) == 1 ) { return $ class ; } return $ this -> append ( new Name ( '\\' . $ class -> toString ( ) ) ) ; } if ( $ this -> isImport ) { if ( ! $ this -> groupImport && count ( $ class -> parts ) == 1 ... | Append a suffix to the node . |
15,086 | protected function buildAndOr ( array & $ cls , array $ where , $ idx ) { if ( $ idx ) { $ cls [ ] = $ where [ 2 ] ; } if ( $ where [ 1 ] ) { $ cls [ ] = $ where [ 1 ] ; } } | build AND NOT part of the clause part |
15,087 | protected function buildCondition ( array $ cls , array $ where , array $ settings ) { if ( ! empty ( $ where [ 3 ] ) ) { $ cls [ ] = $ this -> quoteItem ( $ where [ 3 ] , $ settings , $ this -> isRaw ( $ where [ 3 ] , $ where [ 0 ] ) ) ; } if ( WhereInterface :: NO_OPERATOR !== $ where [ 4 ] ) { $ cls [ ] = $ where [ ... | Build col = val part |
15,088 | public static function error_handler ( $ number , $ message , $ file , $ line ) { $ msg = "$message in $file on line $line" ; if ( ( $ number !== E_NOTICE ) && ( $ number < 2048 ) ) { self :: errorMessage ( $ msg , true ) ; self :: customErrorMsg ( ) ; } return 0 ; } | Saves error message from exception |
15,089 | protected function processInputBuffer ( ) { if ( $ this -> request === null ) { if ( isset ( $ this -> inputBuffer [ HttpRequest :: MAX_HEADER_LENGTH ] ) ) { $ this -> logger -> warning ( "Client $this sent headers larger than " . HttpRequest :: MAX_HEADER_LENGTH . ' bytes' ) ; $ this -> inputBuffer = '' ; throw new Ht... | Handles HTTP request collection |
15,090 | public static function build ( array $ pointer , array $ context ) { if ( array_key_exists ( 'value' , $ pointer ) ) { return $ pointer [ 'value' ] ; } if ( ! empty ( $ pointer [ 'classname' ] ) ) { $ classname = NameResolver :: resolve ( $ pointer [ 'classname' ] , $ context ) ; return self :: buildByClassname ( $ cla... | Builds an object by the pointer |
15,091 | public function & block ( $ script , $ defer = false ) { $ script = new JavascriptObject ( ) ; $ script -> setType ( 'block' ) ; $ script -> setScript ( $ script ) ; $ script -> setDefer ( $ defer ) ; $ this -> add ( $ script ) ; return $ script ; } | Blocks with complete code . Use this for conditional scripts! |
15,092 | public function & bootstrap ( $ version , $ defer = false ) { $ url = $ this -> js_url . '/bootstrap-' . $ version . '.min.js' ; if ( str_replace ( BASEURL , BASEDIR , $ url ) ) { return $ this -> file ( $ url ) ; } } | Returns an file script block for the BS js lib |
15,093 | public function getFieldList ( ) { $ fields = dbQuery ( '\samson\cms\web\field\CMSField' ) -> join ( '\samson\cms\CMSNavField' ) -> cond ( 'StructureID' , $ this -> id ) -> exec ( ) ; $ items = '' ; if ( sizeof ( $ fields ) ) { foreach ( $ fields as $ field ) { $ items .= m ( 'structure' ) -> view ( 'form/field/field_i... | Fet list of additional fields of current structure |
15,094 | public function fillFields ( ) { foreach ( $ _POST as $ key => $ val ) { if ( $ key == 'ParentID' && $ val == 0 ) { $ this [ $ key ] = null ; } elseif ( $ key != 'StructureID' ) { $ this [ $ key ] = $ val ; } } $ this [ 'applicationGenerate' ] = isset ( $ _POST [ 'generate-application' ] ) && ( $ _POST [ 'generate-appl... | Filling the fields and creating relation of structure |
15,095 | public function beforePrepare ( Event $ event ) { $ command = $ event [ 'command' ] ; $ operation = $ command -> getOperation ( ) ; if ( $ command -> offsetGet ( 'collection' ) === 'user' || $ command -> getClient ( ) -> getCollectionName ( ) === 'user' ) { if ( strstr ( $ operation -> getURI ( ) , 'user' ) !== false )... | If the query is targets the users or files collection rewrite the URI . This allows the same entity commands to be used for data store entities as well as users and files . |
15,096 | public static function Go ( Event $ event ) { $ event -> getIO ( ) -> writeError ( '<info>Updating .gitignore: </info>' , false ) ; $ composer = $ event -> getComposer ( ) ; $ repositoryManager = $ composer -> getRepositoryManager ( ) ; $ installManager = $ composer -> getInstallationManager ( ) ; $ extraConfiguration ... | This runs the builder |
15,097 | protected function call ( array $ params ) { $ response = $ this -> client -> get ( null , array ( 'query' => $ params ) ) ; $ result = $ response -> json ( ) ; if ( $ result [ 'result' ] == 'ERR' ) { throw new ResponseException ( $ result [ 'message' ] , $ result [ 'code' ] ) ; } return $ result ; } | Sends a request to server |
15,098 | public function useSkillRelatedByStartPositionIdQuery ( $ relationAlias = null , $ joinType = Criteria :: LEFT_JOIN ) { return $ this -> joinSkillRelatedByStartPositionId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SkillRelatedByStartPositionId' , '\gossi\trixionary\model\SkillQu... | Use the SkillRelatedByStartPositionId relation Skill object |
15,099 | public function useSkillRelatedByEndPositionIdQuery ( $ relationAlias = null , $ joinType = Criteria :: LEFT_JOIN ) { return $ this -> joinSkillRelatedByEndPositionId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SkillRelatedByEndPositionId' , '\gossi\trixionary\model\SkillQuery' )... | Use the SkillRelatedByEndPositionId relation Skill object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.