idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
12,500
private function get ( string $ tag , string $ memberof = '' , bool $ grouped = true ) { if ( empty ( $ this -> parsed ) ) { $ this -> parse ( ) ; } if ( ! empty ( $ this -> parsed ) ) { $ res = [ ] ; foreach ( $ this -> parsed as $ p ) { if ( ! empty ( $ p [ 'tags' ] ) && ( ( $ i = \ bbn \ x :: find ( $ p [ 'tags' ] , [ 'tag' => $ tag ] ) ) !== false ) && ( ( empty ( $ memberof ) && ( \ bbn \ x :: find ( $ p [ 'tags' ] , [ 'tag' => 'memberof' ] ) === false ) ) || ( ! empty ( $ memberof ) && ( ( $ k = \ bbn \ x :: find ( $ p [ 'tags' ] , [ 'tag' => 'memberof' ] ) ) !== false ) && ( $ p [ 'tags' ] [ $ k ] [ 'name' ] === $ memberof ) ) ) ) { if ( $ grouped ) { $ tmp = $ p [ 'tags' ] [ $ i ] ; if ( $ p [ 'tags' ] [ $ i ] [ 'tag' ] !== 'file' ) { $ tmp [ 'description' ] = $ p [ 'description' ] ; } unset ( $ p [ 'tags' ] [ $ i ] , $ tmp [ 'tag' ] ) ; $ res [ ] = array_merge ( $ tmp , $ this -> group_tags ( $ p [ 'tags' ] ) ) ; } else { $ res = array_map ( function ( $ t ) { unset ( $ t [ 'tag' ] ) ; return $ t ; } , $ p [ 'tags' ] ) ; } } } return $ res ; } return false ; }
Parses the parsed array to get an array of the given tag
12,501
private function get_components ( string $ memberof = '' ) { $ res = [ ] ; if ( $ components = $ this -> get ( 'component' , $ memberof ) ) { foreach ( $ components as $ comp ) { if ( ! empty ( $ comp [ 'name' ] ) ) { $ res [ ] = array_merge ( $ comp , $ this -> get_vue ( $ comp [ 'name' ] ) ) ; } } } return $ res ; }
Gets an array of component tags
12,502
public function set_source ( string $ src ) { $ this -> source = is_file ( $ src ) ? file_get_contents ( $ src ) : $ src ; $ this -> parsed = [ ] ; return $ this ; }
Sets the source to parse
12,503
public function set_mode ( string $ mode ) { if ( ! empty ( $ mode ) && in_array ( $ mode , $ this -> modes ) ) { $ this -> mode = $ mode ; return $ this ; } die ( _ ( 'Error: mode not allowed.' ) ) ; }
Sets the mode
12,504
public function parse ( ) { preg_match_all ( $ this -> pattern [ 'start' ] , $ this -> source , $ matches , PREG_OFFSET_CAPTURE ) ; if ( isset ( $ matches [ 0 ] ) ) { foreach ( $ matches [ 0 ] as $ match ) { preg_match ( $ this -> pattern [ 'end' ] , $ this -> source , $ mat , PREG_OFFSET_CAPTURE , $ match [ 1 ] ) ; $ start = $ match [ 1 ] ; $ length = isset ( $ mat [ 0 ] ) ? ( $ mat [ 0 ] [ 1 ] - $ start ) + 3 : 0 ; $ this -> parsed [ ] = $ this -> parse_docblock ( substr ( $ this -> source , $ start , $ length ) ) ; } } return $ this -> parsed ; }
Parses the current source
12,505
public function parse_docblock ( string $ block ) { $ b = [ 'description' => '' , 'tags' => [ ] ] ; $ block = trim ( substr ( $ block , 0 , strlen ( $ block ) - 2 ) ) ; $ tags = $ this -> get_tags ( $ block ) ; foreach ( $ tags as $ i => $ tag ) { if ( ( isset ( $ tags [ $ i + 1 ] ) && ( $ t = $ this -> parse_tag ( substr ( $ block , $ tag [ 1 ] , $ tags [ $ i + 1 ] [ 1 ] - $ tag [ 1 ] ) ) ) ) || ( $ t = $ this -> parse_tag ( substr ( $ block , $ tag [ 1 ] ) ) ) ) { $ b [ 'tags' ] [ ] = $ t ; } } $ b [ 'description' ] = $ this -> clear_text ( isset ( $ tags [ 0 ] ) ? substr ( $ block , 3 , $ tags [ 0 ] [ 1 ] - 1 ) : substr ( $ block , 3 ) ) ; return $ b ; }
Parses a given docblock
12,506
public function get_vue ( string $ memberof = '' ) { return [ 'description' => $ this -> get_file ( $ memberof ) , 'methods' => $ this -> get_methods ( $ memberof ) , 'events' => $ this -> get_events ( $ memberof ) , 'mixins' => $ this -> get_mixins ( $ memberof ) , 'props' => $ this -> get_props ( $ memberof ) , 'data' => $ this -> get_data ( $ memberof ) , 'computed' => $ this -> get_computed ( $ memberof ) , 'watch' => $ this -> get_watch ( $ memberof ) , 'components' => $ this -> get_components ( $ memberof ) , ] ; }
Gets Vue . js structure
12,507
public function formatBillingAddress ( ClientBillingAddress $ address , $ lineSeparator = self :: LINES_SEPARATOR ) { $ lines = [ ] ; $ lines [ ] = sprintf ( '%s %s' , $ address -> getFirstName ( ) , $ address -> getLastName ( ) ) ; if ( '' !== $ address -> getCompanyName ( ) ) { $ lines [ ] = $ address -> getCompanyName ( ) ; } $ lines [ ] = $ address -> getLine1 ( ) ; $ lines [ ] = $ address -> getLine2 ( ) ; $ lines [ ] = sprintf ( '%s, %s %s' , $ address -> getCountry ( ) , $ address -> getPostalCode ( ) , $ address -> getCity ( ) ) ; return implode ( $ lineSeparator , $ lines ) ; }
Formats the billing address
12,508
public function getStringToSign ( RequestInterface $ request , $ timestamp , $ nonce ) { $ params = $ this -> getParamsToSign ( $ request , $ timestamp , $ nonce ) ; $ params = $ this -> prepareParameters ( $ params ) ; $ parameterString = new QueryString ( $ params ) ; $ url = Url :: factory ( $ request -> getUrl ( ) ) -> setQuery ( '' ) -> setFragment ( null ) ; return strtoupper ( $ request -> getMethod ( ) ) . '&' . rawurlencode ( $ url ) . '&' . rawurlencode ( ( string ) $ parameterString ) ; }
Calculate string to sign
12,509
public function getParamsToSign ( RequestInterface $ request , $ timestamp , $ nonce ) { $ params = new Collection ( array ( 'oauth_consumer_key' => $ this -> config [ 'consumer_key' ] , 'oauth_nonce' => $ nonce , 'oauth_signature_method' => $ this -> config [ 'signature_method' ] , 'oauth_timestamp' => $ timestamp , 'oauth_token' => $ this -> config [ 'token' ] , 'oauth_version' => $ this -> config [ 'version' ] ) ) ; if ( array_key_exists ( 'callback' , $ this -> config ) == true ) { $ params [ 'oauth_callback' ] = $ this -> config [ 'callback' ] ; } if ( array_key_exists ( 'verifier' , $ this -> config ) == true ) { $ params [ 'oauth_verifier' ] = $ this -> config [ 'verifier' ] ; } $ params -> merge ( $ request -> getQuery ( ) ) ; if ( $ this -> shouldPostFieldsBeSigned ( $ request ) ) { $ params -> merge ( $ request -> getPostFields ( ) ) ; } $ params = $ params -> toArray ( ) ; ksort ( $ params ) ; return $ params ; }
Parameters sorted and filtered in order to properly sign a request
12,510
public function cache_driver ( ) { if ( ! $ this -> _cache ) { $ adapter = new DCache_Adapter \ File ( realpath ( __DIR__ . '../../../' . static :: CACHE_DIR ) ) ; $ adapter -> setOption ( 'ttl' , static :: CACHE_LIFETIME ) ; $ this -> _cache = new DCache \ Cache ( $ adapter ) ; } return $ this -> _cache ; }
Get an instance of the cache helper
12,511
public function signalToEvent ( $ signal ) { if ( $ this -> pid == ProcessTools :: getPid ( ) ) { $ signame = $ this -> signals -> signame ( $ signal ) ; $ this -> logger -> debug ( "Received $signame ($signal) signal, firing associated event(s)" ) ; $ this -> events -> emit ( new PosixEvent ( $ signal , $ this ) ) ; $ this -> events -> emit ( new PosixEvent ( $ signame , $ this ) ) ; } return $ this ; }
The generic signal handler .
12,512
private function getMinInConfiguration ( $ val1 , $ val2 ) { if ( $ val1 && $ val2 ) { return min ( array ( $ val1 , $ val2 ) ) ; } if ( $ val1 ) { return $ val1 ; } if ( $ val2 ) { return $ val2 ; } return null ; }
Get the min in 2 values if there exist .
12,513
private static function iniGetBytes ( $ val ) { $ val = trim ( ini_get ( $ val ) ) ; if ( $ val != '' ) { $ last = strtolower ( $ val { strlen ( $ val ) - 1 } ) ; } else { $ last = '' ; } $ val = ( int ) $ val ; switch ( $ last ) { case 'g' : $ val *= 1024 ; case 'm' : $ val *= 1024 ; case 'k' : $ val *= 1024 ; } return $ val ; }
Returns the number of bytes from php . ini parameter .
12,514
public function requestAsync ( $ url , $ method = 'GET' , $ data = [ ] ) { $ stack = HandlerStack :: create ( ) ; $ stack -> push ( ApiMiddleware :: auth ( ) ) ; $ client = new Client ( [ 'handler' => $ stack ] ) ; $ promise = $ client -> requestAsync ( $ method , $ url , [ 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> token ] , 'json' => $ data , 'content-type' => 'application/json' ] ) ; return $ promise ; }
Guzzle async request
12,515
public function requestCurl ( $ url , $ method = 'GET' , $ data = [ ] ) { $ data_string = json_encode ( $ data ) ; $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ method ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ data_string ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json' , 'Authorization: Bearer ' . $ this -> token ) ) ; $ result = curl_exec ( $ ch ) ; $ httpcode = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; $ result = json_decode ( $ result ) ; $ result = array_merge ( ( array ) $ result , [ "status_code" => $ httpcode ] ) ; if ( $ httpcode == 401 || $ httpcode == 403 ) { throw new UnauthorizedException ( "Unauthorized" ) ; } elseif ( $ httpcode > 403 ) { throw new \ Exception ( "Status_code: " . $ httpcode ) ; } return $ result ; }
Curl request - instead of Guzzle
12,516
public function parseBody ( $ line ) { $ this -> parseHeader ( $ line , $ this -> headers ) ; $ this -> size += strlen ( $ line ) ; }
Parses each line of the mail part .
12,517
public function finish ( ) { unset ( $ this -> part -> recipients [ $ this -> section - 1 ] ) ; $ this -> part -> size = $ this -> size ; return $ this -> part ; }
Returns the ezcMailDeliveryStatus part corresponding to the parsed message .
12,518
public function addEntityDirectory ( $ namespace , $ directory ) { if ( ! is_dir ( $ directory ) ) { return ; } $ files = new \ DirectoryIterator ( $ directory ) ; foreach ( $ files as $ file ) { if ( $ file -> isDir ( ) && ! $ file -> isDot ( ) ) { $ this -> addEntityDirectory ( $ namespace . '\\' . basename ( $ file -> getPathname ( ) ) , $ file -> getPathname ( ) ) ; continue ; } if ( ! $ file -> isFile ( ) ) { continue ; } $ class = $ namespace . '\\' . $ file -> getBasename ( '.php' ) ; $ r = new \ ReflectionClass ( $ class ) ; if ( $ r -> isSubclassOf ( 'ActiveDoctrine\Entity\Entity' ) && ! $ r -> isAbstract ( ) ) { $ this -> addEntityClass ( $ class ) ; } } }
Add all entity classes in a directory .
12,519
public static function __createOutput ( $ printerId ) { $ Printer = ClassRegistry :: init ( "Printers.Printer" ) ; $ Printer -> recursive = - 1 ; $ printer = $ Printer -> read ( null , $ printerId ) ; if ( empty ( $ printer [ 'Printer' ] [ 'output' ] ) ) { return false ; } $ outputName = $ printer [ 'Printer' ] [ 'output' ] . 'PrinterOutput' ; App :: uses ( $ outputName , 'Printers.Lib/PrinterOutput' ) ; self :: $ Output = new $ outputName ; return true ; }
Gets the name of the printer engine
12,520
public static function _loadPrinterOutput ( $ outputType ) { $ outputType = ucfirst ( strtolower ( $ outputType ) ) ; $ printerOutputName = $ outputType . "PrinterOutput" ; App :: uses ( $ printerOutputName , "Printers.PrinterOutput" ) ; self :: $ PrinterOutput = new $ printerOutputName ( ) ; }
Instanciates an Engine for change Output Printing
12,521
public static function getView ( PrintaitorViewObj $ printViewObj ) { $ data = $ printViewObj -> dataToView ; $ printer_id = $ printViewObj -> printerId ; $ templateName = $ printViewObj -> viewName ; if ( empty ( $ printer_id ) ) { return - 1 ; } $ pluginPath = App :: path ( 'Lib' , 'Printers' ) ; $ driverName = $ printViewObj -> printer [ 'Printer' ] [ 'driver' ] ; $ driverModelName = $ printViewObj -> printer [ 'Printer' ] [ 'driver_model' ] ; App :: build ( array ( 'View' => array ( $ pluginPath [ 0 ] . '/DriverView' ) ) ) ; $ viewName = $ driverName . "Printer/$templateName" ; $ View = new View ( ) ; $ View -> set ( $ data ) ; $ helperName = $ driverModelName . $ driverName . 'Helper' ; App :: uses ( $ helperName , 'Printers.Lib/DriverView/Helper' ) ; if ( ! class_exists ( $ helperName ) ) { throw new MissingHelperException ( array ( 'class' => $ helperName , 'plugin' => substr ( 'Printers' , 0 , - 1 ) ) ) ; } $ View -> PE = new $ helperName ( $ View ) ; $ View -> printaitorObj = $ printViewObj ; $ view = null ; try { $ view = $ View -> render ( $ viewName , false ) ; } catch ( Exception $ e ) { CakeLog :: write ( 'debug' , 'No existe la vista de Plugin Printer para ' . $ e -> getMessage ( ) ) ; } return $ view ; }
Logic for creating the view rendered .
12,522
public function search ( $ place , $ limit = 40 , $ clientIp = null ) { $ parameters = array ( 'sort' => 'closeness' , 'name' => $ place , 'limit' => $ limit , ) ; if ( $ clientIp ) { $ parameters [ 'client-ip' ] = $ clientIp ; } $ result = $ this -> get ( 'city' , $ parameters ) ; return array_map ( function ( $ geoname ) { return new Geoname ( $ geoname ) ; } , $ result ) ; }
Search for a place by its name .
12,523
private function get ( $ endPoint , array $ queryParameters = array ( ) ) { $ request = $ this -> client -> get ( $ this -> serverUri . $ endPoint , array ( 'accept' => 'application/json' ) ) ; foreach ( $ queryParameters as $ key => $ value ) { $ request -> getQuery ( ) -> add ( $ key , $ value ) ; } try { $ result = json_decode ( $ request -> send ( ) -> getBody ( true ) , true ) ; } catch ( ClientErrorResponseException $ e ) { if ( 404 === $ e -> getResponse ( ) -> getStatusCode ( ) ) { throw new NotFoundException ( 'Resource not found' , $ e -> getCode ( ) , $ e ) ; } throw new TransportException ( 'Failed to execute query' , $ e -> getCode ( ) , $ e ) ; } catch ( GuzzleException $ e ) { throw new TransportException ( 'Failed to execute query' , $ e -> getCode ( ) , $ e ) ; } if ( JSON_ERROR_NONE !== json_last_error ( ) ) { throw new TransportException ( 'Unable to parse result' ) ; } return $ result ; }
Executes a GET HTTP query .
12,524
protected function getFilenames ( Collection $ files ) { $ paths = $ files -> getFilenames ( ) ; if ( count ( $ paths ) < 1 ) { throw new FilesNotFoundException ( ) ; } $ this -> log ( 'Starting to process ' . count ( $ paths ) . ' files' ) ; return $ paths ; }
Extract all filenames from the given collection and output the amount of files .
12,525
protected function parseFileIntoDescriptor ( ProjectDescriptorBuilder $ builder , $ filename ) { $ parser = new File ( $ this ) ; $ parser -> parse ( $ filename , $ builder ) ; }
Parses a file and creates a Descriptor for it in the project .
12,526
protected function logAfterParsingAFile ( $ memory ) { if ( ! $ this -> stopwatch ) { return $ memory ; } $ lap = $ this -> stopwatch -> lap ( 'parser.parse' ) ; $ oldMemory = $ memory ; $ periods = $ lap -> getPeriods ( ) ; $ memory = end ( $ periods ) -> getMemory ( ) ; $ this -> log ( '>> Memory after processing of file: ' . number_format ( $ memory / 1024 / 1024 , 2 ) . ' megabytes (' . ( ( $ memory - $ oldMemory >= 0 ) ? '+' : '-' ) . number_format ( ( $ memory - $ oldMemory ) / 1024 ) . ' kilobytes)' , LogLevel :: DEBUG ) ; return $ memory ; }
Collects the time and duration of processing a file logs it and returns the new amount of memory in use .
12,527
public function serverGetByName ( $ name ) { foreach ( $ this -> serverList ( ) as $ server ) { if ( $ server [ "virtualserver_name" ] == $ name ) return $ server ; } throw new Exception ( "invalid serverID" , 0x400 ) ; }
Returns the first Server object matching the given name .
12,528
public function serverGetByUid ( $ uid ) { foreach ( $ this -> serverList ( ) as $ server ) { if ( $ server [ "virtualserver_unique_identifier" ] == $ uid ) return $ server ; } throw new Exception ( "invalid serverID" , 0x400 ) ; }
Returns the first Server object matching the given unique identifier .
12,529
public function permissionList ( ) { if ( $ this -> permissionList === null ) { $ this -> fetchPermissionList ( ) ; } foreach ( $ this -> permissionList as $ permname => $ permdata ) { if ( isset ( $ permdata [ "permcatid" ] ) && $ permdata [ "permgrant" ] ) { continue ; } $ this -> permissionList [ $ permname ] [ "permcatid" ] = $ this -> permissionGetCategoryById ( $ permdata [ "permid" ] ) ; $ this -> permissionList [ $ permname ] [ "permgrant" ] = $ this -> permissionGetGrantById ( $ permdata [ "permid" ] ) ; $ grantsid = "i_needed_modify_power_" . substr ( $ permname , 2 ) ; if ( ! $ permdata [ "permname" ] -> startsWith ( "i_needed_modify_power_" ) && ! isset ( $ this -> permissionList [ $ grantsid ] ) ) { $ this -> permissionList [ $ grantsid ] [ "permid" ] = $ this -> permissionList [ $ permname ] [ "permgrant" ] ; $ this -> permissionList [ $ grantsid ] [ "permname" ] = Str :: factory ( $ grantsid ) ; $ this -> permissionList [ $ grantsid ] [ "permdesc" ] = null ; $ this -> permissionList [ $ grantsid ] [ "permcatid" ] = 0xFF ; $ this -> permissionList [ $ grantsid ] [ "permgrant" ] = $ this -> permissionList [ $ permname ] [ "permgrant" ] ; } } return $ this -> permissionList ; }
Returns a list of permissions available on the server instance .
12,530
public function execute ( ) { $ output = [ ] ; $ code = 0 ; exec ( sprintf ( $ this -> command , $ this -> hgPath , $ this ) . " 2>&1" , $ output , $ code ) ; if ( $ code != 0 ) { throw new \ RuntimeException ( 'An error occurred while using VersionControl_HG; hg returned: ' . implode ( PHP_EOL , $ output ) , $ code ) ; } return implode ( PHP_EOL , $ output ) ; }
Execute mercurial command .
12,531
protected function assembleOptionString ( ) { $ optionString = '' ; foreach ( $ this -> options as $ name => $ option ) { if ( $ option === true ) { $ optionString .= " {$name}" ; } elseif ( is_string ( $ option ) && $ option !== '' ) { $ optionString .= " {$name} " . escapeshellarg ( $ option ) ; } elseif ( is_array ( $ option ) && ! empty ( $ option ) ) { $ optionString .= " {$name} " . implode ( ' ' , $ option ) ; } } return $ optionString !== '' ? $ optionString . '' : ' ' ; }
Concatinates string options .
12,532
private function getCommandName ( ) { $ className = implode ( '' , array_slice ( explode ( '\\' , get_class ( $ this ) ) , - 1 ) ) ; $ commandName = str_replace ( 'command' , '' , strtolower ( $ className ) ) ; return $ commandName ; }
Returns the concrete commands name .
12,533
public function install ( WorkerInterface $ worker , $ looptime = 1 , $ forever = false ) { $ name = $ worker -> getName ( ) ; if ( $ this -> isInstalled ( $ name ) ) { throw new Exception ( "Worker already installed" ) ; } $ w = Worker :: create ( ) -> setInstance ( $ worker ) -> setLooptime ( $ looptime ) -> setForever ( $ forever ) -> setInputChannel ( new SharedMemory ( ( int ) '1' . hexdec ( $ worker -> getId ( ) ) ) ) -> setOutputChannel ( new SharedMemory ( ( int ) '2' . hexdec ( $ worker -> getId ( ) ) ) ) ; $ this -> data [ $ name ] = $ w ; return $ this ; }
Install a worker into the stack
12,534
public function generateSlug ( $ title ) { $ title = strtolower ( $ title ) ; $ title = preg_replace ( '/[^%a-z0-9 _-]/' , '' , $ title ) ; $ title = preg_replace ( '/\s+/' , '-' , $ title ) ; $ title = preg_replace ( '|-+|' , '-' , $ title ) ; $ title = trim ( $ title , '-' ) ; return $ title ; }
Generate an appropriate slug from a title This function will turn a title into a lowercase and hyphenated title that is compatible with how Sculpin expects slugs .
12,535
protected function entityReferenceSearch ( $ value , $ entity ) { if ( ! is_array ( $ value ) && ! ( $ value instanceof Traversable ) ) { return false ; } if ( ! isset ( $ entity ) ) { throw new Exceptions \ InvalidParametersException ( ) ; } if ( is_array ( $ entity ) ) { foreach ( $ entity as & $ curEntity ) { if ( is_object ( $ curEntity ) ) { $ curEntity = $ curEntity -> guid ; } } unset ( $ curEntity ) ; } elseif ( is_object ( $ entity ) ) { $ entity = [ $ entity -> guid ] ; } else { $ entity = [ ( int ) $ entity ] ; } if ( isset ( $ value [ 0 ] ) && $ value [ 0 ] === 'nymph_entity_reference' ) { return in_array ( $ value [ 1 ] , $ entity ) ; } else { foreach ( $ value as $ curValue ) { if ( $ this -> entityReferenceSearch ( $ curValue , $ entity ) ) { return true ; } } } return false ; }
Search through a value for an entity reference .
12,536
protected function pullCache ( $ guid , $ className ) { if ( ! isset ( $ this -> entityCount [ $ guid ] ) ) { $ this -> entityCount [ $ guid ] = 0 ; } $ this -> entityCount [ $ guid ] ++ ; if ( isset ( $ this -> entityCache [ $ guid ] [ $ className ] ) ) { return ( clone $ this -> entityCache [ $ guid ] [ $ className ] ) ; } return null ; }
Pull an entity from the cache .
12,537
protected function pushCache ( & $ entity , $ className ) { if ( ! isset ( $ entity -> guid ) ) { return ; } if ( ! isset ( $ this -> entityCount [ $ entity -> guid ] ) ) { $ this -> entityCount [ $ entity -> guid ] = 0 ; } $ this -> entityCount [ $ entity -> guid ] ++ ; if ( $ this -> entityCount [ $ entity -> guid ] < $ this -> config [ 'cache_threshold' ] ) { return ; } if ( ( array ) $ this -> entityCache [ $ entity -> guid ] === $ this -> entityCache [ $ entity -> guid ] ) { $ this -> entityCache [ $ entity -> guid ] [ $ className ] = clone $ entity ; } else { while ( $ this -> config [ 'cache_limit' ] && count ( $ this -> entityCache ) >= $ this -> config [ 'cache_limit' ] ) { asort ( $ this -> entityCount ) ; foreach ( $ this -> entityCount as $ key => $ val ) { if ( isset ( $ this -> entityCache [ $ key ] ) ) { break ; } } if ( isset ( $ this -> entityCache [ $ key ] ) ) { unset ( $ this -> entityCache [ $ key ] ) ; } } $ this -> entityCache [ $ entity -> guid ] = [ $ className => ( clone $ entity ) ] ; } $ this -> entityCache [ $ entity -> guid ] [ $ className ] -> clearCache ( ) ; }
Push an entity onto the cache .
12,538
protected function sortProperty ( $ a , $ b ) { $ property = $ this -> sortProperty ; $ parent = $ this -> sortParent ; if ( isset ( $ parent ) && ( isset ( $ a -> $ parent -> $ property ) || isset ( $ b -> $ parent -> $ property ) ) ) { if ( ! $ this -> sortCaseSensitive && is_string ( $ a -> $ parent -> $ property ) && is_string ( $ b -> $ parent -> $ property ) ) { $ aprop = strtoupper ( $ a -> $ parent -> $ property ) ; $ bprop = strtoupper ( $ b -> $ parent -> $ property ) ; if ( $ aprop > $ bprop ) { return 1 ; } if ( $ aprop < $ bprop ) { return - 1 ; } } else { if ( $ a -> $ parent -> $ property > $ b -> $ parent -> $ property ) { return 1 ; } if ( $ a -> $ parent -> $ property < $ b -> $ parent -> $ property ) { return - 1 ; } } } if ( ! $ this -> sortCaseSensitive && is_string ( $ a -> $ property ) && is_string ( $ b -> $ property ) ) { $ aprop = strtoupper ( $ a -> $ property ) ; $ bprop = strtoupper ( $ b -> $ property ) ; if ( $ aprop > $ bprop ) { return 1 ; } if ( $ aprop < $ bprop ) { return - 1 ; } } else { if ( $ a -> $ property > $ b -> $ property ) { return 1 ; } if ( $ a -> $ property < $ b -> $ property ) { return - 1 ; } } return 0 ; }
Determine the sort order between two entities .
12,539
public function open ( $ file , $ mode = 'r+' ) { if ( ! file_exists ( $ file ) ) { throw new FileException ( 'CSV file does not exist' ) ; } parent :: open ( $ file , $ mode ) ; return $ this ; }
Open CSV file for reading
12,540
public function getHeader ( ) { $ this -> withHeader = true ; if ( ftell ( $ this -> handle ) == 0 ) { $ this -> header = $ this -> read ( ) ; } return $ this -> header ; }
Get CSV header . Usually it s the first line in file .
12,541
public function readLine ( ) { $ out = $ this -> read ( ) ; if ( $ this -> withHeader && is_array ( $ out ) ) { $ out = array_combine ( $ this -> header , $ out ) ; } return $ out ; }
Read current line from CSV file
12,542
private function read ( ) { $ out = fgetcsv ( $ this -> handle , null , $ this -> delimiter , $ this -> enclosure ) ; if ( ! is_array ( $ out ) ) { return $ out ; } if ( $ this -> encodingFrom !== null && $ this -> encodingTo !== null ) { foreach ( $ out as $ k => $ v ) { $ out [ $ k ] = iconv ( $ this -> encodingFrom , $ this -> encodingTo , $ v ) ; } } return $ out ; }
Wrapper for fgetcsv function
12,543
public function run ( ) { $ model = new Measure ; return $ this -> controller -> render ( 'index' , [ 'dataProvider' => $ model -> search ( \ Yii :: $ app -> request -> get ( ) ) , 'model' => $ model , ] ) ; }
Lists all Measure models .
12,544
public function make ( $ data = null ) { if ( is_null ( $ data ) ) { return new NullResource ( ) ; } elseif ( is_array ( $ data ) ) { return static :: makeFromArray ( $ data ) ; } $ method = static :: getMakeMethod ( $ data ) ; return static :: $ method ( $ data ) ; }
Build a resource instance from the given data .
12,545
protected function makeFromPaginator ( Paginator $ paginator ) : ResourceInterface { $ resource = static :: makeFromCollection ( $ paginator -> getCollection ( ) ) ; if ( $ resource instanceof CollectionResource ) { $ queryParams = array_diff_key ( app ( 'request' ) -> all ( ) , array_flip ( [ 'page' ] ) ) ; $ paginator -> appends ( $ queryParams ) ; $ resource -> setPaginator ( new IlluminatePaginatorAdapter ( $ paginator ) ) ; } return $ resource ; }
Make resource from an Eloquent paginator .
12,546
public function download ( $ ftkey , $ size , $ passthru = FALSE ) { $ this -> init ( $ ftkey ) ; if ( $ passthru ) { return $ this -> passthru ( $ size ) ; } $ buff = new Str ( "" ) ; $ size = intval ( $ size ) ; $ pack = 4096 ; Signal :: getInstance ( ) -> emit ( "filetransferDownloadStarted" , $ ftkey , count ( $ buff ) , $ size ) ; for ( $ seek = 0 ; $ seek < $ size ; ) { $ rest = $ size - $ seek ; $ pack = $ rest < $ pack ? $ rest : $ pack ; $ data = $ this -> getTransport ( ) -> read ( $ rest < $ pack ? $ rest : $ pack ) ; $ seek = $ seek + $ pack ; $ buff -> append ( $ data ) ; Signal :: getInstance ( ) -> emit ( "filetransferDownloadProgress" , $ ftkey , count ( $ buff ) , $ size ) ; } $ this -> getProfiler ( ) -> stop ( ) ; Signal :: getInstance ( ) -> emit ( "filetransferDownloadFinished" , $ ftkey , count ( $ buff ) , $ size ) ; if ( strlen ( $ buff ) != $ size ) { throw new Exception ( "incomplete file download (" . count ( $ buff ) . " of " . $ size . " bytes)" ) ; } return $ buff ; }
Returns the content of a downloaded file as a Str object .
12,547
private function processDirectoryEntry ( $ artifactDirectory , $ entry ) { $ entity = fphp \ Helper \ Path :: join ( $ artifactDirectory , $ entry ) ; if ( is_dir ( $ entity ) && ! fphp \ Helper \ Path :: isDot ( $ entry ) && in_array ( $ this -> get ( "artifactFile" ) , scandir ( $ entity ) ) ) { $ feature = $ this -> get ( "model" ) -> getFeature ( $ entry , true ) ; if ( $ this -> has ( $ feature -> getName ( ) , $ this -> get ( "artifacts" ) ) ) throw new fphp \ SettingsException ( "there are multiple settings for \"{$feature->getName()}\"" ) ; $ this -> set ( "artifacts" , $ feature -> getName ( ) , new fphp \ Artifact \ Artifact ( $ feature , fphp \ Artifact \ Settings :: fromFile ( fphp \ Helper \ Path :: join ( $ entity , $ this -> get ( "artifactFile" ) ) ) ) ) ; } else if ( is_dir ( $ entity ) && ! fphp \ Helper \ Path :: isDot ( $ entry ) ) foreach ( scandir ( $ entity ) as $ entry ) $ this -> processDirectoryEntry ( $ entity , $ entry ) ; else if ( is_file ( $ entity ) ) try { $ feature = $ this -> get ( "model" ) -> getFeature ( pathinfo ( $ entity ) [ "filename" ] , true ) ; if ( $ this -> has ( $ feature -> getName ( ) , $ this -> get ( "artifacts" ) ) ) throw new fphp \ SettingsException ( "there are multiple settings for \"{$feature->getName()}\"" ) ; $ this -> set ( "artifacts" , $ feature -> getName ( ) , new fphp \ Artifact \ Artifact ( $ feature , fphp \ Artifact \ Settings :: fromFile ( $ entity ) ) ) ; } catch ( fphp \ Model \ ModelException $ e ) { } }
recursively search the artifact directory allowing the user to group features
12,548
public static function observe ( $ class ) { $ className = is_string ( $ class ) ? $ class : get_class ( $ class ) ; foreach ( static :: $ observables as $ event ) { if ( method_exists ( $ class , $ event ) ) { static :: registerModelEvent ( $ event , $ className . '@' . $ event ) ; } } }
Register an observer with the Model .
12,549
public function say_dir ( ) { if ( $ this -> path ) { $ p = dirname ( $ this -> path ) ; if ( $ p === '.' ) { return '' ; } if ( ( $ prepath = $ this -> get_prepath ( ) ) && ( strpos ( $ p , $ prepath ) === 0 ) ) { return substr ( $ p , \ strlen ( $ prepath ) ) ; } return $ p ; } return false ; }
Returns the current controller s file s name .
12,550
public function render ( $ view , $ model = '' ) { if ( empty ( $ model ) && $ this -> has_data ( ) ) { $ model = $ this -> data ; } if ( \ is_string ( $ view ) ) { return \ is_array ( $ model ) ? bbn \ tpl :: render ( $ view , $ model ) : $ view ; } die ( bbn \ x :: hdump ( "Problem with the template" , $ view , $ this -> path , $ this -> mode ) ) ; }
This directly renders content with arbitrary values using the existing Mustache engine .
12,551
public function incl ( $ file_name ) { if ( $ this -> exists ( ) ) { $ d = dirname ( $ this -> file ) . '/' ; if ( substr ( $ file_name , - 4 ) !== '.php' ) { $ file_name .= '.php' ; } if ( ( strpos ( $ file_name , '..' ) === false ) && file_exists ( $ d . $ file_name ) ) { $ bbn_path = $ d . $ file_name ; $ ctrl = & $ this ; unset ( $ d , $ file_name ) ; include ( $ bbn_path ) ; } } return $ this ; }
This will include a file from within the controller s path . Chainable
12,552
public function add_script ( $ script ) { if ( \ is_object ( $ this -> obj ) ) { if ( ! isset ( $ this -> obj -> script ) ) { $ this -> obj -> script = '' ; } $ this -> obj -> script .= $ script ; } return $ this ; }
This will add the given string to the script property and create it if needed . Chainable
12,553
public function get_content ( $ file_name ) { if ( $ this -> check_path ( $ file_name ) && \ defined ( 'BBN_DATA_PATH' ) && is_file ( BBN_DATA_PATH . $ file_name ) ) { return file_get_contents ( BBN_DATA_PATH . $ file_name ) ; } return false ; }
This will get a the content of a file located within the data path
12,554
public function delete_cached_model ( ) { $ args = \ func_get_args ( ) ; foreach ( $ args as $ a ) { if ( \ is_string ( $ a ) && \ strlen ( $ a ) ) { $ path = $ a ; } else if ( \ is_array ( $ a ) ) { $ data = $ a ; } } if ( ! isset ( $ path ) ) { $ path = $ this -> path ; } else if ( strpos ( $ path , './' ) === 0 ) { $ path = $ this -> say_dir ( ) . substr ( $ path , 1 ) ; } if ( ! isset ( $ data ) ) { $ data = $ this -> data ; } return $ this -> mvc -> delete_cached_model ( $ path , $ data , $ this ) ; }
This will delete the cached model . There is no order for the arguments .
12,555
public function has_data ( $ data = null ) { if ( \ is_null ( $ data ) ) { $ data = $ this -> data ; } return ( \ is_array ( $ data ) && ( \ count ( $ data ) > 0 ) ) ? 1 : false ; }
Checks if data exists
12,556
protected function urlGetDomainUrlAndClasifyParamsAndDomainParams ( array & $ params , array & $ domainParamsDefault , & $ targetDomainRoute ) { $ domainParams = array_intersect_key ( $ params , $ domainParamsDefault ) ; $ params = array_diff_key ( $ params , $ domainParamsDefault ) ; $ defaultDomainParams = array_merge ( [ ] , $ this -> GetDefaultParams ( ) ? : [ ] ) ; list ( $ domainUrlBaseSection , ) = $ targetDomainRoute -> Url ( $ this -> request , $ domainParams , $ defaultDomainParams , '' , TRUE ) ; return $ domainUrlBaseSection ; }
Complete domain URL part by given module domain route and classify params necessary to complete URL by module route reverse string and unset those params from params array reference . Params array will be changed . Return URL base part by module domain route .
12,557
private function httpClient ( ) { if ( ! self :: $ httpClient ) { self :: $ httpClient = HttpClient \ CurlClient :: instance ( ) ; } return self :: $ httpClient ; }
If needed create and return a http client
12,558
public function isVariableRequired ( $ field ) { switch ( $ field ) { case 'email' : $ user = eZUser :: currentUser ( ) ; if ( ! $ user -> isAnonymous ( ) ) { return false ; } return true ; case 'recaptcha' : $ bypassCaptcha = ezcomPermission :: hasAccessToSecurity ( 'AntiSpam' , 'bypass_captcha' ) ; if ( $ bypassCaptcha [ 'result' ] ) { return false ; } return true ; default : return parent :: isVariableRequired ( $ field ) ; } }
isVariableRequire in adding comment . When adding comment for logined user the email is not required
12,559
protected function validateField ( $ field , $ value ) { switch ( $ field ) { case 'website' : return ezcomUtility :: validateURLString ( $ value ) ; case 'email' : $ user = eZUser :: currentUser ( ) ; if ( $ user -> isAnonymous ( ) ) { $ result = eZMail :: validate ( $ value ) ; if ( ! $ result ) { return ezpI18n :: tr ( 'ezcomments/comment/add' , 'Not a valid email address.' ) ; } } return true ; case 'recaptcha' : require_once 'recaptchalib.php' ; $ ini = eZINI :: instance ( 'ezcomments.ini' ) ; $ privateKey = $ ini -> variable ( 'RecaptchaSetting' , 'PrivateKey' ) ; $ http = eZHTTPTool :: instance ( ) ; if ( $ http -> hasPostVariable ( 'recaptcha_challenge_field' ) && $ http -> hasPostVariable ( 'recaptcha_response_field' ) ) { $ ip = $ _SERVER [ "REMOTE_ADDR" ] ; $ challengeField = $ http -> postVariable ( 'recaptcha_challenge_field' ) ; $ responseField = $ http -> postVariable ( 'recaptcha_response_field' ) ; $ capchaResponse = recaptcha_check_answer ( $ privateKey , $ ip , $ challengeField , $ responseField ) ; if ( ! $ capchaResponse -> is_valid ) { return ezpI18n :: tr ( 'ezcomments/comment/add' , 'The words you input are incorrect.' ) ; } } else { return ezpI18n :: tr ( 'ezcomments/comment/add' , 'Captcha parameter error.' ) ; } return true ; default : return true ; } }
Implement the validatation in adding comment
12,560
protected function setFieldValue ( $ field , $ fieldPostName ) { $ user = eZUser :: currentUser ( ) ; switch ( $ field ) { case 'email' : if ( ! $ user -> isAnonymous ( ) ) { $ this -> fieldValues [ $ field ] = $ user -> attribute ( 'email' ) ; } else { parent :: setFieldValue ( $ field , $ fieldPostName ) ; } break ; case 'notificationField' : $ http = eZHTTPTool :: instance ( ) ; $ notification = false ; if ( $ http -> hasPostVariable ( $ fieldPostName ) && $ http -> postVariable ( $ fieldPostName ) == '1' ) { $ notification = true ; } $ this -> fieldValues [ $ field ] = $ notification ; break ; default : parent :: setFieldValue ( $ field , $ fieldPostName ) ; break ; } }
Implement the setFieldValue in adding comment
12,561
protected function getThemePaths ( $ themes ) { $ dirsFromConfig = array_filter ( [ $ this -> getConfig ( ) -> get ( 'digipolis.root.project' , false ) , $ this -> getConfig ( ) -> get ( 'digipolis.root.web' , false ) , ] ) ; $ dirs = empty ( $ this -> dirs ) ? $ dirsFromConfig : $ this -> dirs ; if ( empty ( $ dirs ) ) { $ dirs = [ getcwd ( ) ] ; } $ finder = clone $ this -> finder ; $ finder -> in ( $ dirs ) -> files ( ) ; foreach ( $ themes as $ themeName ) { $ finder -> path ( '/themes\/(custom\/)?[^\/]*\/' . preg_quote ( $ themeName , '/' ) . '\.info\.yml/' ) ; } $ processed = [ ] ; $ paths = [ ] ; foreach ( $ finder as $ infoFile ) { $ path = dirname ( $ infoFile -> getRealPath ( ) ) ; if ( isset ( $ processed [ $ path ] ) ) { continue ; } $ processed [ $ path ] = true ; $ theme = $ infoFile -> getBasename ( '.info.yml' ) ; $ paths [ $ theme ] = $ path ; } return $ paths ; }
Get the theme paths .
12,562
public function decodeFile ( $ file , $ assoc = true , $ depth = 512 , $ options = 0 ) { set_error_handler ( create_function ( '$severity, $message, $file, $line' , 'throw new ErrorException($message, $severity, $severity, $file, $line);' ) ) ; try { $ jsonData = file_get_contents ( $ file ) ; } catch ( Exception $ e ) { throw new RuntimeException ( sprintf ( $ e -> getMessage ( ) ) ) ; } restore_error_handler ( ) ; if ( false === $ jsonData ) { throw new RuntimeException ( sprintf ( 'Unable to get file %s' , $ file ) ) ; } return $ this -> decode ( $ jsonData , $ assoc , $ depth , $ options ) ; }
Decode JSON data encoded in file
12,563
protected function checkJsonError ( ) { if ( ! function_exists ( 'json_last_error' ) ) { throw new BadFunctionCallException ( 'json_last_error() function not exits' ) ; } $ jsonError = json_last_error ( ) ; if ( $ jsonError !== JSON_ERROR_NONE ) { $ this -> jsonErrorException ( $ jsonError ) ; } return true ; }
Check exists error for last execution json funtion
12,564
private function decodeCheckVersion ( $ dataValid , $ assocValid , $ depthValid , $ optionsValid ) { if ( version_compare ( PHP_VERSION , '5.4.0' ) >= 0 ) { return json_decode ( $ dataValid , $ assocValid , $ depthValid , $ optionsValid ) ; } return json_decode ( $ dataValid , $ assocValid , $ depthValid ) ; }
Options param add 5 . 4
12,565
private function encodeCheckVersion ( $ dataValid , $ optionsValid , $ depthValid ) { if ( version_compare ( PHP_VERSION , '5.4.0' ) >= 0 ) { return json_encode ( $ dataValid , $ optionsValid , $ depthValid ) ; } return json_encode ( $ dataValid , $ optionsValid ) ; }
Depth param add 5 . 4
12,566
protected function registerCampagneWorkerService ( ) { $ this -> app -> bind ( 'designpond\newsletter\Newsletter\Worker\CampagneInterface' , function ( ) { return new \ designpond \ newsletter \ Newsletter \ Worker \ CampagneWorker ( \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterContentInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterUserInterface' ) ) ; } ) ; }
Newsletter Campagne worker
12,567
protected function registerImportService ( ) { $ this -> app -> singleton ( 'designpond\newsletter\Newsletter\Worker\ImportWorkerInterface' , function ( ) { return new \ designpond \ newsletter \ Newsletter \ Worker \ ImportWorker ( \ App :: make ( 'designpond\newsletter\Newsletter\Worker\MailjetServiceInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterUserInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterInterface' ) , \ App :: make ( 'Maatwebsite\Excel\Excel' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Worker\CampagneInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Service\UploadInterface' ) ) ; } ) ; }
Newsletter Import worker
12,568
protected function registerSubscribeWorkerService ( ) { $ this -> app -> bind ( 'designpond\newsletter\Newsletter\Worker\SubscriptionWorkerInterface' , function ( ) { return new \ designpond \ newsletter \ Newsletter \ Worker \ SubscriptionWorker ( \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Repo\NewsletterUserInterface' ) , \ App :: make ( 'designpond\newsletter\Newsletter\Worker\MailjetServiceInterface' ) ) ; } ) ; }
Newsletter subscriber service
12,569
public function parentBlockWidget ( BlockView $ view , array $ variables = [ ] ) { return $ this -> renderer -> searchAndRenderBlock ( $ view , 'widget' , $ variables , true ) ; }
Renders the parent block widget defined in other resources on all levels of block prefix hierarchy
12,570
public function formatLog ( array $ logMessage ) { extract ( $ logMessage ) ; $ level = strtoupper ( $ level ) ; $ message = $ this -> applyContext ( $ message , $ context ) ; $ timestamp = date ( $ this -> dateTimeFormat , $ timestamp ) ; $ exception = $ this -> getExceptionTrace ( $ context ) ; $ log = str_replace ( self :: FORMAT_TIMESTAMP , $ timestamp , $ this -> logFormat ) ; $ log = str_replace ( self :: FORMAT_LEVEL , $ level , $ log ) ; $ log = str_replace ( self :: FORMAT_MESSAGE , $ message , $ log ) ; $ log = str_replace ( self :: FORMAT_EXCEPTION , $ exception , $ log ) ; return $ log ; }
Format log message
12,571
protected function applyContext ( $ message , array $ context = array ( ) ) { foreach ( $ context as $ key => $ value ) { $ key = trim ( $ key , "{}" ) ; if ( $ key != 'exception' ) { $ message = $ this -> replaceContext ( $ message , $ key , $ value ) ; } } return $ message ; }
Apply context into log message .
12,572
protected function replaceContext ( $ message , string $ key , $ context ) { $ strContext = '' ; if ( is_object ( $ context ) ) { if ( method_exists ( $ context , '__toString' ) ) { $ strContext = call_user_func ( [ $ context , '__toString' ] ) ; } else { $ strContext = var_export ( $ context , true ) ; } } else { $ strContext = $ context ; } return str_replace ( '{' . $ key . '}' , $ strContext , $ message ) ; }
Replace context pattern in the message with related context .
12,573
protected function getExceptionTrace ( array $ context ) { if ( array_key_exists ( 'exception' , $ context ) ) { if ( $ context [ 'exception' ] instanceof \ Exception ) { $ strException = $ context [ 'exception' ] -> getTraceAsString ( ) ; return $ strException ; } } return '' ; }
Get Exception trace if found in the context .
12,574
public function handleChecks ( ) { $ errors = [ ] ; foreach ( $ this -> _config [ 'checks' ] as $ name => $ check ) { if ( empty ( $ check ) ) { continue ; } $ result = $ check [ 'callback' ] ( ) ; if ( $ result !== true ) { $ errors [ ] = $ name . ': <br>' . $ check [ 'error' ] . ' - ' . $ result ; } } if ( ! empty ( $ errors ) ) { $ this -> response -> statusCode ( 500 ) ; echo date ( 'Y-m-d H:i:s' ) . ': ' . $ this -> _config [ 'projectName' ] . ' - ' . $ this -> _config [ 'serverDescription' ] . ' - Status Code: ' . $ this -> response -> statusCode ( ) . '<br><br> ' ; foreach ( $ errors as $ error ) { echo $ error . '<br><br>' ; } die ; } $ this -> _config [ 'onSuccess' ] ( ) ; die ; }
Handle all defined checks
12,575
public function search ( $ params ) { $ query = Message :: find ( ) ; $ query -> joinWith ( 'source' ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query ] ) ; $ dataProvider -> getSort ( ) -> attributes [ 'sourceMessage' ] = [ 'asc' => [ 'source.message' => SORT_ASC ] , 'desc' => [ 'source.message' => SORT_DESC ] , ] ; $ dataProvider -> getSort ( ) -> attributes [ 'sourceCategory' ] = [ 'asc' => [ 'source.category' => SORT_ASC ] , 'desc' => [ 'source.category' => SORT_DESC ] , ] ; if ( ! ( $ this -> load ( $ params ) && $ this -> validate ( ) ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'id' => $ this -> id ] ) ; if ( $ this -> translation ) { $ t = addslashes ( $ this -> translation ) ; $ query -> where ( "translation like '%{$t}%'" ) ; } if ( $ this -> translationUpdate === 'is null' ) { $ query -> where ( 'translation is null' ) ; } if ( $ this -> translationUpdate === 'is not null' ) { $ query -> where ( 'translation is not null' ) ; } if ( $ this -> translation ) { $ query -> andWhere ( [ 'like' , 'translation' , '%' . $ this -> translation . '%' , false ] ) ; } if ( $ this -> sourceMessage ) { $ query -> andFilterWhere ( [ 'like' , 'source.message' , $ this -> sourceMessage ] ) ; } if ( $ this -> language ) { $ query -> andWhere ( [ 'language' => $ this -> language ] ) ; } if ( $ this -> sourceCategory ) { $ query -> andFilterWhere ( [ 'like' , 'source.category' , $ this -> sourceCategory ] ) ; } return $ dataProvider ; }
Default index search method
12,576
public function execute ( ProjectDescriptor $ project ) { $ this -> analyzer -> analyze ( $ project ) ; $ this -> log -> debug ( ( string ) $ this -> analyzer ) ; }
Analyzes the given project and returns the results to the logger .
12,577
protected function findModel ( $ id ) { if ( ( $ model = ProductType :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } }
Finds the ProductType model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
12,578
protected function addPageParameterNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'page' ) ; $ node -> treatTrueLike ( array ( 'versionable' => false , 'signable' => false , 'form' => array ( 'type' => "ASF\DocumentBundle\Form\Type\PageType" , 'name' => 'page_type' ) ) ) -> treatFalseLike ( array ( 'versionable' => false , 'signable' => false , 'form' => array ( 'type' => "ASF\DocumentBundle\Form\Type\PageType" , 'name' => 'page_type' ) ) ) -> addDefaultsIfNotSet ( ) -> children ( ) -> booleanNode ( 'versionable' ) -> defaultFalse ( ) -> end ( ) -> booleanNode ( 'signable' ) -> defaultFalse ( ) -> end ( ) -> arrayNode ( 'form' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'type' ) -> defaultValue ( 'ASF\DocumentBundle\Form\Type\PageType' ) -> end ( ) -> scalarNode ( 'name' ) -> defaultValue ( 'page_type' ) -> end ( ) -> arrayNode ( 'validation_groups' ) -> prototype ( 'scalar' ) -> end ( ) -> defaultValue ( array ( "Default" ) ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; return $ node ; }
Add Page Entity Configuration
12,579
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof \ CustomerGroup \ Model \ CustomerCustomerGroupQuery ) { return $ criteria ; } $ query = new \ CustomerGroup \ Model \ CustomerCustomerGroupQuery ( ) ; if ( null !== $ modelAlias ) { $ query -> setModelAlias ( $ modelAlias ) ; } if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
Returns a new ChildCustomerCustomerGroupQuery object .
12,580
public function filterByCustomerGroupId ( $ customerGroupId = null , $ comparison = null ) { if ( is_array ( $ customerGroupId ) ) { $ useMinMax = false ; if ( isset ( $ customerGroupId [ 'min' ] ) ) { $ this -> addUsingAlias ( CustomerCustomerGroupTableMap :: CUSTOMER_GROUP_ID , $ customerGroupId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ customerGroupId [ 'max' ] ) ) { $ this -> addUsingAlias ( CustomerCustomerGroupTableMap :: CUSTOMER_GROUP_ID , $ customerGroupId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( CustomerCustomerGroupTableMap :: CUSTOMER_GROUP_ID , $ customerGroupId , $ comparison ) ; }
Filter the query on the customer_group_id column
12,581
public function filterByCustomer ( $ customer , $ comparison = null ) { if ( $ customer instanceof \ Thelia \ Model \ Customer ) { return $ this -> addUsingAlias ( CustomerCustomerGroupTableMap :: CUSTOMER_ID , $ customer -> getId ( ) , $ comparison ) ; } elseif ( $ customer instanceof ObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( CustomerCustomerGroupTableMap :: CUSTOMER_ID , $ customer -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection' ) ; } }
Filter the query by a related \ Thelia \ Model \ Customer object
12,582
public function useCustomerQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinCustomer ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Customer' , '\Thelia\Model\CustomerQuery' ) ; }
Use the Customer relation Customer object
12,583
protected function show ( $ user , string $ modelName ) { $ method = "{$modelName}s" ; $ methodTitle = ucfirst ( $ method ) ; if ( ! $ user -> $ method ) { $ this -> warn ( "User not use Has{$methodTitle}Trait!" ) ; return ; } echo "{$methodTitle}:" , PHP_EOL ; $ data = $ this -> prepareData ( $ user -> $ method -> toArray ( ) ) ; if ( $ user -> $ method -> count ( ) ) { $ this -> table ( [ 'ID' , ucfirst ( $ modelName ) , 'Created At' , 'Updated At' ] , $ data ) ; } else { $ this -> warn ( "Not found any {$method}!" ) ; } }
Show roles or permissions
12,584
function nativeCopy ( $ path , $ newPath ) { if ( ! $ this -> createDir ( Util :: dirname ( $ newPath ) , new Config ( ) ) ) { return false ; } $ location = $ this -> applyPathPrefix ( $ this -> encodePath ( $ path ) ) ; $ newLocation = $ this -> applyPathPrefix ( $ this -> encodePath ( $ newPath ) ) ; try { $ destination = $ this -> client -> getAbsoluteUrl ( $ newLocation ) ; $ response = $ this -> client -> request ( 'COPY' , '/' . ltrim ( $ location , '/' ) , null , [ 'Destination' => $ destination , ] ) ; if ( $ response [ 'statusCode' ] >= 200 && $ response [ 'statusCode' ] < 300 ) { return true ; } } catch ( NotFound $ e ) { } return false ; }
Copy a file through WebDav COPY method .
12,585
function normalizeObject ( array $ object , $ path ) { if ( ! isset ( $ object [ '{DAV:}getcontentlength' ] ) or $ object [ '{DAV:}getcontentlength' ] == "" ) { return [ 'type' => 'dir' , 'path' => trim ( $ path , '/' ) ] ; } $ result = Util :: map ( $ object , static :: $ resultMap ) ; if ( isset ( $ object [ '{DAV:}getlastmodified' ] ) ) { $ result [ 'timestamp' ] = strtotime ( $ object [ '{DAV:}getlastmodified' ] ) ; } $ result [ 'type' ] = 'file' ; $ result [ 'path' ] = trim ( $ path , '/' ) ; return $ result ; }
Normalise a WebDAV repsonse object .
12,586
function removePathPrefix ( $ path ) { if ( strpos ( $ path , $ this -> getPathPrefix ( ) ) === false ) { return basename ( $ path ) ; } return parent :: removePathPrefix ( $ path ) ; }
Remove a path prefix .
12,587
protected function findModel ( $ id ) { if ( ( $ model = TermOfProductType :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } }
Finds the TermOfProductType model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
12,588
public function post ( $ url , $ data = [ ] , $ headers = [ ] , $ curl_opts = [ ] ) { return $ this -> load ( $ url , $ data , $ headers , $ curl_opts ) ; }
GETs data from the server
12,589
public function put ( $ url , $ data = [ ] , $ headers = [ ] , $ curl_opts = [ ] ) { $ curl_opts [ CURLOPT_CUSTOMREQUEST ] = 'PUT' ; return $ this -> load ( $ url , $ data , $ headers , $ curl_opts ) ; }
PUTs data to the server
12,590
public function delete ( $ url , $ data = [ ] , $ headers = [ ] , $ curl_opts = [ ] ) { $ curl_opts [ CURLOPT_CUSTOMREQUEST ] = 'DELETE' ; return $ this -> load ( $ url , $ data , $ headers , $ curl_opts ) ; }
DELETEs data from the server
12,591
public function split ( string $ subject , int $ limit = - 1 , int $ flags = 0 ) : array { $ result = preg_split ( $ this -> pattern -> getPattern ( ) . $ this -> modifier , $ subject , $ limit , $ flags ) ; if ( ( $ errno = preg_last_error ( ) ) !== PREG_NO_ERROR ) { $ message = array_flip ( get_defined_constants ( true ) [ 'pcre' ] ) [ $ errno ] ; switch ( $ errno ) { case PREG_INTERNAL_ERROR : throw new InternalException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_BACKTRACK_LIMIT_ERROR : throw new BacktrackLimitException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_RECURSION_LIMIT_ERROR : throw new RecursionLimitException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_BAD_UTF8_ERROR : throw new BadUtf8Exception ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_BAD_UTF8_OFFSET_ERROR : throw new BadUtf8OffsetException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_JIT_STACKLIMIT_ERROR : throw new JitStackLimitException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; } } return $ result ; }
Retrieves subject split with Pattern
12,592
protected function parseArguments ( ) { $ stream = $ this -> parser -> getStream ( ) ; $ data = null ; $ only = false ; if ( $ stream -> test ( Twig_Token :: BLOCK_END_TYPE ) ) { $ stream -> expect ( Twig_Token :: BLOCK_END_TYPE ) ; return [ $ data , $ only ] ; } if ( $ stream -> test ( Twig_Token :: NAME_TYPE , 'only' ) ) { $ only = true ; $ stream -> next ( ) ; $ stream -> expect ( Twig_Token :: BLOCK_END_TYPE ) ; return [ $ data , $ only ] ; } $ data = $ this -> parser -> getExpressionParser ( ) -> parseExpression ( ) ; if ( $ stream -> test ( Twig_Token :: NAME_TYPE , 'only' ) ) { $ only = true ; $ stream -> next ( ) ; } $ stream -> expect ( Twig_Token :: BLOCK_END_TYPE ) ; return [ $ data , $ only ] ; }
Tokenizes the component stream .
12,593
public function getSubscribedEvents ( ) { $ events = [ ] ; foreach ( $ this -> providers as $ command => $ provider ) { $ events [ 'command.' . $ command ] = 'handleCommand' ; $ events [ 'command.' . $ command . '.help' ] = 'handleCommandHelp' ; } return $ events ; }
Return an array of commands and associated methods
12,594
public function handleCommandHelp ( Event $ event , Queue $ queue ) { $ params = $ event -> getCustomParams ( ) ; $ provider = $ this -> getProvider ( ( $ event -> getCustomCommand ( ) === "help" ) ? $ params [ 0 ] : $ event -> getCustomCommand ( ) ) ; if ( $ provider ) { $ this -> sendIrcResponse ( $ event , $ queue , $ provider -> getHelpLines ( ) ) ; } }
Main plugin handler for help requests
12,595
public function getProvider ( $ command ) { $ providerExists = ( isset ( $ this -> providers [ $ command ] ) && class_exists ( $ this -> providers [ $ command ] ) ) ; return ( $ providerExists ) ? new $ this -> providers [ $ command ] : false ; }
Get a single provider class by command
12,596
protected function getApiRequest ( Event $ event , Queue $ queue , GoogleProviderInterface $ provider ) { $ self = $ this ; return new HttpRequest ( [ 'url' => $ provider -> getApiRequestUrl ( $ event ) , 'resolveCallback' => function ( Response $ response ) use ( $ self , $ event , $ queue , $ provider ) { $ self -> sendIrcResponse ( $ event , $ queue , $ provider -> getSuccessLines ( $ event , $ response -> getBody ( ) ) ) ; } , 'rejectCallback' => function ( $ error ) use ( $ self , $ event , $ queue , $ provider ) { $ self -> sendIrcResponse ( $ event , $ queue , $ provider -> getRejectLines ( $ event , $ error ) ) ; } ] ) ; }
Set up the API request and set the callbacks
12,597
protected function sendIrcResponse ( Event $ event , Queue $ queue , array $ ircResponse ) { foreach ( $ ircResponse as $ ircResponseLine ) { $ this -> sendIrcResponseLine ( $ event , $ queue , $ ircResponseLine ) ; } }
Send an array of response lines back to IRC
12,598
protected function sendIrcResponseLine ( Event $ event , Queue $ queue , $ ircResponseLine ) { $ queue -> ircPrivmsg ( $ event -> getSource ( ) , $ ircResponseLine ) ; }
Send a single response line back to IRC
12,599
private function fetchInfo ( $ key ) { return array_key_exists ( $ key , $ this -> info ) ? $ this -> info [ $ key ] : null ; }
Search the information array for the specified key and return the value