idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
9,900
public static function fromString ( $ str , $ directory = null ) { return new self ( ( new fphp \ Helper \ XmlParser ( ) ) -> parseString ( $ str ) ) ; }
Creates an XML configuration from an XML string .
9,901
protected function prepareDateTime ( $ value ) { if ( $ this -> requireAppTimeZone && ! static :: timeZoneEqual ( $ value -> getTimeZone ( ) , $ this -> appTimeZone ) ) { throw new \ UnexpectedValueException ( "Incoming time zone {$value->getTimeZone()->getName()} did not match app time zone {$this->appTimeZone->getName()}" ) ; } $ value = clone $ value ; $ value = $ value -> setTimeZone ( $ this -> dbTimeZone ) ; if ( $ this -> forceTime ) { $ value = $ value -> setTime ( ... $ this -> forceTime ) ; } return $ value ; }
Don t type hint here - there s no common interface between DateTime and DateTimeImmutable at 5 . 6 that supports all the methods we are using though both objects remain largely interchangeable .
9,902
protected function is ( $ methodName ) { if ( ! method_exists ( $ this , $ methodName ) ) { throw new TextParserException ( "The method `$methodName` does not exist" ) ; } if ( ! is_callable ( array ( $ this , $ methodName ) ) ) { throw new TextParserException ( "The method `$methodName` is inaccessible" ) ; } $ offset = $ this -> offset ; $ ret = call_user_func_array ( array ( $ this , $ methodName ) , array_slice ( func_get_args ( ) , 1 ) ) ; if ( ! $ ret ) { $ this -> offset = $ offset ; } return $ ret ; }
Does the next thing satisfies a given method?
9,903
public function getControllerName ( ) { if ( empty ( $ this -> controller_name ) ) { $ controller_class = get_class ( $ this ) ; if ( ( $ pos = strrpos ( $ controller_class , '\\' ) ) !== false ) { $ this -> controller_name = substr ( $ controller_class , $ pos + 1 ) ; } else { $ this -> controller_name = $ controller_class ; } } return $ this -> controller_name ; }
Return controller name without namespace .
9,904
protected function getParsedBodyParam ( ServerRequestInterface $ request , $ param_name , $ default = null ) { $ parsed_body = $ request -> getParsedBody ( ) ; if ( $ parsed_body ) { if ( is_array ( $ parsed_body ) && array_key_exists ( $ param_name , $ parsed_body ) ) { return $ parsed_body [ $ param_name ] ; } elseif ( is_object ( $ parsed_body ) && property_exists ( $ parsed_body , $ param_name ) ) { return $ parsed_body -> $ param_name ; } } return $ default ; }
Return a param from a parsed body .
9,905
function tzinfo ( $ zone ) { $ ref = new DateTimeZone ( $ zone ) ; $ loc = $ ref -> getLocation ( ) ; $ trn = $ ref -> getTransitions ( $ now = time ( ) , $ now ) ; $ out = array ( 'offset' => $ ref -> getOffset ( new DateTime ( 'now' , new DateTimeZone ( 'GMT' ) ) ) / 3600 , 'country' => $ loc [ 'country_code' ] , 'latitude' => $ loc [ 'latitude' ] , 'longitude' => $ loc [ 'longitude' ] , 'dst' => $ trn [ 0 ] [ 'isdst' ] ) ; unset ( $ ref ) ; return $ out ; }
Return information about specified Unix time zone
9,906
public function login ( ) { if ( $ this -> getGet ( 'code' ) ) { $ this -> client -> authenticate ( $ this -> getGet ( 'code' ) ) ; $ this -> setSession ( 'token' , $ this -> client -> getAccessToken ( ) ) ; $ redirect = $ this -> config -> redirect_uris [ 0 ] ; header ( 'Location: ' . filter_var ( $ redirect , FILTER_SANITIZE_URL ) ) ; return ; } $ token = $ this -> getSession ( 'token' ) ; if ( $ token ) { $ this -> client -> setAccessToken ( $ token ) ; } if ( $ this -> client -> getAccessToken ( ) ) { $ user = $ this -> oauth2_service -> userinfo -> get ( ) ; $ this -> setSession ( 'token' , $ this -> client -> getAccessToken ( ) ) ; return $ user ; } }
Logs in the user
9,907
public function countSelectors ( $ css = null ) { $ count = 0 ; if ( $ css !== null && $ this -> css !== $ css ) { $ this -> css = $ css ; $ this -> parsedCss = $ this -> splitIntoBlocks ( $ this -> css ) ; } foreach ( $ this -> parsedCss as $ rules ) { $ count += $ rules [ 'count' ] ; } return $ count ; }
Counts the selectors in the given css
9,908
public function split ( $ css = null , $ part = 1 , $ maxSelectors = self :: MAX_SELECTORS_DEFAULT ) { if ( empty ( $ css ) && empty ( $ this -> css ) ) { return null ; } if ( ! empty ( $ css ) && $ this -> css !== $ css ) { $ this -> css = $ css ; } $ charset = $ this -> extractCharset ( $ this -> css ) ; isset ( $ charset ) && $ this -> css = str_replace ( $ charset , '' , $ this -> css ) ; if ( empty ( $ this -> css ) ) { return null ; } $ this -> parsedCss = $ this -> splitIntoBlocks ( $ this -> css ) ; if ( empty ( $ this -> parsedCss ) ) { return null ; } $ output = $ charset ? : '' ; $ count = 0 ; $ partCount = 1 ; foreach ( $ this -> parsedCss as $ block ) { $ appliedMedia = false ; foreach ( $ block [ 'rules' ] as $ rule ) { $ tmpCount = $ rule [ 'count' ] ; if ( ( $ count + $ tmpCount ) > $ maxSelectors ) { $ partCount ++ ; $ count = 0 ; } $ count += $ tmpCount ; if ( $ partCount < $ part ) { continue ; } if ( $ partCount > $ part ) { break ; } if ( ! $ appliedMedia && isset ( $ block [ 'at-rule' ] ) ) { $ output .= $ block [ 'at-rule' ] . ' {' ; $ appliedMedia = true ; } $ output .= $ rule [ 'rule' ] ; } $ appliedMedia && $ output .= '}' ; } return $ output ; }
Returns the requested part of the split css
9,909
private function summarizeBlock ( $ block ) { $ block = array ( 'rules' => is_array ( $ block ) ? $ block : $ this -> splitIntoRules ( trim ( $ block ) ) , 'count' => 0 ) ; foreach ( $ block [ 'rules' ] as $ key => $ rule ) { $ block [ 'rules' ] [ $ key ] = array ( 'rule' => $ rule , 'count' => $ this -> countSelectorsInRule ( $ rule ) , ) ; $ block [ 'count' ] += $ block [ 'rules' ] [ $ key ] [ 'count' ] ; } return $ block ; }
Summarizes the block of CSS
9,910
private function splitIntoBlocks ( $ css ) { if ( is_array ( $ css ) ) { return $ css ; } $ blocks = array ( ) ; $ css = $ this -> stripComments ( $ css ) ; $ offset = 0 ; if ( preg_match_all ( '/(@[^{]+){([^{}]*{[^}]*})*\s*}/ism' , $ css , $ matches , PREG_OFFSET_CAPTURE ) > 0 ) { foreach ( $ matches [ 0 ] as $ key => $ match ) { $ atRule = trim ( $ matches [ 1 ] [ $ key ] [ 0 ] ) ; list ( $ rules , $ start ) = $ match ; if ( $ start > $ offset ) { $ block = trim ( substr ( $ css , $ offset , $ start - $ offset ) ) ; if ( ! empty ( $ block ) ) { $ blocks [ ] = $ this -> summarizeBlock ( $ block ) ; } } $ offset = $ start + strlen ( $ rules ) ; if ( strpos ( $ atRule , '@media' ) === 0 ) { $ block = $ this -> summarizeBlock ( substr ( $ rules , strpos ( $ rules , '{' ) + 1 , - 1 ) ) ; } else { $ block = array ( 'count' => 1 , 'rules' => array ( array ( 'rule' => substr ( $ rules , strpos ( $ rules , '{' ) + 1 , - 1 ) , 'count' => 1 , ) ) , ) ; } $ block [ 'at-rule' ] = $ atRule ; $ blocks [ ] = $ block ; } $ block = trim ( substr ( $ css , $ offset ) ) ; if ( ! empty ( $ block ) ) { $ blocks [ ] = $ this -> summarizeBlock ( $ block ) ; } } else { $ blocks [ ] = $ this -> summarizeBlock ( $ css ) ; } return $ blocks ; }
Splits the css into blocks maintaining the order of the rules and media queries
9,911
private function splitIntoRules ( $ css ) { $ rules = preg_split ( '/}/' , trim ( $ this -> stripComments ( $ css ) ) ) ; array_walk ( $ rules , function ( & $ s ) { ! empty ( $ s ) && $ s = trim ( "$s}" ) ; } ) ; return array_filter ( $ rules ) ; }
Splits the css into it s rules
9,912
public static function describeTable ( AdapterInterface $ db , $ table , $ schema = null ) { $ columns = $ db -> describeColumns ( $ table , $ schema ) ; $ indexes = $ db -> describeIndexes ( $ table , $ schema ) ; $ references = $ db -> describeReferences ( $ table , $ schema ) ; $ options = $ db -> tableOptions ( $ table , $ schema ) ; return new self ( [ 'name' => $ table , 'schema' => $ schema , 'columns' => array_map ( [ Column :: class , 'fromColumn' ] , $ columns ) , 'indexes' => array_map ( [ Index :: class , 'fromIndex' ] , $ indexes ) , 'references' => array_map ( [ Reference :: class , 'fromReference' ] , $ references ) , 'options' => $ options , ] ) ; }
Gets table description
9,913
static public function validate ( ezcDbSchema $ schema ) { $ errors = array ( ) ; foreach ( $ schema -> getSchema ( ) as $ tableName => $ table ) { $ fields = array_keys ( $ table -> fields ) ; foreach ( $ table -> indexes as $ indexName => $ index ) { foreach ( $ index -> indexFields as $ indexFieldName => $ dummy ) { if ( ! in_array ( $ indexFieldName , $ fields ) ) { $ errors [ ] = "Index '$tableName:$indexName' references unknown field name '$tableName:$indexFieldName'." ; } } } } return $ errors ; }
Validates if all the fields used in all indexes exist .
9,914
public function prepend ( $ message ) { $ this -> log = [ $ message ] + $ this -> log ; $ this -> extendedLog = [ $ message ] + $ this -> extendedLog ; }
Prepend a message to the log
9,915
public static function getExtensions ( string $ mime ) : array { $ extensions = [ ] ; foreach ( static :: $ _types as $ extension => $ mimeType ) { if ( $ mimeType === $ mime ) { $ extensions [ ] = $ extension ; } } return $ extensions ; }
Get extensions for one mime
9,916
protected function onSetAttribute ( $ name , $ value ) { $ listen = [ 'message_type' => 'type' , 'message_id' => 'id' , 'credits_cost' => 'credits' , 'rb_cost' => 'cost' , ] ; if ( isset ( $ listen [ $ name ] ) ) { if ( ! isset ( $ this -> { $ listen [ $ name ] } ) ) { $ this -> { $ listen [ $ name ] } = $ value ; } } }
When an attribute is set
9,917
public function delete_cache ( $ command_name = '' , $ arguments = false ) { $ uid = $ this -> hostname ; if ( ! empty ( $ arguments ) ) { $ uid .= md5 ( json_encode ( $ arguments ) ) ; } if ( ! empty ( $ this -> cache_delete ( $ uid , $ command_name ) ) ) { \ bbn \ x :: log ( [ $ uid , $ command_name ] , 'cache_delete' ) ; return true ; } return false ; }
This function allows the cancellation of the cache of the used commands
9,918
private function get_header_url ( ) { return "wget -O - --quiet --http-user=" . $ this -> user . " --http-passwd=" . escapeshellarg ( $ this -> pass ) . " --no-check-certificate 'https://" . $ this -> hostname . ":10000/" . ( $ this -> mode === 'cloudmin' ? 'server-manager' : 'virtual-server' ) . "/remote.cgi?json=1&multiline=&program=" ; }
This function is used to get the header url part to be executed
9,919
protected function createUrl ( BlockadeException $ exception , Request $ request ) { if ( $ exception instanceof AuthenticationException || $ exception instanceof CredentialsException ) { return $ this -> login_url . '/to' . $ request -> getPathInfo ( ) ; } return $ this -> deny_url ; }
Create the url to redirect to .
9,920
protected function createXmlHttpResponse ( BlockadeException $ exception , Request $ request ) { if ( $ exception instanceof AuthenticationException || $ exception instanceof CredentialsException ) { return new Response ( 'Authentication required' , Response :: HTTP_UNAUTHORIZED ) ; } return new Response ( 'Access denied' , Response :: HTTP_FORBIDDEN ) ; }
Create a response for XmlHttpRequests .
9,921
public function call ( $ function , array $ parameters = [ ] ) { $ inspector = new ReflectionFunction ( $ function ) ; $ dependencies = $ inspector -> getParameters ( ) ; $ dependencies = $ this -> process ( '' , $ parameters , $ dependencies ) ; return call_user_func_array ( $ function , $ dependencies ) ; }
Call a user function injecting the dependencies .
9,922
public function make ( string $ abstract , array $ parameters = [ ] ) { try { if ( ! isset ( $ this -> resolving [ $ abstract ] ) ) { $ this -> resolving [ $ abstract ] = $ this -> construct ( $ abstract ) ; } return $ this -> resolving [ $ abstract ] ( $ abstract , $ parameters ) ; } catch ( ReflectionException $ e ) { throw new ContainerException ( "Fail while attempt to make '$abstract'" , 0 , $ e ) ; } }
Makes an element or class injecting automatically all the dependencies .
9,923
protected function construct ( string $ abstract ) : Closure { $ inspector = new ReflectionClass ( $ abstract ) ; if ( ( $ constructor = $ inspector -> getConstructor ( ) ) && ( $ dependencies = $ constructor -> getParameters ( ) ) ) { return function ( string $ abstract , array $ parameters ) use ( $ inspector , $ dependencies ) { return $ inspector -> newInstanceArgs ( $ this -> process ( $ abstract , $ parameters , $ dependencies ) ) ; } ; } return function ( string $ abstract ) { return new $ abstract ; } ; }
Construct a class and all the dependencies using the reflection library of PHP .
9,924
protected function process ( string $ abstract , array $ parameters , array $ dependencies ) : array { foreach ( $ dependencies as & $ dependency ) { if ( isset ( $ parameters [ $ dependency -> name ] ) ) { $ dependency = $ parameters [ $ dependency -> name ] ; } else $ dependency = $ this -> resolve ( $ abstract , $ dependency ) ; } return $ dependencies ; }
Process all dependencies
9,925
protected function resolve ( string $ abstract , ReflectionParameter $ dependency ) { $ key = $ abstract . $ dependency -> name ; if ( ! isset ( $ this -> resolved [ $ key ] ) ) { $ this -> resolved [ $ key ] = $ this -> generate ( $ abstract , $ dependency ) ; } return $ this -> resolved [ $ key ] ( $ this ) ; }
Resolve all the given class reflected dependencies .
9,926
protected function generate ( string $ abstract , ReflectionParameter $ dependency ) : Closure { if ( $ class = $ dependency -> getClass ( ) ) { return $ this -> build ( $ class -> name , "{$abstract}{$class->name}" ) ; } try { $ value = $ dependency -> getDefaultValue ( ) ; return function ( ) use ( $ value ) { return $ value ; } ; } catch ( ReflectionException $ e ) { throw new ContainerException ( "Cannot resolve '$dependency->name' of '$abstract'" , 0 , $ e ) ; } }
Generate the dependencies callbacks to jump some conditions in every dependency creation .
9,927
protected function build ( string $ classname , string $ entry ) : Closure { if ( isset ( $ this -> dependencies [ $ entry ] ) ) { return $ this -> dependencies [ $ entry ] ; } return function ( ) use ( $ classname ) { return $ this -> make ( $ classname ) ; } ; }
Create a build closure for a given class
9,928
public function flush ( ) : ContainerInterface { $ this -> collection = [ ] ; $ this -> dependencies = [ ] ; $ this -> resolving = [ ] ; $ this -> resolved = [ ] ; return $ this ; }
Reset the container removing all the elements cache and options .
9,929
public function isSingleton ( string $ abstract ) : bool { if ( ! $ this -> has ( $ abstract ) ) { throw new NotFoundException ( "Element '$abstract' not found" ) ; } return $ this -> collection [ $ abstract ] instanceof Closure === false ; }
Verify if an element has a singleton instance .
9,930
public function set ( string $ abstract , $ concrete , bool $ shared = false ) : ContainerInterface { if ( is_object ( $ concrete ) ) { return $ this -> instance ( $ abstract , $ concrete ) ; } if ( $ concrete instanceof Closure === false ) { $ concrete = function ( Container $ container ) use ( $ concrete ) { return $ container -> make ( $ concrete ) ; } ; } if ( $ shared === true ) { $ this -> collection [ $ abstract ] = $ concrete ( $ this ) ; } else $ this -> collection [ $ abstract ] = $ concrete ; return $ this ; }
Bind a new element to the container .
9,931
public function setIf ( string $ abstract , $ concrete , bool $ shared = false ) : ContainerInterface { if ( ! $ this -> has ( $ abstract ) ) { $ this -> set ( $ abstract , $ concrete , $ shared ) ; } return $ this ; }
Bind a new element to the container IF the element name not exists in the container .
9,932
public function setTo ( string $ class , string $ dependencyName , $ dependency ) : ContainerInterface { $ key = "$class$dependencyName" ; if ( $ dependency instanceof Closure === false ) { $ this -> set ( $ key , $ dependency ) ; $ resolved = $ this -> collection [ $ key ] ; $ dependency = function ( ) use ( $ resolved ) { return $ resolved ; } ; unset ( $ resolved , $ this -> collection [ $ key ] ) ; } $ this -> dependencies [ $ key ] = $ dependency ; return $ this ; }
Bind an specific instance to a class dependency .
9,933
public function instance ( string $ abstract , $ instance ) : ContainerInterface { if ( ! is_object ( $ instance ) ) { throw new ContainerException ( 'Trying to store ' . gettype ( $ instance ) . ' as object.' ) ; } $ this -> collection [ $ abstract ] = $ instance ; return $ this ; }
Bind an object to the container .
9,934
public function extend ( string $ abstract , closure $ extension ) : ContainerInterface { $ object = $ this -> get ( $ abstract ) ; $ this -> collection [ $ abstract ] = $ extension ( $ object , $ this ) ; return $ this ; }
Modify an element with a given function that receive the old element as argument .
9,935
public function share ( string $ abstract ) : ContainerInterface { $ object = $ this -> get ( $ abstract ) ; $ this -> collection [ $ abstract ] = $ object ; return $ this ; }
Makes an resolvable element an singleton .
9,936
public function start ( $ key = 'default' ) { if ( ! isset ( $ this -> measures [ $ key ] ) ) { $ this -> measures [ $ key ] = [ 'num' => 0 , 'sum' => 0 , 'start' => microtime ( 1 ) ] ; } else { $ this -> measures [ $ key ] [ 'start' ] = microtime ( 1 ) ; } }
Starts a timer for a given key
9,937
public function has_started ( $ key ) { if ( isset ( $ this -> measures [ $ key ] ) ) { return $ this -> measures [ $ key ] [ 'start' ] > 0 ; } return false ; }
Returns true is the timer has started for the given key
9,938
public function stop ( $ key = 'default' ) { if ( isset ( $ this -> measures [ $ key ] , $ this -> measures [ $ key ] [ 'start' ] ) ) { $ this -> measures [ $ key ] [ 'num' ] ++ ; $ time = $ this -> measure ( $ key ) ; $ this -> measures [ $ key ] [ 'sum' ] += $ time ; unset ( $ this -> measures [ $ key ] [ 'start' ] ) ; return $ time ; } else { die ( "Missing a start declaration for timer $key" ) ; } }
Stops a timer for a given key
9,939
protected function getArrayAbleAppends ( ) { if ( property_exists ( $ this , 'customAppends' ) ) { if ( is_array ( self :: $ customAppends ) && count ( self :: $ customAppends ) ) return self :: $ customAppends ; elseif ( is_bool ( self :: $ customAppends ) && ! self :: $ customAppends ) return [ ] ; } return parent :: getArrayAbleAppends ( ) ; }
Append attribute ignore
9,940
public function get ( string $ id ) : ? array { $ mask = $ this -> db -> rselect ( 'bbn_notes_masks' , [ ] , [ 'id_note' => $ id ] ) ; if ( $ data = $ this -> notes -> get ( $ mask [ 'id_note' ] ) ) { $ data [ 'default' ] = $ mask [ 'def' ] ; $ data [ 'id_type' ] = $ mask [ 'id_type' ] ; $ data [ 'type' ] = $ this -> o -> text ( $ mask [ 'id_type' ] ) ; $ data [ 'name' ] = $ mask [ 'name' ] ; return $ data ; } return null ; }
Gets the content of a mask based on the provided ID
9,941
private function getDatetime ( $ datein , $ timein ) { $ date = explode ( '-' , $ datein ) ; $ time = explode ( ':' , $ timein ) ; $ datetime = Carbon :: create ( $ date [ 0 ] , $ date [ 1 ] , $ date [ 2 ] , $ time [ 0 ] , $ time [ 1 ] ) ; return $ datetime ; }
Get Carbon start datetime and end datemime .
9,942
public function confirmDestroy ( Request $ request , Event $ event ) { $ this -> authorize ( 'delete' , $ event ) ; return view ( 'laralum::pages.confirmation' , [ 'method' => 'DELETE' , 'message' => __ ( 'laralum_events::general.sure_del_event' , [ 'event' => $ event -> title ] ) , 'action' => route ( 'laralum::events.destroy' , [ 'event' => $ event -> id ] ) , ] ) ; }
confirm destroy of the specified resource from storage .
9,943
public function join ( Event $ event ) { $ this -> authorize ( 'join' , Event :: class ) ; $ event -> addUser ( User :: findOrfail ( Auth :: id ( ) ) ) ; return redirect ( ) -> route ( 'laralum::events.index' ) -> with ( 'success' , __ ( 'laralum_events::general.joined_event' , [ 'id' => $ event -> id ] ) ) ; }
Join to the specified resource from storage .
9,944
public function leave ( Event $ event ) { $ this -> authorize ( 'join' , Event :: class ) ; $ event -> deleteUser ( User :: findOrfail ( Auth :: id ( ) ) ) ; return redirect ( ) -> route ( 'laralum::events.index' ) -> with ( 'success' , __ ( 'laralum_events::general.left_event' , [ 'id' => $ event -> id ] ) ) ; }
Leave from the specified resource from storage .
9,945
public function makeResponsible ( Event $ event , User $ user ) { $ this -> authorize ( 'update' , $ event ) ; $ event -> addResponsible ( $ user ) ; return redirect ( ) -> route ( 'laralum::events.show' , [ 'event' => $ event -> id ] ) -> with ( 'success' , __ ( 'laralum_events::general.responsible_added' , [ 'event_id' => $ event -> id , 'user_id' => $ user -> id ] ) ) ; }
Make author of to the specified resource from storage .
9,946
public function undoResponsible ( Event $ event , User $ user ) { $ this -> authorize ( 'update' , $ event ) ; $ event -> deleteResponsible ( $ user ) ; return redirect ( ) -> route ( 'laralum::events.show' , [ 'event' => $ event -> id ] ) -> with ( 'success' , __ ( 'laralum_events::general.responsible_deleted' , [ 'event_id' => $ event -> id , 'user_id' => $ user -> id ] ) ) ; }
Undo author from the specified resource from storage .
9,947
protected function createStream ( BrowserKitRequest $ request ) { $ stream = fopen ( 'php://temp' , 'a+' ) ; fwrite ( $ stream , $ request -> getContent ( ) ) ; return new Stream ( $ stream ) ; }
Create the output stream handle
9,948
protected function buildFullUri ( BrowserKitRequest $ request ) { $ uri = new Uri ( $ request -> getUri ( ) ) ; $ queryParams = [ ] ; parse_str ( $ uri -> getQuery ( ) , $ queryParams ) ; if ( $ request -> getMethod ( ) === 'GET' ) { $ queryParams = array_merge ( $ queryParams , $ request -> getParameters ( ) ) ; $ uri = $ uri -> withQuery ( http_build_query ( $ queryParams ) ) ; } return [ $ uri , $ queryParams ] ; }
Build a full URI from a request
9,949
protected function setRequestHeaders ( ServerRequestInterface $ baseRequest , array $ params ) { $ headers = ( new ServerRequest ( ) ) -> withServerParams ( $ params ) -> getHeaders ( ) ; $ psrRequest = $ baseRequest ; foreach ( $ headers as $ header => $ values ) { $ psrRequest = $ psrRequest -> withHeader ( $ header , $ values ) ; } return $ psrRequest ; }
Set the request headers
9,950
protected function setRequestProperties ( ServerRequestInterface $ baseRequest , BrowserKitRequest $ request , Stream $ stream , UriInterface $ uri , array $ queryParams ) { return $ baseRequest -> withProtocolVersion ( '1.1' ) -> withBody ( $ stream ) -> withMethod ( $ request -> getMethod ( ) ) -> withRequestTarget ( ( string ) ( $ uri -> withScheme ( '' ) -> withHost ( '' ) -> withPort ( '' ) -> withUserInfo ( '' ) ) ) -> withCookieParams ( $ request -> getCookies ( ) ) -> withUri ( $ uri ) -> withQueryParams ( $ queryParams ) -> withParsedBody ( $ request -> getMethod ( ) !== 'GET' && ! empty ( $ request -> getParameters ( ) ) ? $ request -> getParameters ( ) : null ) -> withUploadedFiles ( $ this -> convertUploadedFiles ( $ request -> getFiles ( ) ) ) ; }
Set the server request properties
9,951
protected function convertUploadedFiles ( array $ files ) { $ fileObjects = [ ] ; foreach ( $ files as $ fieldName => $ file ) { if ( $ file instanceof UploadedFileInterface ) { $ fileObjects [ $ fieldName ] = $ file ; } elseif ( ! isset ( $ file [ 'tmp_name' ] ) && ! isset ( $ file [ 'error' ] ) ) { $ fileObjects [ $ fieldName ] = $ this -> convertUploadedFiles ( $ file ) ; } else { $ fileObjects [ $ fieldName ] = new UploadedFile ( $ file ) ; } } return $ fileObjects ; }
Convert a list of uploaded files to a Jasny PSR - 7 uploaded files
9,952
public function convert ( BrowserKitRequest $ request , ServerRequestInterface $ baseRequest ) { $ stream = $ this -> createStream ( $ request ) ; list ( $ uri , $ queryParams ) = $ this -> buildFullUri ( $ request ) ; if ( $ baseRequest instanceof ServerRequest ) { $ serverParams = $ this -> determineServerParams ( $ request , $ uri , ( array ) $ queryParams ) ; $ psrRequest = $ baseRequest -> withServerParams ( $ request -> getServer ( ) + $ serverParams ) ; } else { $ psrRequest = $ this -> setRequestHeaders ( $ baseRequest , $ request -> getServer ( ) ) ; } return $ this -> setRequestProperties ( $ psrRequest , $ request , $ stream , $ uri , ( array ) $ queryParams ) ; }
Convert a codeception request to a PSR - 7 server request
9,953
public static function toArray ( $ e , $ getTrace = true , $ catcher = null ) { $ data = [ 'class' => \ get_class ( $ e ) , 'message' => $ e -> getMessage ( ) , 'code' => $ e -> getCode ( ) , 'file' => $ e -> getFile ( ) . ':' . $ e -> getLine ( ) , ] ; if ( $ catcher ) { $ data [ 'catcher' ] = $ catcher ; } if ( $ getTrace ) { $ data [ 'trace' ] = $ e -> getTrace ( ) ; } return $ data ; }
Converts an exception into a simple array .
9,954
protected function supportedType ( $ type ) { $ supportedType = false ; $ baseType = substr ( $ type , 0 , strpos ( $ type , '-' ) ) ; if ( array_key_exists ( $ baseType , $ this -> supportedTypes ) ) { $ supportedType = $ baseType ; } return $ supportedType ; }
Find the matching installer type
9,955
protected function dbConnect ( array $ aOptions ) { $ aOptions = array_merge ( SudoBible :: DB_CREDS , $ aOptions ) ; try { $ this -> db = new mysqli ( $ aOptions [ 'db_host' ] , $ aOptions [ 'db_user' ] , $ aOptions [ 'db_pass' ] , $ aOptions [ 'db_name' ] , $ aOptions [ 'db_port' ] ) ; } catch ( Exception $ e ) { throw new Exception ( __METHOD__ . ': DB connection failed.' ) ; } }
Connect to the DB .
9,956
public function setTranslation ( $ mTranslation ) { $ this -> iTranslation = is_numeric ( $ mTranslation ) ? $ mTranslation : $ this -> getIdFor ( 'translation' , $ mTranslation ) ; }
Set the translation preference .
9,957
protected function queryFiles ( $ strAction ) { if ( ! in_array ( $ strAction , [ 'create' , 'insert' , 'drop' ] ) ) throw new Exception ( 'Invalid parameter "' . $ strAction . '" sent to SudoBible::queryFiles()' ) ; $ strPath = 'queries/' . $ this -> dbType . '/' . $ strAction ; foreach ( scandir ( $ strPath ) as $ strFilename ) { if ( in_array ( substr ( $ strFilename , - 4 ) , [ '.sql' ] ) ) { $ mResult = $ this -> db -> query ( file_get_contents ( $ strPath . '/' . $ strFilename ) ) ; if ( 'insert' !== $ strAction && true !== $ mResult ) { throw new Exception ( 'Unable to ' . $ strAction . ' table in ' . $ strFilename . ' - please ensure your DB user has the right permissions.' ) ; } } } }
Run the query files in a given directory .
9,958
public function topic ( $ mTopic , $ bRandomOne = false ) { if ( is_string ( $ mTopic ) ) $ mTopic = $ this -> getIdFor ( 'topic' , $ mTopic ) ; $ q = 'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`' . ' FROM `sudo_bible_topic_verses` AS tv' . ' LEFT JOIN `sudo_bible_verses` AS verses ON verses.`book_id` = tv.`book_id`' . ' AND verses.`chapter` = tv.`chapter` AND verses.`verse` = tv.`verse`' . ' LEFT JOIN `sudo_bible_books` AS books ON books.`id` = tv.`book_id`' . ' WHERE verses.`translation_id` = ? AND tv.`topic_id` = ?' . ' ORDER BY `book_id`, `chapter`, `verse`' ; $ mResult = $ this -> runPreparedQuery ( $ q , [ $ this -> iTranslation , $ mTopic ] ) ; if ( $ bRandomOne ) { $ mResult = new SudoBiblePassage ( [ $ mResult [ array_rand ( $ mResult ) ] ] , $ this ) ; } else { foreach ( $ mResult as $ k => $ oResult ) $ mResult [ $ k ] = new SudoBiblePassage ( [ $ oResult ] , $ this ) ; } return $ mResult ; }
Return all verses on a single topic .
9,959
public function nextVerse ( $ mBook , $ iChapter , $ iVerse ) { $ oPassage = new SudoBiblePassage ( [ ] , $ this ) ; $ iBookId = is_numeric ( $ mBook ) ? $ mBook : getIdFor ( 'book' , $ mBook ) ; $ aSteps = [ [ $ iBookId , $ iChapter , $ iVerse + 1 ] , [ $ iBookId , $ iChapter + 1 , 1 ] , [ $ iBookId + 1 , 1 , 1 ] , ] ; foreach ( $ aSteps as $ aStep ) { if ( $ oPassage -> isEmpty ( ) ) $ oPassage = call_user_func_array ( [ $ this , 'verse' ] , $ aStep ) ; else break ; } return $ oPassage ; }
Get the verse following the given reference .
9,960
protected function getIdFor ( $ strType , $ strNameAbbr ) { if ( ! in_array ( $ strType , [ 'book' , 'translation' , 'topic' ] ) ) throw new Exception ( 'Invalid entity type "' . $ strType . '"' ) ; $ strTableName = 'sudo_bible_' . $ strType . 's' ; $ q = 'SELECT `id` FROM `' . $ strTableName . '` WHERE `name` LIKE ?' ; $ aParams = [ $ strNameAbbr ] ; if ( 'topic' !== $ strType ) { $ q .= ' OR `abbr` LIKE ?' ; $ aParams [ ] = $ strNameAbbr ; } $ aResult = $ this -> runPreparedQuery ( $ q , $ aParams ) ; $ iId = $ aResult [ 0 ] -> id ; if ( ! is_numeric ( $ iId ) ) throw new Exception ( 'Invalid ' . $ strType . ' "' . $ strNameAbbr . '" given.' ) ; return $ iId ; }
Get an ID given the name .
9,961
protected function runPreparedQuery ( $ strSql , array $ aParams = [ ] ) { $ aRefParams = [ ] ; foreach ( $ aParams as $ k => $ v ) $ aRefParams [ $ k ] = & $ aParams [ $ k ] ; $ strDataTypes = '' ; foreach ( $ aRefParams as $ mValue ) $ strDataTypes .= is_int ( $ mValue ) ? 'i' : 's' ; array_unshift ( $ aRefParams , $ strDataTypes ) ; $ stmt = $ this -> db -> prepare ( $ strSql ) ; call_user_func_array ( array ( $ stmt , 'bind_param' ) , $ aRefParams ) ; $ stmt -> execute ( ) ; $ oResult = $ stmt -> get_result ( ) ; $ aReturn = [ ] ; $ i = 0 ; while ( $ oRow = $ oResult -> fetch_object ( ) ) $ aReturn [ ] = $ oRow ; $ stmt -> close ( ) ; return $ aReturn ; }
Run a mysqli prepared query given the query string and params .
9,962
protected static function tryDelete ( $ path ) { $ success = true ; try { if ( ! @ unlink ( $ path ) ) { $ success = false ; } } catch ( ErrorException $ e ) { $ success = false ; } return $ success ; }
Try to delete a file
9,963
public function makeLogEvent ( $ name , $ eventListener , $ status ) { if ( $ this -> options [ 'log_events' ] && ( $ this -> options [ 'log_all_events' ] || in_array ( $ name , $ this -> logEvents , true ) ) ) { $ this -> loggerInstance -> makeLog ( [ 'event_name' => $ name , 'listener' => $ this -> getListenerData ( $ eventListener ) , 'status' => $ status ] ) ; } return $ this ; }
check that event data can be logged and create log message
9,964
protected function findModel ( $ id ) { if ( ( $ model = ProductTypeMeta :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } }
Finds the ProductTypeMeta model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
9,965
public static function enable ( ) { if ( ! is_array ( $ functions = spl_autoload_functions ( ) ) ) { return ; } foreach ( $ functions as $ function ) { spl_autoload_unregister ( $ function ) ; } foreach ( $ functions as $ function ) { if ( is_array ( $ function ) && $ function [ 0 ] instanceof UniversalClassLoader ) { $ loader = new static ( ) ; $ loader -> registerNamespaceFallbacks ( $ function [ 0 ] -> getNamespaceFallbacks ( ) ) ; $ loader -> registerPrefixFallbacks ( $ function [ 0 ] -> getPrefixFallbacks ( ) ) ; $ loader -> registerNamespaces ( $ function [ 0 ] -> getNamespaces ( ) ) ; $ loader -> registerPrefixes ( $ function [ 0 ] -> getPrefixes ( ) ) ; $ loader -> useIncludePath ( $ function [ 0 ] -> getUseIncludePath ( ) ) ; $ function [ 0 ] = $ loader ; } spl_autoload_register ( $ function ) ; } }
Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones .
9,966
static function createFromData ( $ data ) { $ instance = new static ( ) ; $ instance -> day = $ data [ 0 ] ; $ instance -> hour = $ data [ 1 ] ; $ instance -> numberCommits = $ data [ 2 ] ; return $ instance ; }
Number of commits
9,967
public function registerResource ( Resources \ Resource $ resource ) { $ this -> resources [ strtolower ( $ resource -> getName ( ) ) ] = $ resource ; }
Registers a resource .
9,968
public function authorize ( $ args ) { $ numArgs = func_num_args ( ) ; if ( $ numArgs === 0 ) { throw new \ InvalidArgumentException ( 'Wrapper->authorize expects atleast 1 argument!' ) ; return ; } if ( $ numArgs === 1 ) { $ arg1 = func_get_arg ( 0 ) ; if ( $ arg1 instanceof OAuthResponse ) { $ this -> accessToken = $ arg1 -> getAccessToken ( ) ; $ this -> registeredScopes = $ arg1 -> getScope ( ) ; } elseif ( is_string ( $ arg1 ) ) { $ this -> accessToken = $ arg1 ; } else { throw new \ InvalidArgumentException ( "Passed argument must be an access token OR an instance of Raideer\TwitchApi\OAuthResponse" ) ; return ; } } elseif ( $ numArgs === 2 ) { list ( $ arg1 , $ arg2 ) = func_get_args ( ) ; if ( is_string ( $ arg1 ) && is_array ( $ arg2 ) ) { $ this -> accessToken = $ arg1 ; $ this -> registeredScopes = $ arg2 ; } else { throw new \ InvalidArgumentException ( 'First argument must be an accessToken and the second must be an array of registered scopes' ) ; return ; } } else { throw new \ InvalidArgumentException ( 'Wrapper->authorize expects 1 or 2 arguments' ) ; return ; } $ this -> authorized = true ; }
Enables the authorized requests .
9,969
public function hasScope ( $ name , $ strict = true ) { if ( ! $ strict ) { if ( empty ( $ this -> registeredScopes ) ) { return true ; } } return in_array ( $ name , $ this -> registeredScopes ) ; }
Checks if scope is registered .
9,970
public function checkScope ( $ name , $ strict = false ) { if ( ! $ this -> hasScope ( $ name , $ strict ) ) { throw new Exceptions \ OutOfScopeException ( "Scope $name is not registered!" ) ; } }
Checks if scope is registered Throws an exception if scope doesn t exist .
9,971
public function resource ( $ name ) { if ( ! isset ( $ this -> resources [ $ name ] ) ) { throw new Exceptions \ ResourceException ( "Resource $name does not exist!" ) ; return ; } return $ this -> resources [ $ name ] ; }
Returns an API resource .
9,972
public function request ( $ type , $ target , $ options = [ ] , $ authorized = false ) { $ headers = [ 'Accept' => 'application/vnd.twitchtv.v3+json' , ] ; if ( $ authorized ) { $ headers [ 'Authorization' ] = 'OAuth ' . $ this -> accessToken ; } $ options = array_merge_recursive ( [ 'headers' => $ headers ] , $ options ) ; try { if ( $ this -> throttling ) { $ this -> throttle -> throttle ( ) ; } $ response = $ this -> client -> request ( $ type , $ this -> apiURL . $ target , $ options ) ; } catch ( RequestException $ e ) { if ( $ e -> hasResponse ( ) ) { $ response = $ e -> getResponse ( ) ; } else { return ; } } $ body = json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ; return ( json_last_error ( ) == JSON_ERROR_NONE ) ? $ body : $ response -> getBody ( ) -> getContents ( ) ; }
Makes a GuzzleHttp request .
9,973
public function addJob ( Job \ WrappedJob $ job , $ queue ) { $ qb = $ this -> conn -> createQueryBuilder ( ) ; $ qb -> insert ( $ this -> table_name ) ; $ qb -> values ( [ 'status' => ':status' , 'job' => ':job' , 'name' => ':name' , 'queue' => ':queue' , 'created_at' => ':created_at' , 'available_at' => ':available_at' , ] ) ; $ qb -> setParameters ( [ 'status' => self :: JOB_STATUS_CREATED , 'queue' => $ queue , 'job' => ( string ) $ job , 'name' => $ job -> getName ( ) , ] ) ; $ qb -> setParameter ( ':created_at' , new \ DateTime ( ) , Type :: DATETIME ) ; $ available_at = $ job -> getDelay ( ) ? new \ DateTime ( sprintf ( '+%d seconds' , $ job -> getDelay ( ) ) ) : new \ DateTime ( ) ; $ qb -> setParameter ( ':available_at' , $ available_at , Type :: DATETIME ) ; $ qb -> execute ( ) ; return $ job -> withAddedPayload ( [ '_doctrine' => [ 'id' => $ this -> conn -> lastInsertId ( ) ] ] ) ; }
add a new wrapped job
9,974
public function getAvailableJobs ( $ queue , $ max = 10 ) { $ qb = $ this -> conn -> createQueryBuilder ( ) ; $ qb -> select ( '*' ) ; $ qb -> from ( $ this -> table_name ) ; $ qb -> where ( 'status = :status AND queue = :queue AND available_at <= :now' ) ; $ qb -> orderBy ( 'status' ) ; $ qb -> setParameters ( [ 'status' => self :: JOB_STATUS_CREATED , 'queue' => $ queue , ] ) ; $ qb -> setParameter ( 'now' , new \ DateTime ( ) , Type :: DATETIME ) ; $ qb -> setMaxResults ( $ max ) ; $ stmt = $ qb -> execute ( ) ; return $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; }
get available jobs
9,975
public function initialize ( Controller $ controller ) { parent :: initialize ( $ controller ) ; $ loginUrl = array ( 'plugin' => 'users' , 'controller' => 'users' , 'action' => 'login' , 'admin' => false , ) ; if ( ! empty ( $ controller -> request -> params [ 'tenant' ] ) ) { $ loginUrl [ 'action' ] = 'tenant_login' ; } $ this -> loginAction = $ loginUrl ; $ this -> logoutRedirect = $ loginUrl ; }
Initializes AuthComponent for use in the controller .
9,976
public function isAuthorized ( $ user = null , CakeRequest $ request = null ) { if ( empty ( $ user ) && ! $ this -> user ( ) ) { return false ; } if ( empty ( $ user ) ) { $ user = $ this -> user ( ) ; } if ( empty ( $ request ) ) { $ request = $ this -> request ; } if ( empty ( $ this -> _authorizeObjects ) ) { $ this -> constructAuthorize ( ) ; } foreach ( $ this -> _authorizeObjects as $ authorizer ) { if ( $ authorizer -> authorize ( $ user , $ request ) === false ) { return false ; } } return true ; }
Al contrario que el isAuthorized que viene en CakePhp este se fija si algun Adapter retorna false y entonces retorna false .
9,977
public function getStreams ( $ params = [ ] ) { $ defaults = [ 'game' => null , 'channel' => null , 'limit' => 25 , 'offset' => 0 , 'client_id' => null , 'stream_type' => 'all' , ] ; $ types = [ 'stream_type' => [ 'all' , 'playlist' , 'live' ] , ] ; return $ this -> wrapper -> request ( 'GET' , 'streams' , [ 'query' => $ this -> resolveOptions ( $ params , $ defaults , [ ] , $ types ) ] ) ; }
Returns a list of stream objects that are queried by a number of parameters sorted by number of viewers descending .
9,978
public function entity ( $ entityType , $ id , $ timestamp ) { $ params = array ( 'type_name' => $ entityType , 'id' => $ id , 'timestamp' => $ timestamp , ) ; return $ this -> post ( 'versions/entity' , $ params ) ; }
Retrieve a past value of single entity by primary key and timestamp .
9,979
private static function get_sameWith_value ( $ dio , $ rules ) { $ sub_name = $ rules [ 'sameWith' ] ; if ( $ rules instanceof Rules ) { $ sub_filter = clone $ rules ; } else { $ sub_filter = $ rules ; } $ sub_filter [ 'sameWith' ] = false ; $ sub_filter [ 'required' ] = false ; $ value = $ dio -> find ( $ sub_name , $ sub_filter ) ; $ value = $ dio -> verify -> is ( $ value , $ sub_filter ) ; return $ value ; }
find the same with value .
9,980
public function get ( $ key ) { $ ret = $ this -> traverseTree ( $ key ) ; if ( ! is_scalar ( $ ret ) ) { throw new UnexpectedValueException ( "The {$key} configuration value is not scalar" ) ; } return $ ret ; }
Get a value for a configuration key
9,981
protected function traverseTree ( $ path ) { $ currentNode = $ this -> tree ; $ pathElements = explode ( static :: KEY_NODE_DELIMITER , $ path ) ; foreach ( $ pathElements as $ node ) { if ( ! isset ( $ currentNode [ $ node ] ) ) { throw new MissingKeyException ( "{$path} configuration value is not found" ) ; } $ currentNode = $ currentNode [ $ node ] ; } return $ currentNode ; }
Traverse a tree until the end of path is reached
9,982
public function match ( string $ subject , int $ flags = 0 , int $ offset = 0 ) : array { preg_match ( $ this -> pattern -> getPattern ( ) . $ this -> modifier , $ subject , $ matches , $ flags , $ offset ) ; 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 $ matches ; }
Retrieve match from subject with Pattern
9,983
public function setHelperSet ( HelperSet $ helperSet ) { parent :: setHelperSet ( $ helperSet ) ; $ this -> getHelper ( 'phpdocumentor_logger' ) -> addOptions ( $ this ) ; }
Registers the current command .
9,984
public function toArray ( ) { $ response = array ( ) ; foreach ( $ this -> items as $ key => $ item ) { $ response [ ] = $ item -> toArray ( ) ; } return $ response ; }
Return collection as array
9,985
public function lOr ( ) { $ args = func_get_args ( ) ; if ( count ( $ args ) < 1 ) { throw new ezcQueryVariableParameterException ( 'lOr' , count ( $ args ) , 1 ) ; } $ elements = ezcQuerySelect :: arrayFlatten ( $ args ) ; if ( count ( $ elements ) == 1 ) { return $ elements [ 0 ] ; } else { return '( ' . join ( ' OR ' , $ elements ) . ' )' ; } }
Returns the SQL to bind logical expressions together using a logical or .
9,986
public function eq ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} = {$value2}" ; }
Returns the SQL to check if two values are equal .
9,987
public function neq ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} <> {$value2}" ; }
Returns the SQL to check if two values are unequal .
9,988
public function gt ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} > {$value2}" ; }
Returns the SQL to check if one value is greater than another value .
9,989
public function gte ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} >= {$value2}" ; }
Returns the SQL to check if one value is greater than or equal to another value .
9,990
public function lt ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} < {$value2}" ; }
Returns the SQL to check if one value is less than another value .
9,991
public function lte ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} <= {$value2}" ; }
Returns the SQL to check if one value is less than or equal to another value .
9,992
public function between ( $ expression , $ value1 , $ value2 ) { $ expression = $ this -> getIdentifier ( $ expression ) ; $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$expression} BETWEEN {$value1} AND {$value2}" ; }
Returns SQL that checks if an expression evaluates to a value between two values .
9,993
public function bitAnd ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "( {$value1} & {$value2} )" ; }
Returns the SQL that performs the bitwise AND on two values .
9,994
public function bitOr ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "( {$value1} | {$value2} )" ; }
Returns the SQL that performs the bitwise OR on two values .
9,995
protected function prepareArray ( array $ conditions ) { switch ( count ( $ conditions ) ) { case 1 : $ result = $ conditions [ 0 ] ; break ; case 2 : if ( is_array ( $ conditions [ 1 ] ) ) { $ result = $ conditions [ 0 ] . ' IN (' . implode ( ',' , $ conditions [ 1 ] ) . ')' ; } elseif ( is_null ( $ conditions [ 1 ] ) ) { $ result = $ conditions [ 0 ] . ' IS NULL' ; } elseif ( $ conditions [ 1 ] instanceof \ pwf \ components \ querybuilder \ interfaces \ SelectBuilder ) { $ result = $ conditions [ 0 ] . ' IN (' . $ conditions [ 1 ] -> generate ( ) . ')' ; $ this -> setParams ( array_merge ( $ this -> getParams ( ) , $ conditions [ 1 ] -> getParams ( ) ) ) ; } else { $ result = $ conditions [ 0 ] . '=?' ; $ this -> addParam ( $ conditions [ 0 ] , $ conditions [ 1 ] ) ; } break ; case 3 : $ left = is_array ( $ conditions [ 1 ] ) ? $ this -> prepareConditions ( $ conditions [ 1 ] ) : $ conditions [ 1 ] ; $ right = is_array ( $ conditions [ 2 ] ) ? $ this -> prepareConditions ( $ conditions [ 2 ] ) : $ conditions [ 2 ] ; $ result = '((' . $ left . ') ' . $ conditions [ 0 ] . ' (' . $ right . '))' ; break ; default : throw new \ Exception ( 'Wrong condition configuration' ) ; } return $ result ; }
Array to string
9,996
public function checkEmailVerification ( MvcEvent $ event ) { $ services = $ event -> getApplication ( ) -> getServiceManager ( ) ; $ appConfig = $ services -> get ( 'config' ) ; $ config = $ this -> defaultConfig ; if ( array_key_exists ( self :: CONFIG_KEY , $ appConfig ) ) { $ config = $ appConfig [ self :: CONFIG_KEY ] + $ config ; } $ routeMatch = $ event -> getRouteMatch ( ) ; if ( in_array ( $ routeMatch -> getMatchedRouteName ( ) , $ config [ 'routeBlacklist' ] ) ) { return ; } $ auth = $ services -> get ( $ config [ 'authServiceName' ] ) ; if ( ! $ auth -> hasIdentity ( ) ) { return ; } $ identity = $ services -> get ( $ config [ 'identityServiceName' ] ) ; $ isVerified = $ config [ 'identityCheckType' ] == 'property' ? $ identity -> $ config [ 'identityCheck' ] : call_user_func ( array ( $ identity , $ config [ 'identityCheck' ] ) ) ; if ( $ isVerified ) { return ; } return $ services -> get ( 'controllerPluginManager' ) -> get ( 'redirect' ) -> toRoute ( $ config [ 'route' ] , $ config [ 'routeParams' ] ) ; }
Check if the email address is verified and if not redirects to a specified route .
9,997
public static function fromArrayAndSettings ( $ cfg , $ settings ) { $ directorySpecification = new self ( $ cfg , $ settings -> getDirectory ( ) ) ; $ directorySpecification -> set ( "source" , $ settings -> getPath ( $ directorySpecification -> getSource ( ) ) ) ; $ directorySpecification -> set ( "baseTarget" , $ settings -> getOptional ( "target" , null ) ) ; if ( ! is_dir ( $ directorySpecification -> getSource ( ) ) ) throw new DirectorySpecificationException ( "directory \"{$directorySpecification->getSource()}\" does not exist" ) ; return $ directorySpecification ; }
Creates a directory specification from a plain settings array . The settings context is taken into consideration to generate paths relative to the settings .
9,998
public function getFileSpecifications ( ) { $ fileSpecifications = array ( ) ; foreach ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> getSource ( ) ) ) as $ entry ) if ( ! fphp \ Helper \ Path :: isDot ( $ entry ) ) { $ fileSource = $ entry -> getPathName ( ) ; if ( is_link ( $ fileSource ) ) continue ; $ relativeFileTarget = fphp \ Helper \ Path :: stripBase ( realpath ( $ fileSource ) , realpath ( $ this -> getSource ( ) ) ) ; foreach ( $ this -> getExclude ( ) as $ exclude ) { if ( $ relativeFileTarget === $ exclude ) continue 2 ; $ parts = explode ( "/" , $ exclude ) ; if ( $ parts [ count ( $ parts ) - 1 ] === "*" ) try { fphp \ Helper \ Path :: stripBase ( $ relativeFileTarget , implode ( "/" , array_slice ( $ parts , 0 , count ( $ parts ) - 1 ) ) ) ; continue 2 ; } catch ( fphp \ Helper \ PathException $ e ) { } } $ fileTarget = fphp \ Helper \ Path :: join ( $ this -> get ( "baseTarget" ) , fphp \ Helper \ Path :: join ( $ this -> getTarget ( ) , $ relativeFileTarget ) ) ; $ fileSpecifications [ ] = new FileSpecification ( array ( "source" => $ fileSource , "target" => $ fileTarget ) , $ this -> getDirectory ( ) ) ; } return $ fileSpecifications ; }
Returns the file specifications this directory specification applies to . The entire source directory tree is considered except for excluded files .
9,999
public function getRemoteObject ( $ key , $ interface = null ) { if ( $ interface ) { if ( $ this -> logger !== null && $ this -> logger -> isHandling ( \ Monolog \ Logger :: DEBUG ) ) { $ this -> logger -> addDebug ( 'Create new virtual remote object proxy' , array ( 'interface' => $ interface , 'path' => $ key ) ) ; } return RemoteObjectProxyGenerator :: generate ( $ this , $ interface , $ key ) ; } else { if ( $ this -> logger !== null && $ this -> logger -> isHandling ( \ Monolog \ Logger :: DEBUG ) ) { $ this -> logger -> addDebug ( 'Get remote object proxy' , array ( 'path' => $ key ) ) ; } return new RemoteObjectProxy ( $ this , $ key ) ; } }
Get a named remote object proxy .