idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
1,600
public static function get ( $ array , $ key = null , $ default = null , $ useDotSyntax = false ) { if ( empty ( $ array ) ) { return $ default ; } if ( is_null ( $ key ) ) { return $ array ; } if ( isset ( $ array [ $ key ] ) ) { return $ array [ $ key ] ; } if ( ! $ useDotSyntax ) { return $ default ; } $ keyParts = ...
Get an item from an array .
1,601
public static function filter ( array $ array , $ callback = null , $ default = [ ] , $ length = null ) { $ result = [ ] ; if ( is_callable ( $ callback ) ) { foreach ( $ array as $ key => $ value ) { if ( call_user_func ( $ callback , $ key , $ value ) ) { $ result [ $ key ] = $ value ; } } } else { reset ( $ array ) ...
Filter array elements with a given callback function .
1,602
public static function merge ( array $ array1 , array $ array2 , $ deep = false ) { if ( ! $ deep ) { return array_merge ( $ array1 , $ array2 ) ; } $ merged = $ array1 ; foreach ( $ array2 as $ key => $ value ) { if ( is_array ( $ value ) && isset ( $ merged [ $ key ] ) && is_array ( $ merged [ $ key ] ) ) { $ merged ...
Perform a merge on the given two arrays . Deep merge will merge the two arrays in full depth .
1,603
public static function toKeyIndex ( $ collection , $ key , $ useDotSyntax = false ) { $ keyIndexArray = [ ] ; foreach ( $ collection as $ item ) { $ itemArray = is_array ( $ item ) ? $ item : ( method_exists ( $ item , 'toArray' ) ? $ item -> toArray ( ) : [ ] ) ; $ keyValue = self :: get ( $ itemArray , $ key , null ,...
Return the array and replace the default keys with the values of the array based on the given key .
1,604
public static function toKeyGroup ( $ collection , $ key , $ useDotSyntax = false ) { $ keyGroupArray = [ ] ; foreach ( $ collection as $ item ) { $ itemArray = is_array ( $ item ) ? $ item : ( method_exists ( $ item , 'toArray' ) ? $ item -> toArray ( ) : [ ] ) ; $ keyValue = self :: get ( $ itemArray , $ key , null ,...
Group all array items by the given key .
1,605
public static function toKeyValue ( $ collection , $ key , $ value , $ useDotSyntax = false ) { $ keyValueArray = [ ] ; foreach ( $ collection as $ item ) { $ itemArray = is_array ( $ item ) ? $ item : ( method_exists ( $ item , 'toArray' ) ? $ item -> toArray ( ) : [ ] ) ; $ keyValue = self :: get ( $ itemArray , $ ke...
Return the array in a key - value form based on the given parameters for key and value .
1,606
public static function sortByKey ( $ array , $ key , $ useDotSyntax = false ) { uasort ( $ array , function ( $ a , $ b ) use ( $ key , $ useDotSyntax ) { $ valueA = self :: get ( $ a , $ key , null , $ useDotSyntax ) ; $ valueB = self :: get ( $ b , $ key , null , $ useDotSyntax ) ; if ( $ valueA == $ valueB ) { retur...
Sort an array by a given value based on the given key .
1,607
public function run ( ManifestInterface $ manifest ) { $ builder = new ProcedureBuilder ( ) ; $ processor = $ manifest -> getProcessor ( ) ; if ( $ this -> dispatcher ) { $ processor -> setEventDispatcher ( $ this -> dispatcher ) ; } $ manifest -> configureProcedureBuilder ( $ builder ) ; $ manifest -> configureProcess...
Configures and runs a manifest .
1,608
public static function create ( $ realPart , $ imaginaryPart = null ) { if ( is_string ( $ realPart ) ) { return self :: fromString ( $ realPart ) ; } if ( $ realPart instanceof ComplexType ) { return clone $ realPart ; } if ( is_null ( $ imaginaryPart ) ) { $ imaginaryPart = 0 ; } $ real = self :: convertType ( $ real...
Complex type factory
1,609
public static function fromPolar ( AbstractRationalType $ radius , AbstractRationalType $ theta ) { if ( self :: getRequiredType ( ) == self :: TYPE_GMP ) { return self :: fromGmpPolar ( $ radius , $ theta ) ; } return self :: fromNativePolar ( $ radius , $ theta ) ; }
Create complex type from polar co - ordinates
1,610
public static function fromNativePolar ( RationalType $ radius , RationalType $ theta ) { $ cos = RationalTypeFactory :: fromFloat ( cos ( $ theta ( ) ) ) ; $ sin = RationalTypeFactory :: fromFloat ( sin ( $ theta ( ) ) ) ; list ( $ realNumerator , $ realDenominator ) = self :: getRealPartsFromRadiusAndCos ( $ radius ,...
Create complex type from polar co - ordinates - Native version
1,611
public static function fromGmpPolar ( GMPRationalType $ radius , GMPRationalType $ theta ) { $ cos = RationalTypeFactory :: fromFloat ( cos ( $ theta ( ) ) ) ; $ sin = RationalTypeFactory :: fromFloat ( sin ( $ theta ( ) ) ) ; $ rNum = TypeFactory :: create ( 'int' , gmp_strval ( gmp_mul ( $ radius -> numerator ( ) -> ...
Create complex type from polar co - ordinates - GMP version
1,612
protected static function convertType ( $ original ) { if ( $ original instanceof AbstractRationalType ) { return RationalTypeFactory :: create ( $ original -> numerator ( ) -> get ( ) , $ original -> denominator ( ) -> get ( ) ) ; } if ( is_numeric ( $ original ) ) { if ( is_int ( $ original ) ) { return RationalTypeF...
Convert to RationalType
1,613
public function listFiles ( $ depth = 0 , $ filter = null , $ asHandlers = false ) { return $ this -> listContents ( $ depth , $ filter , 'file' , $ asHandlers ) ; }
Lists all files in a directory
1,614
public function listDirs ( $ depth = 0 , $ filter = null , $ asHandlers = false ) { return $ this -> listContents ( $ depth , $ filter , 'dir' , $ asHandlers ) ; }
Lists all directories in a directory
1,615
public function listContents ( $ depth = 0 , $ filter = null , $ type = 'all' , $ asHandlers = false ) { $ pattern = $ this -> path . '/*' ; if ( is_array ( $ filter ) ) { $ filters = $ filter ; $ filter = new Filter ; foreach ( $ filters as $ f => $ type ) { if ( ! is_int ( $ f ) ) { $ f = $ type ; $ type = null ; } $...
Lists all files and directories in a directory
1,616
private function loadAssignments ( $ userId ) { if ( ! isset ( $ this -> _assignments [ $ userId ] ) ) { $ query = ( new Query ) -> select ( 'item_name' ) -> from ( $ this -> assignmentTable ) -> where ( [ 'user_id' => $ userId ] ) ; $ this -> _assignments [ $ userId ] = $ query -> column ( $ this -> db ) ; } }
Load data . If avaliable in memory get from memory If no get from cache . If no avaliable get from database .
1,617
public function route ( Application $ app , Request $ request ) { $ url = $ request -> getPathInfo ( ) ; $ method = $ request -> getMethod ( ) ; foreach ( $ this -> routes as $ route ) { if ( $ route -> getMethod ( ) == $ method ) { $ matches = $ route -> matches ( $ url ) ; if ( $ matches !== false ) { $ app [ 'emitte...
Routes the request and returns a Response .
1,618
public function getRoute ( $ name ) { if ( empty ( $ name ) ) { throw new \ InvalidArgumentException ( "Route name not provided." ) ; } foreach ( $ this -> routes as $ route ) { if ( $ route -> getName ( ) === $ name ) { return $ route ; } } throw new \ Exception ( "Route \"$name\" not found." ) ; }
Returns a route by name .
1,619
public function checkAccess ( $ attributes , $ object = null , string $ message = 'Access Denied.' ) { $ this -> denyAccessUnlessGranted ( $ attributes , $ object , $ message ) ; }
Throws an exception unless the attributes are granted against the current authentication token and optionally supplied object .
1,620
public function seek ( $ offset , $ whence = SEEK_SET ) { if ( ! is_int ( $ offset ) && ! is_numeric ( $ offset ) ) { return false ; } $ offset = ( int ) $ offset ; if ( $ offset < 0 ) { return false ; } $ key = $ this -> iterator -> key ( ) ; if ( ! is_int ( $ key ) && ! is_numeric ( $ key ) ) { $ key = 0 ; $ this -> ...
Seek the iterator .
1,621
public function request ( $ message_name , $ request_datum ) { $ io = new AvroStringIO ( ) ; $ encoder = new AvroIOBinaryEncoder ( $ io ) ; $ this -> write_handshake_request ( $ encoder ) ; $ this -> write_call_request ( $ message_name , $ request_datum , $ encoder ) ; $ call_request = $ io -> string ( ) ; if ( $ this ...
Writes a request message and reads a response or error message .
1,622
public function write_handshake_request ( AvroIOBinaryEncoder $ encoder ) { if ( $ this -> transceiver -> is_connected ( ) ) return ; $ remote_name = $ this -> transceiver -> remote_name ( ) ; $ local_hash = $ this -> local_protocol -> md5 ( ) ; $ remote_hash = ( ! isset ( $ this -> remote_hash [ $ remote_name ] ) ) ? ...
Write the handshake request .
1,623
public function read_handshake_response ( AvroIOBinaryDecoder $ decoder ) { if ( $ this -> transceiver -> is_connected ( ) ) return true ; $ established = false ; $ handshake_response = $ this -> handshake_requestor_reader -> read ( $ decoder ) ; $ match = $ handshake_response [ "match" ] ; switch ( $ match ) { case 'B...
Reads and processes the handshake response message .
1,624
public function process_handshake ( AvroIOBinaryDecoder $ decoder , AvroIOBinaryEncoder $ encoder , Transceiver $ transceiver ) { if ( $ transceiver -> is_connected ( ) ) return $ transceiver -> get_remote ( ) ; $ handshake_request = $ this -> handshake_responder_reader -> read ( $ decoder ) ; $ client_hash = $ handsha...
Processes an RPC handshake .
1,625
public static function fromRGB ( $ red , $ green , $ blue ) { if ( $ red < 0 || $ red > 255 || $ green < 0 || $ green > 255 || $ blue < 0 || $ blue > 255 ) { throw new InvalidArgumentException ( 'Values $red, $blue and $green can only be 0 to 255' ) ; } $ red /= 255 ; $ green /= 255 ; $ blue /= 255 ; $ min = min ( $ re...
Creates a Color instance based on the given RGB - formatted color .
1,626
public static function fromHEX ( $ hex ) { $ hex = preg_replace ( '/[^0-9A-Fa-f]/' , '' , $ hex ) ; $ rgb = [ ] ; if ( strlen ( $ hex ) == 6 ) { $ colorVal = hexdec ( $ hex ) ; $ rgb [ 'red' ] = 0xFF & ( $ colorVal >> 0x10 ) ; $ rgb [ 'green' ] = 0xFF & ( $ colorVal >> 0x8 ) ; $ rgb [ 'blue' ] = 0xFF & $ colorVal ; } e...
Creates a Color instance based on the given Hexadecimal - formatted color .
1,627
public static function fromHSV ( $ hue , $ saturation , $ value ) { if ( $ hue < 0 || $ hue > 360 || $ saturation < 0 || $ saturation > 100 || $ value < 0 || $ value > 100 ) { throw new InvalidArgumentException ( 'Value $hue can only be 0 to 360, $saturation and $value can only be 0 to 100' ) ; } $ hue /= 360 ; $ satur...
Creates a Color instance based on the given HSV - formatted color .
1,628
public static function fromHSL ( $ hue , $ saturation , $ lightness ) { if ( $ hue < 0 || $ hue > 360 || $ saturation < 0 || $ saturation > 100 || $ lightness < 0 || $ lightness > 100 ) { throw new InvalidArgumentException ( 'Value $hue can only be 0 to 360, $saturation and $lightness can only be 0 to 100' ) ; } return...
Creates a Color instance based on the given HSL - formatted color .
1,629
public function lighten ( $ amount ) { if ( $ amount < 0 || $ amount > 100 ) { throw new InvalidArgumentException ( 'The given amount must be between 0 and 100' ) ; } $ amount /= 100 ; $ this -> lightness += ( 100 - $ this -> lightness ) * $ amount ; return $ this ; }
Alters the color by lightening it with the given percentage .
1,630
public function darken ( $ amount ) { if ( $ amount < 0 || $ amount > 100 ) { throw new InvalidArgumentException ( 'The given amount must be between 0 and 100' ) ; } $ amount /= 100 ; $ this -> lightness -= $ this -> lightness * $ amount ; return $ this ; }
Alters the color by darkening it with the given percentage .
1,631
public function saturate ( $ amount ) { if ( $ amount < 0 || $ amount > 100 ) { throw new InvalidArgumentException ( 'The given amount must be between 0 and 100' ) ; } $ amount /= 100 ; $ this -> saturation += ( 100 - $ this -> saturation ) * $ amount ; return $ this ; }
Alters the color by saturating it with the given percentage .
1,632
public function desaturate ( $ amount ) { if ( $ amount < 0 || $ amount > 100 ) { throw new InvalidArgumentException ( 'The given amount must be between 0 and 100' ) ; } $ amount /= 100 ; $ this -> saturation -= $ this -> saturation * $ amount ; return $ this ; }
Alters the color by desaturating it with the given percentage .
1,633
public function toHSL ( ) { return [ round ( $ this -> hue ) , round ( $ this -> saturation ) , round ( $ this -> lightness ) , ] ; }
Outputs the color using the HSL format .
1,634
public function toRGB ( ) { $ h = $ this -> hue ; $ s = $ this -> saturation / 100 ; $ l = $ this -> lightness / 100 ; $ r ; $ g ; $ b ; $ c = ( 1 - abs ( 2 * $ l - 1 ) ) * $ s ; $ x = $ c * ( 1 - abs ( fmod ( ( $ h / 60 ) , 2 ) - 1 ) ) ; $ m = $ l - ( $ c / 2 ) ; if ( $ h < 60 ) { list ( $ r , $ g , $ b ) = [ $ c , $ ...
Outputs the color using the RGB format .
1,635
public function toHEX ( ) { list ( $ red , $ green , $ blue ) = $ this -> toRGB ( ) ; return strtoupper ( sprintf ( '#%02x%02x%02x' , $ red , $ green , $ blue ) ) ; }
Outputs the color using the HEX format .
1,636
public function toHSV ( ) { list ( $ red , $ green , $ blue ) = $ this -> toRGB ( ) ; $ red /= 255 ; $ green /= 255 ; $ blue /= 255 ; $ maxRGB = max ( $ red , $ green , $ blue ) ; $ minRGB = min ( $ red , $ green , $ blue ) ; $ chroma = $ maxRGB - $ minRGB ; $ value = 100 * $ maxRGB ; if ( $ chroma == 0 ) { return [ 0 ...
Outputs the color using the HSV format .
1,637
public static function triplesToQuads ( array $ triples ) { $ quads = array ( ) ; foreach ( $ triples as $ t ) { $ quads [ ] = new Quad ( new IRI ( $ t [ 's' ] ) , new IRI ( $ t [ 'p' ] ) , ( $ t [ 'o_type' ] == 'uri' ) ? new IRI ( $ t [ 'o' ] ) : new TypedValue ( $ t [ 'o' ] , ( isset ( $ t [ 'o_datatype' ] ) && $ t [...
Converts an array of ARC2 triples into an array of RDF quads in JsonLD library format .
1,638
public static function indexToQuads ( array $ index ) { $ quads = array ( ) ; foreach ( $ index as $ subject => $ predicates ) { foreach ( $ predicates as $ predicate => $ objects ) { foreach ( $ objects as $ object ) { $ quads [ ] = new Quad ( new IRI ( $ subject ) , new IRI ( $ predicate ) , ( $ object [ 'type' ] != ...
Converts an ARC2 index into an array of RDF quads in JsonLD library format .
1,639
public static function quadsToTriples ( array $ quads ) { $ arcTriples = array ( ) ; foreach ( $ quads as $ q ) { $ arcTriples [ ] = array ( 's' => ( string ) $ q -> getSubject ( ) , 'p' => ( string ) $ q -> getProperty ( ) , 'o' => ( is_a ( $ q -> getObject ( ) , 'ML\JsonLD\TypedValue' ) ) ? $ q -> getObject ( ) -> ge...
Converts an array of RDF quads in JsonLD library format into an array of ARC2 triples .
1,640
private function createCoreFunction ( Closure $ core ) : Closure { return function ( ServerRequestInterface $ request , ResponseInterface $ response , Route $ route ) use ( $ core ) { return call_user_func_array ( $ core , [ & $ request , & $ response , & $ route ] ) ; } ; }
Create the core function
1,641
public static function contains ( $ haystack , $ needle ) { if ( empty ( $ haystack ) || empty ( $ needle ) ) { return false ; } if ( ! is_array ( $ needle ) ) { return mb_strpos ( $ haystack , $ needle ) !== false ; } foreach ( ( array ) $ needle as $ str_needle ) { if ( ! empty ( $ str_needle ) && mb_strpos ( $ hayst...
Check if a given string contains a given substring .
1,642
public function add ( callable $ callback ) { $ reflection = new \ ReflectionFunction ( $ callback ) ; $ params = $ reflection -> getParameters ( ) ; if ( empty ( $ params ) ) { throw new \ InvalidArgumentException ( "Invalid exception callback: Has no arguments. Expected at least one." ) ; } $ class = $ params [ 0 ] -...
Adds an exception callback .
1,643
public function offsetExists ( $ key ) { return isset ( $ this -> data [ $ key ] ) || array_key_exists ( $ key , $ this -> data ) ; }
Determines whether a item exists .
1,644
public function getByPrimary ( $ value ) { foreach ( $ this -> data as $ entity ) { $ primaryPropertyName = $ entity :: getReflection ( ) -> getPrimaryProperty ( ) -> getName ( ) ; $ primaryValue = $ entity -> { $ primaryPropertyName } ; if ( $ primaryValue === $ value && $ primaryValue !== null ) { return $ entity ; }...
Get entity by primary value
1,645
public function reset ( $ items = null ) { $ this -> items = [ ] ; if ( ( func_get_args ( ) > 0 ) && is_array ( $ items ) ) { $ this -> items = $ items ; } return $ this ; }
Resets the collection with the specified array content .
1,646
public function pull ( $ key ) { if ( $ this -> has ( $ key ) ) { $ pulled = $ this -> get ( $ key ) ; $ this -> remove ( $ key ) ; return $ pulled ; } return false ; }
Pull an item from the collection and remove it from the collection .
1,647
public function register ( ) { $ this -> app -> singleton ( 'fielder' , function ( $ app ) { $ fielder = new Fielder ( $ app ) ; $ fielder -> register ( $ this -> fields ) ; return $ fielder ; } ) ; $ this -> app -> alias ( 'fielder' , Fielder :: class ) ; }
Register fielder services .
1,648
public function dispatchAssets ( ) { $ this -> app [ 'asset.factory' ] -> add ( 'fielder-vendors' , [ 'path' => FIELDER_URI . 'public/js/vendors.js' , ] ) -> area ( 'admin' ) ; $ this -> app [ 'asset.factory' ] -> add ( 'fielder' , [ 'path' => FIELDER_URI . 'public/js/fielder.js' , 'dependences' => [ 'fielder-vendors' ...
Dispatch fielder assets .
1,649
public function indexAction ( ) { $ service = $ this -> getLayoutService ( ) ; try { $ theme = $ service -> getTheme ( $ this -> params ( ) -> fromRoute ( 'theme' ) ) ; } catch ( RuntimeException $ e ) { $ this -> flashMessenger ( ) -> addMessage ( $ e -> getMessage ( ) ) ; return $ this -> redirect ( ) -> toRoute ( 's...
Shows a layout .
1,650
private function importLine ( ) { $ import = false ; $ from = false ; while ( ! $ this -> eol ( ) ) { $ c = $ this -> peek ( ) ; $ tok = null ; $ m = null ; if ( $ c === '\\' ) { $ m = $ this -> get ( 2 ) ; } elseif ( $ this -> scan ( '/[,\\.;\\*]+/' ) ) { $ tok = 'OPERATOR' ; } elseif ( $ this -> scan ( "/[ \t]+/" ) )...
mini - scanner to handle highlighting module names in import lines
1,651
public function check_markup ( $ text , $ format_id = null , $ langcode = '' , $ cache = FALSE ) { return check_markup ( $ text , $ format_id , $ langcode , $ cache ) ; }
Run all the enabled filters on a piece of text .
1,652
public function filter_dom_serialize_escape_cdata_element ( $ dom_document , $ dom_element , $ comment_start = '//' , $ comment_end = '' ) { return filter_dom_serialize_escape_cdata_element ( $ dom_document , $ dom_element , $ comment_start , $ comment_end ) ; }
Adds comments around the <!CDATA section in a dom element .
1,653
public static function dataTypeToEavColumn ( $ type ) { switch ( $ type ) { case Property :: DATA_TYPE_FLOAT : return 'value_float' ; break ; case Property :: DATA_TYPE_BOOLEAN : case Property :: DATA_TYPE_INTEGER : return 'value_integer' ; break ; case Property :: DATA_TYPE_TEXT : case Property :: DATA_TYPE_PACKED_JSO...
Returns EAV column by property data type .
1,654
public function getInfo ( $ info_name ) { $ value = null ; if ( $ info_name == 'provider' ) $ value = $ this -> provider ; else if ( property_exists ( $ this -> profile , $ info_name ) ) $ value = $ this -> profile -> $ info_name ; return $ value ; }
Query the info for a specific value
1,655
public function success ( UserInterface $ user ) { $ repository = App :: make ( 'Ipunkt\SocialAuth\Repositories\SocialLoginRepository' ) ; $ login = $ repository -> create ( ) ; $ login -> setIdentifier ( $ this -> identifier ) ; $ login -> setProvider ( $ this -> provider ) ; $ login -> setUser ( $ user -> getAuthIden...
Notify the provider of the RegisterInfo that the user was now successfuly registered .
1,656
public function process ( EventInterface $ event ) { $ events = $ this -> getEventManager ( ) ; $ mapper = $ this -> getMapper ( ) ; $ optionsProvider = $ this -> getOptionsProvider ( ) ; $ translator = $ this -> getTranslator ( ) ; $ pane = $ event -> getParam ( 'pane' ) ; if ( ! $ optionsProvider -> hasIdentifier ( $...
To permanently delete elements from the trash
1,657
public function addQueue ( $ queue ) { if ( ! in_array ( $ queue , $ this -> queuesWorkedOn ) ) { $ this -> queuesWorkedOn [ ] = $ queue ; } return $ this ; }
add a worked queue
1,658
public function get ( $ path , $ params = array ( ) , $ vars = array ( ) ) { $ request = $ this -> request ( ) ; $ request = $ this -> prepareRequest ( $ request ) ; $ response = $ request -> get ( $ this -> endpoint . $ path , $ params , $ vars ) ; return $ this -> handleResponse ( $ response ) ; }
Perform a GET request to the API .
1,659
public function post ( $ path , $ vars = array ( ) ) { $ request = $ this -> request ( ) ; $ request = $ this -> prepareRequest ( $ request ) ; $ response = $ request -> post ( $ this -> endpoint . $ path , $ vars ) ; return $ this -> handleResponse ( $ response ) ; }
Perform a POST request to the API .
1,660
public function delete ( $ path , $ params = array ( ) ) { $ request = $ this -> request ( ) ; $ request = $ this -> prepareRequest ( $ request ) ; $ response = $ request -> delete ( $ this -> endpoint . $ path , $ params ) ; return $ this -> handleResponse ( $ response ) ; }
Perform a DELETE request to the API .
1,661
protected function prepareRequest ( $ request ) { $ request -> header ( 'X-M2X-KEY' , $ this -> apiKey ) ; $ request -> header ( 'User-Agent' , $ this -> userAgent ) ; return $ request ; }
Sets the common headers for each request to the API .
1,662
protected function handleResponse ( HttpResponse $ response ) { $ this -> lastResponse = $ response ; if ( $ response -> success ( ) ) { return $ response ; } throw new M2XException ( $ response ) ; }
Checks the HttpResponse for errors and throws an exception if no errors are encountered the HttpResponse is returned .
1,663
public function sqlSearch ( $ params ) { $ this -> load ( $ params ) ; $ where = [ 'id' => sprintf ( 'id = "%s"' , $ this -> id ) , 'status' => sprintf ( 'status = "%s"' , $ this -> status ) , 'created_at' => sprintf ( 'created_at = "%s"' , $ this -> created_at ) , 'updated_at' => sprintf ( 'updated_at = "%s"' , $ this...
Creates data provider instance with search query and sql applied
1,664
public static function set ( $ error , $ key = null ) { if ( $ key ) { static :: $ error [ $ key ] [ ] = $ error ; } else { static :: $ error [ ] = $ error ; } }
Set specific error .
1,665
public function db_add_field ( $ table , $ field , $ spec , $ keys_new = array ( ) ) { db_add_field ( $ table , $ field , $ spec , $ keys_new ) ; }
Adds a new field to a table .
1,666
public function db_query_range ( $ query , $ from , $ count , array $ args = array ( ) , array $ options = array ( ) ) { return db_query_range ( $ query , $ from , $ count , $ args , $ options ) ; }
Executes a query against the active database restricted to a range .
1,667
protected function localizeCollection ( array $ prefixes , RouteCollection $ collection ) { $ removeRoutes = array ( ) ; $ newRoutes = new RouteCollection ( ) ; foreach ( $ collection -> all ( ) as $ name => $ route ) { $ routeLocale = $ route -> getDefault ( self :: LOCALE_PARAM ) ; if ( $ routeLocale !== null ) { if ...
Localize a route collection .
1,668
protected function localizeCollectionLocaleParameter ( $ prefix , RouteCollection $ collection ) { $ localizedPrefixes = array ( ) ; foreach ( $ collection -> all ( ) as $ name => $ route ) { $ locale = $ route -> getDefault ( self :: LOCALE_PARAM ) ; if ( $ locale === null ) { $ routePrefix = $ prefix ; } else { if ( ...
Localize the prefix _locale of all routes .
1,669
public function actionFillIndex ( ) { try { $ this -> client -> ping ( ) ; } catch ( NoNodesAvailableException $ e ) { $ this -> stderr ( $ e -> getMessage ( ) . ', maybe you first need to configure and run elasticsearch' . PHP_EOL ) ; return ; } foreach ( $ this -> applicables as $ indexName => $ model ) { if ( true =...
Creates and fills in indices
1,670
private static function prepareIndexConfig ( ) { foreach ( self :: $ storage as $ className => $ id ) { $ key = IndexHelper :: storageClassToType ( $ className ) ; $ config = self :: prepareMapping ( $ className ) ; if ( false === empty ( $ config ) ) { self :: $ indexConfig [ 'body' ] [ 'mappings' ] [ $ key ] = $ conf...
Prepares config for all applicable property storage
1,671
private static function prepareMapping ( $ className ) { $ mapping = [ ] ; foreach ( self :: $ languages as $ iso_639_2t ) { if ( true === isset ( self :: $ langToAnalyzer [ $ iso_639_2t ] ) ) { switch ( $ className ) { case StaticValues :: class : self :: $ staticMapping [ 'properties' ] [ Search :: STATIC_VALUES_FILE...
Prepares language based index mappings according to languages defined in app config multilingual
1,672
public static function getBonusByRole ( string $ role ) : float { switch ( $ role ) { case Row :: GOALKEEPER : return GoalsNormalizer :: STANDARD_GOALKEEPER_MALUS ; case Row :: DEFENDER : return GoalsNormalizer :: FORMAT_2017_DEFENDER_GOAL_BONUS ; case Row :: MIDFIELDER : return GoalsNormalizer :: FORMAT_2017_MIDFIELDE...
Returns the goal bonus given the role
1,673
public function execute ( ) { try { $ this -> filesystem -> mirror ( $ this -> demoDataPath , $ this -> outPath ) ; } catch ( IOException $ exception ) { $ items = [ "Error occurred while copying files:" , $ exception -> getMessage ( ) , "\n" ] ; $ message = implode ( " " , $ items ) ; echo $ message ; return 1 ; } ret...
Copies DemoData images from vendor directory of needed edition to the OXID eShop OUT directory .
1,674
public function format ( $ data , $ multiple = false ) { if ( $ multiple === true || $ data instanceof Collection ) { foreach ( $ data as $ key => $ value ) { $ data [ $ key ] = $ this -> runFormatters ( $ value ) ; } } else { $ data = $ this -> runFormatters ( $ data ) ; } return $ data ; }
Format the given data .
1,675
protected function runFormatters ( $ data ) { $ data = self :: formatAble ( $ data ) ; foreach ( $ this -> formatters as $ formatter ) { $ data = $ formatter -> format ( $ data ) ; } return $ data -> getObject ( ) ; }
Run the Formatters on the given data .
1,676
public function publishedPostsAction ( ) { $ this -> routeParam ( ) -> mapPageTo ( $ this -> queryService ) ; if ( $ tag = $ this -> params ( ) -> fromRoute ( 'tag' ) ) { $ collection = $ this -> queryService -> findPublishedPostsByTag ( $ tag ) ; } else { $ collection = $ this -> queryService -> findPublishedPosts ( )...
Published post entries retrieval
1,677
public function publishedPostAction ( ) { $ encryptedId = $ this -> params ( ) -> fromRoute ( 'id' ) ; if ( $ decryptedId = $ this -> cryptEngine -> decrypt ( $ encryptedId ) ) { $ post = $ this -> queryService -> findPublishedPostById ( $ decryptedId ) ; } if ( ! isset ( $ post ) ) { return $ this -> nullResponse ( ) ...
Published post entry retrieval
1,678
function buildPayload ( & $ payload ) { if ( is_array ( $ payload ) ) { $ payload = $ this -> array_map_deep ( $ payload , array ( $ this , 'buildPayloadItemInfo' ) ) ; } else { $ payload = $ this -> makePayloadBuilder ( $ payload ) ; $ this -> buildPayload ( $ payload ) ; } return $ payload ; }
Parse the payload to check for PayloadBuilder objects and make them .
1,679
function buildPayloadItemInfo ( $ key , $ item ) { if ( is_object ( $ item ) ) { $ key = ( $ this -> getPayloadBuilderKey ( $ item ) ) ? $ this -> getPayloadBuilderKey ( $ item ) : $ key ; $ item = $ this -> makePayloadBuilder ( $ item ) ; } return array ( 'key' => $ key , 'item' => $ item ) ; }
The array_map_deep callback for buildPayload . If the array part is an object it attempts to make payloadBuilder .
1,680
function makeQuery ( ) { $ query = array ( ) ; foreach ( $ this -> query as $ paramater ) { $ operator = ( $ paramater [ 1 ] != '=' ) ? $ paramater [ 1 ] : '' ; $ query [ $ paramater [ 0 ] . $ operator ] = $ paramater [ 2 ] ; } return $ query ; }
Return an array ready to be http encoded .
1,681
function makeResource ( ) { $ resource = $ this -> resource ; if ( $ this -> id ) $ resource .= '/' . $ this -> id ; return $ resource ; }
Return the resource url part .
1,682
public function record ( $ str , $ dummy1 = null , $ dummy2 = null ) { if ( $ dummy1 !== null || $ dummy2 !== null ) { throw new Exception ( 'Luminous\\Core\\Scanners\\StatefulScanner::record does not currently observe its second and third ' . 'parameters' ) ; } $ c = & $ this -> tokenTreeStack [ count ( $ this -> toke...
Records a string as a child of the currently active token
1,683
public function main ( ) { $ this -> setup ( ) ; while ( ! $ this -> eos ( ) ) { $ p = $ this -> pos ( ) ; $ state = $ this -> stateName ( ) ; $ this -> loadTransitions ( ) ; list ( $ nextPatternData , $ nextPatternIndex , $ nextPatternMatches ) = $ this -> nextStartData ( ) ; list ( $ endIndex , $ endMatches ) = $ thi...
Generic main function which observes the transition table
1,684
protected function collapseTokenTree ( $ node ) { $ text = '' ; foreach ( $ node [ 'children' ] as $ c ) { if ( is_string ( $ c ) ) { $ text .= Utils :: escapeString ( $ c ) ; } else { $ text .= $ this -> collapseTokenTree ( $ c ) ; } } $ tokenName = $ node [ 'token_name' ] ; $ token = array ( $ node [ 'token_name' ] ,...
Recursive function to collapse the token tree into XML
1,685
public function createNewToken ( $ value , $ expire = 300 ) { $ this -> token = [ 'value' => sha1 ( rand ( 10000 , getrandmax ( ) ) . $ value ) , 'expire' => ( int ) $ expire , 'start' => time ( ) ] ; $ _SESSION [ 'pop_csrf' ] = serialize ( $ this -> token ) ; return $ this ; }
Set the token of the csrf form element
1,686
protected function assignMedia ( ) { if ( \ Sifo \ Domains :: getInstance ( ) -> getDevMode ( ) ) { $ packer = new \ Sifo \ JsPacker ( ) ; $ packer -> packMedia ( ) ; $ packer = new \ Sifo \ CssPacker ( ) ; $ packer -> packMedia ( ) ; } $ this -> assign ( 'media' , \ Sifo \ Config :: getInstance ( ) -> getConfig ( 'css...
Assign a variable to the tpl with the HTML code to load the JS and CSS files .
1,687
public function beforeDelete ( ) { if ( parent :: beforeDelete ( ) === false ) { return false ; } $ storage = PropertyStorageHelper :: storageById ( $ this -> storage_id ) ; return $ storage -> beforePropertyDelete ( $ this ) ; }
Perform beforeDelete events
1,688
public function beforeValidate ( ) { $ validation = parent :: beforeValidate ( ) ; return $ validation && PropertyStorageHelper :: storageById ( $ this -> storage_id ) -> beforePropertyValidate ( $ this ) ; }
Perform beforeValidate events
1,689
public static function castValueToDataType ( $ value , $ type ) { switch ( $ type ) { case Property :: DATA_TYPE_FLOAT : return empty ( $ value ) ? null : ( float ) $ value ; break ; case Property :: DATA_TYPE_BOOLEAN : return empty ( $ value ) ? null : ( bool ) $ value ; break ; case Property :: DATA_TYPE_INTEGER : re...
Casts value to data type
1,690
public static function validationCastFunction ( $ type ) { switch ( $ type ) { case Property :: DATA_TYPE_FLOAT : return 'floatval' ; break ; case Property :: DATA_TYPE_BOOLEAN : return 'boolval' ; break ; case Property :: DATA_TYPE_INTEGER : return 'intval' ; break ; case Property :: DATA_TYPE_STRING : case Property :...
Returns name of function for filtering data casting
1,691
public static function findById ( $ id , $ throwException = true ) { $ e = $ throwException ? new ServerErrorHttpException ( "Property with id $id not found" ) : false ; return static :: loadModel ( $ id , false , true , 86400 , $ e , true ) ; }
A proxy method for LoadModel
1,692
public function isRequired ( ) { $ params = $ this -> params ; $ required = boolval ( ArrayHelper :: getValue ( $ params , Property :: PACKED_ADDITIONAL_RULES . '.required' , false ) ) ; return $ required ; }
check if property required
1,693
public function getTimezoneByIP ( $ ipAddress = '' ) { $ ipAddress = ( empty ( $ ipAddress ) ? $ this -> request -> server -> get ( 'REMOTE_ADDR' ) : $ ipAddress ) ; $ countryCode = $ this -> getCountryCode2ByIP ( $ ipAddress ) ; if ( ! function_exists ( 'geoip_time_zone_by_country_and_region' ) ) { throw new Exception...
Get the corresponding timezone according to ip address .
1,694
public function getCountryCode2ByIP ( $ ipAddress = '' ) { $ ipAddress = ( empty ( $ ipAddress ) ? $ this -> request -> server -> get ( 'REMOTE_ADDR' ) : $ ipAddress ) ; if ( ! function_exists ( 'geoip_country_code_by_name' ) ) { throw new Exception ( 'geoip_country_code_by_name() function is not available.' ) ; } retu...
Get the country ISO2A code by ip .
1,695
public function getCountryCode3ByIP ( $ ipAddress = '' ) { $ ipAddress = ( empty ( $ ipAddress ) ? $ this -> request -> server -> get ( 'REMOTE_ADDR' ) : $ ipAddress ) ; if ( ! function_exists ( 'geoip_country_code3_by_name' ) ) { throw new Exception ( 'geoip_country_code3_by_name() function is not available.' ) ; } re...
Get the country ISO3A code by ip .
1,696
public function render ( $ depth = 0 , $ indent = null , $ inner = false ) { if ( ! $ this -> renderValue ) { $ this -> setAttribute ( 'value' , '' ) ; } return parent :: render ( $ depth , $ indent , $ inner ) ; }
Render the password element
1,697
protected function getAvailablePageWrapper ( $ url , $ page , $ rel = null ) { return sprintf ( $ this -> availablePageWrapper , $ url , $ page ) ; }
Get html tag for an available link .
1,698
protected function getPreviousButton ( ) { if ( $ this -> paginator -> currentPage ( ) <= 1 ) { return $ this -> getDisabledLink ( $ this -> previousButtonText ) ; } $ url = $ this -> paginator -> url ( $ this -> paginator -> currentPage ( ) - 1 ) ; return $ this -> getPrevNextPageLinkWrapper ( $ url , $ this -> previo...
Get html tag the previous page link .
1,699
protected function getNextButton ( ) { if ( ! $ this -> paginator -> hasMorePages ( ) ) { return $ this -> getDisabledLink ( $ this -> nextButtonText ) ; } $ url = $ this -> paginator -> url ( $ this -> paginator -> currentPage ( ) + 1 ) ; return $ this -> getPrevNextPageLinkWrapper ( $ url , $ this -> nextButtonText ,...
Get html tag for the next page link .