idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
23,800
protected function loadView ( $ view , $ values = [ ] ) { if ( isset ( $ this -> application [ $ view ] ) ) { return $ this -> application [ $ view ] ; } $ instance = $ this -> application -> createInstance ( $ view , [ $ values , $ this -> response , $ this -> getHandler ( ) ] ) ; return $ this -> application -> shareInstance ( $ instance , $ view ) ; }
Loads a view from classname ;
23,801
public function accountInformationAction ( ) { $ databaseInfo = $ this -> checkDatabaseInformation ( ) ; if ( $ databaseInfo ) { return $ databaseInfo ; } $ this -> title ( "Admin Account" ) ; return $ this -> render ( "steps/account_information.phtml" ) ; }
Admin account information form .
23,802
public static function fromXml ( \ DOMElement $ xml ) { $ static = new static ( ) ; $ static -> libraryItemMetadata = LibraryItemMetadata :: fromXml ( $ xml ) ; $ static -> renewable = Renewable :: fromXml ( $ xml ) ; $ loanDate = $ xml -> getElementsByTagName ( 'loanDate' ) ; $ static -> loanDate = DateTime :: fromXml ( $ loanDate ) ; $ dueDate = $ xml -> getElementsByTagName ( 'dueDate' ) ; $ static -> dueDate = DateTime :: fromXml ( $ dueDate ) ; $ returnedDate = $ xml -> getElementsByTagName ( 'returnedDate' ) ; $ static -> returnedDate = DateTime :: fromXml ( $ returnedDate ) ; $ stringLiterals = array ( 'pbsCode' => $ xml -> getElementsByTagName ( 'pbsCode' ) , 'itemSequence' => $ xml -> getElementsByTagName ( 'itemSequence' ) , 'material' => $ xml -> getElementsByTagName ( 'material' ) , ) ; foreach ( $ stringLiterals as $ propertyName => $ xmlTag ) { $ static -> $ propertyName = StringLiteral :: fromXml ( $ xmlTag ) ; } return $ static ; }
Builds a Loan object from XML .
23,803
public function & get ( $ key ) { if ( $ this -> has ( $ key ) ) { $ object = $ this -> _registered [ $ key ] ; if ( $ object instanceof Closure ) { $ object = $ this -> set ( call_user_func ( $ object ) , $ key ) ; } return $ object ; } throw new MissingObjectException ( sprintf ( 'Object %s does not exist in the container' , $ key ) ) ; }
Return the object assigned to the given key .
23,804
public static function stringToUrl ( $ string , $ separator = '_' , $ encoding = 'UTF-8' , $ lower = false ) { if ( ! Validate :: isCharset ( $ encoding ) ) throw new \ Exception ( 'Encoding in\'t a valid charset type' ) ; $ string = htmlentities ( html_entity_decode ( $ string , null , $ encoding ) , ENT_NOQUOTES , $ encoding ) ; if ( $ lower ) $ string = strtolower ( $ string ) ; $ search = array ( '#\&(.)(?:uml|circ|tilde|acute|grave|cedil|ring)\;#' , '#\&(.{2})(?:lig)\;#' , '#\&[a-z]+\;#' , '#[^a-zA-Z0-9_]#' , '#' . $ separator . '+#' ) ; $ replace = array ( '\1' , '\1' , '' , $ separator , $ separator ) ; return trim ( preg_replace ( $ search , $ replace , $ string ) , $ separator ) ; }
Convert a string to url format for url rewrite
23,805
public static function parseObjectToArray ( $ object ) { $ array = array ( ) ; if ( is_object ( $ object ) ) $ array = get_object_vars ( $ object ) ; elseif ( is_array ( $ object ) ) { foreach ( $ object as $ k => & $ value ) $ array [ $ k ] = self :: parseObjectToArray ( $ value ) ; } else $ array = $ object ; return $ array ; }
Transforme un object en array
23,806
public static function httpFileExistsWithCurl ( $ url ) { if ( ! extension_loaded ( 'curl' ) ) throw new \ Exception ( 'Curl extension not loaded try change your PHP configuration' ) ; return ( $ ch = curl_init ( $ url ) ) ? @ curl_close ( $ ch ) || true : false ; }
Permet de regarder si un fichier existe depuis une url avec curl
23,807
public static function dirList ( $ dir ) { if ( ! is_dir ( $ dir ) ) throw new \ Exception ( '"' . $ dir . '" is not a valid directory' ) ; $ l = array ( ) ; foreach ( self :: cleanScandir ( $ dir ) as $ f ) { if ( is_dir ( $ dir . $ f ) ) { $ l [ ] = $ dir . $ f . '/' ; $ l = array_merge ( $ l , self :: dirList ( $ dir . $ f . DIRECTORY_SEPARATOR ) ) ; } } return $ l ; }
Permet de lister les repertoires d un dossier
23,808
public static function getIncludeContents ( $ filename , $ param_contents = false ) { if ( ! is_file ( $ filename ) && ! file_exists ( $ filename ) && ! is_readable ( $ filename ) ) throw new \ Exception ( 'Le fichier "' . $ filename . '" n\'existe pas ou est invalid' ) ; if ( $ param_contents ) { for ( $ i = 0 ; $ i < count ( $ param_contents ) ; $ i ++ ) { if ( array_key_exists ( 'param_name' , $ param_contents ) && array_key_exists ( 'param_value' , $ param_contents ) ) $ { $ param_contents [ $ i ] [ 'param_name' ] } = $ param_contents [ $ i ] [ 'param_value' ] ; } } ob_start ( ) ; include $ filename ; $ contents = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ contents ; }
Permet de retourner le contenu d un fichier inclut
23,809
public function addCallableHandle ( ) { if ( $ this -> handler ) { throw new AlreadyBuildedException ( 'The handler already builded.' ) ; } $ loader = new CallableLoader ( ) ; $ resolver = new CallableResolver ( ) ; $ this -> addCallableResolver ( $ resolver ) ; $ this -> addActionLoader ( $ loader ) ; return $ loader ; }
Add closure handle
23,810
public function addCallableResolver ( CallableResolverInterface $ callableResolver ) { if ( $ this -> handler ) { throw new AlreadyBuildedException ( 'The handler already builded.' ) ; } $ this -> callableResolvers [ spl_object_hash ( $ callableResolver ) ] = $ callableResolver ; return $ this ; }
Add callable resolver
23,811
public function addActionLoader ( LoaderInterface $ loader ) { if ( $ this -> handler ) { throw new AlreadyBuildedException ( 'The handler already builded.' ) ; } $ this -> actionLoaders [ spl_object_hash ( $ loader ) ] = $ loader ; return $ this ; }
Add action loader
23,812
public function setEventDispatcher ( EventDispatcherInterface $ eventDispatcher ) { if ( $ this -> handler ) { throw new AlreadyBuildedException ( 'The handler already builded.' ) ; } $ this -> eventDispatcher = $ eventDispatcher ; return $ this ; }
Set event dispatcher
23,813
public function setParameterResolver ( ParameterResolverInterface $ resolver ) { if ( $ this -> handler ) { throw new AlreadyBuildedException ( 'The handler already builded.' ) ; } $ this -> parameterResolver = $ resolver ; return $ this ; }
Set parameter resolver
23,814
public function setParameterExtractor ( ParameterExtractorInterface $ extractor ) { if ( $ this -> handler ) { throw new AlreadyBuildedException ( 'The handler already builded.' ) ; } $ this -> parameterExtractor = $ extractor ; return $ this ; }
Set parameter extractor
23,815
public function with ( callable $ supplier , callable $ accumulator , callable $ finisher = null ) { return $ this -> sequence -> collect ( new Collector ( $ supplier , $ accumulator , $ finisher ) ) ; }
collects all elements into structure defined by supplier
23,816
public function inPartitions ( callable $ predicate , Collector $ base = null ) : array { $ collector = ( null === $ base ) ? Collector :: forList ( ) : $ base ; return $ this -> with ( function ( ) use ( $ collector ) { return [ true => $ collector -> fork ( ) , false => $ collector -> fork ( ) ] ; } , function ( & $ partitions , $ element , $ key ) use ( $ predicate ) { $ partitions [ $ predicate ( $ element ) ] -> accumulate ( $ element , $ key ) ; } , function ( $ partitions ) { return [ true => $ partitions [ true ] -> finish ( ) , false => $ partitions [ false ] -> finish ( ) ] ; } ) ; }
creates collector which groups the elements in two partitions according to given predicate
23,817
public function inGroups ( callable $ classifier , Collector $ base = null ) : array { $ collector = ( null === $ base ) ? Collector :: forList ( ) : $ base ; return $ this -> with ( function ( ) { return [ ] ; } , function ( & $ groups , $ element ) use ( $ classifier , $ collector ) { $ key = $ classifier ( $ element ) ; if ( ! isset ( $ groups [ $ key ] ) ) { $ groups [ $ key ] = $ collector -> fork ( ) ; } $ groups [ $ key ] -> accumulate ( $ element , $ key ) ; } , function ( $ groups ) { foreach ( $ groups as $ key => $ group ) { $ groups [ $ key ] = $ group -> finish ( ) ; } return $ groups ; } ) ; }
creates collector which groups the elements according to given classifier
23,818
public function byJoining ( string $ delimiter = ', ' , string $ prefix = '' , string $ suffix = '' , string $ keySeparator = null ) : string { return $ this -> with ( function ( ) { return null ; } , function ( & $ joinedElements , $ element , $ key ) use ( $ prefix , $ delimiter , $ keySeparator ) { if ( null === $ joinedElements ) { $ joinedElements = $ prefix ; } else { $ joinedElements .= $ delimiter ; } $ joinedElements .= ( null !== $ keySeparator ? $ key . $ keySeparator : null ) . $ element ; } , function ( $ joinedElements ) use ( $ suffix ) { return $ joinedElements . $ suffix ; } ) ; }
creates collector which concatenates all elements into a single string
23,819
function bind ( $ orig , $ b , $ wanted ) { $ result = array ( $ b ) ; foreach ( $ wanted as $ k => $ field ) { if ( isset ( $ orig [ $ field ] ) && strlen ( "" . $ orig [ $ field ] ) ) { $ result [ $ field ] = $ orig [ $ field ] ; } else { $ result [ $ field ] = null ; } } return $ result ; }
get the bound values using null if not defined in the orig
23,820
function id_insert ( $ table , $ query , $ bind_arr = null ) { $ stmt = $ this -> mysqli -> prepare ( $ query ) ; if ( ! $ stmt ) { throw new Exception ( "can't prepare query:[$query] because [" . $ this -> mysqli -> error . "]" ) ; } if ( isset ( $ bind_arr ) && $ bind_arr != null ) { call_user_func_array ( array ( $ stmt , 'bind_param' ) , $ this -> makeValuesReferenced ( $ bind_arr ) ) ; } if ( ! $ stmt -> execute ( ) ) { throw new Exception ( $ this -> mysqli -> error ) ; } if ( ! $ id = $ stmt -> insert_id ) { throw new Exception ( "no id returned for insert $query" ) ; } $ stmt -> close ( ) ; $ rows = $ this -> query ( "select * from $table where id = ?" , array ( "i" , $ id ) ) ; return $ rows [ 0 ] ; }
insert a row of data and return it back
23,821
function id_update ( $ table , $ id , $ query , $ bind_arr = null ) { $ stmt = $ this -> mysqli -> prepare ( $ query ) or die ( "can't prepare query:[$query] because [" . $ this -> mysqli -> error . "]" ) ; if ( isset ( $ bind_arr ) && $ bind_arr != null ) { call_user_func_array ( array ( $ stmt , 'bind_param' ) , $ this -> makeValuesReferenced ( $ bind_arr ) ) ; } $ stmt -> execute ( ) ; $ stmt -> close ( ) ; $ rows = $ this -> query ( "select * from $table where id = ?" , array ( "i" , $ id ) ) ; return $ rows [ 0 ] ; }
update the row having the given id and return back the same row .
23,822
public function editionMode ( ) { if ( isset ( $ _SESSION [ "FINE_MESSAGE_EDITION_MODE" ] ) ) { $ this -> isMessageEditionMode = true ; } $ this -> content -> addFile ( '../utils.i18n.fine/src/views/enableDisableEdition.php' , $ this ) ; $ this -> template -> toHtml ( ) ; }
Admin page used to enable or disable label edition .
23,823
public function setMode ( $ mode ) { $ editMode = ( $ mode == "on" ) ? true : false ; if ( $ editMode ) { $ _SESSION [ "FINE_MESSAGE_EDITION_MODE" ] = true ; $ this -> isMessageEditionMode = true ; } else { unset ( $ _SESSION [ "FINE_MESSAGE_EDITION_MODE" ] ) ; } $ this -> content -> addFile ( '../utils.i18n.fine/src/views/enableDisableEdition.php' , $ this ) ; $ this -> template -> toHtml ( ) ; }
Action used to set the mode of label edition .
23,824
public function addSupportedLanguage ( $ language , $ name = "defaultTranslationService" , $ selfedit = "false" ) { $ this -> addTranslationLanguageFromService ( ( $ selfedit == "true" ) , $ name , $ language ) ; $ this -> supportedLanguages ( $ name , $ selfedit ) ; }
Adds a language to the list of supported languages
23,825
public function searchLabel ( $ msginstancename = "defaultTranslationService" , $ selfedit = "false" , $ search , $ language_search = null ) { $ this -> msgInstanceName = $ msginstancename ; $ this -> selfedit = $ selfedit ; $ array = $ this -> getAllMessagesFromService ( ( $ selfedit == "true" ) , $ msginstancename , $ language_search ) ; $ this -> languages = $ array [ "languages" ] ; $ this -> search = $ search ; $ this -> language_search = $ language_search ; if ( $ search ) { $ this -> msgs = $ array [ "msgs" ] ; $ regex = $ this -> stripRegexMetaChars ( $ this -> stripAccents ( $ search ) ) ; $ this -> results = $ this -> regex_search_array ( $ array [ "msgs" ] , $ regex ) ; $ this -> error = false ; } else $ this -> error = true ; $ webLibriary = new WebLibrary ( array ( ) , array ( '../utils.i18n.fine/src/views/css/style.css' ) ) ; $ this -> template -> getWebLibraryManager ( ) -> addLibrary ( $ webLibriary ) ; $ this -> content -> addFile ( '../utils.i18n.fine/src/views/searchLabel.php' , $ this ) ; $ this -> template -> toHtml ( ) ; }
Search All label with the value
23,826
protected static function setTranslationsForMessageFromService ( $ selfEdit , $ msgInstanceName , $ language , $ translations ) { $ translationService = new InstanceProxy ( $ msgInstanceName , $ selfEdit ) ; return $ translationService -> setMessages ( $ translations , $ language ) ; }
Saves many translations for one key and one language using CURL .
23,827
private function regex_search_array ( $ array , $ regex ) { $ return = array ( ) ; foreach ( $ array as $ key => $ item ) { if ( is_array ( $ item ) ) { $ tmp = $ this -> regex_search_array ( $ item , $ regex ) ; if ( $ tmp ) $ return [ $ key ] = $ tmp ; } elseif ( ! is_object ( $ item ) ) { if ( preg_match ( "/" . $ regex . "/i" , $ this -> stripAccents ( $ item ) ) ) { $ return [ $ key ] = $ item ; } } } return $ return ; }
Search the regex in all the array . Return an array with all result
23,828
public function toSum ( callable $ summer = null ) { if ( null === $ summer ) { $ summer = function ( $ sum , $ element ) { return $ sum += $ element ; } ; } return $ this -> with ( $ summer , 0 ) ; }
reduce to sum of all elements
23,829
public function toMin ( callable $ min = null ) { if ( null === $ min ) { $ min = function ( $ smallest , $ element ) { return ( null === $ smallest || $ element < $ smallest ) ? $ element : $ smallest ; } ; } return $ this -> with ( $ min ) ; }
reduce to smallest element
23,830
public function setWorkingDirectory ( $ workingDirectory ) { if ( ( null !== $ workingDirectory ) && ! is_dir ( $ workingDirectory ) ) { throw new InvalidArgumentException ( 'The working directory must exist.' ) ; } $ this -> workingDirectory = $ workingDirectory ; return $ this ; }
Sets the working directory .
23,831
public function generate ( ) { $ options = $ this -> options ; $ arguments = array_merge ( [ $ this -> binary ] , ( array ) $ this -> arguments ) ; $ script = implode ( ' ' , array_map ( [ ProcessUtils :: class , 'escapeArgument' ] , $ arguments ) ) ; $ process = new Process ( $ this -> applyForceToBackground ( $ script ) , $ this -> workingDirectory , $ this -> getEnvironmentVariables ( ) , $ this -> input , $ this -> timeout , $ options ) ; if ( $ this -> outputDisabled ) { $ process -> disableOutput ( ) ; } return $ process ; }
Generate the process .
23,832
private function getEnvironmentVariables ( ) { $ variables = $ this -> inheritEnvironment ? array_replace ( $ _ENV , $ _SERVER , $ this -> environment ) : $ this -> environment ; foreach ( array_keys ( $ variables ) as $ name ) { if ( false !== ( $ value = getenv ( $ name ) ) ) { $ variables [ $ name ] = $ value ; } } return $ variables ; }
Retrieve the passed environment variables from the current session and return them .
23,833
public function register ( ) { $ app = $ this -> app ; if ( true === $ this -> app [ 'config' ] -> get ( 'database.autostart' ) ) { $ configs = Config :: get ( 'database' ) ; $ connection = $ configs [ 'connection' ] ; $ connectionConfigs = Arr :: get ( $ configs [ 'connections' ] , $ connection , [ ] ) ; Query :: configs ( $ connectionConfigs ) ; $ this -> singleton ( 'database.base' , function ( ) { return new Database ( ) ; } ) ; $ this -> singleton ( Base :: class , function ( ) { return App :: make ( 'database.base' ) ; } ) ; } }
register the database base
23,834
public static function getQuery ( string $ p_type = \ FreeFW \ Model \ Query :: QUERY_SELECT ) { $ cls = get_called_class ( ) ; $ cls = rtrim ( ltrim ( $ cls , '\\' ) , '\\' ) ; $ query = \ FreeFW \ DI \ DI :: get ( 'FreeFW::Model::Query' ) ; $ query -> setType ( $ p_type ) -> setMainModel ( str_replace ( '\\' , '::' , $ cls ) ) ; return $ query ; }
Get new Query Model
23,835
public function dispatchMatch ( MatchContextInterface $ match ) { $ request = $ this -> url -> getRequestContext ( ) ; $ this -> url -> setRequestContext ( $ match -> getRequest ( ) ) ; $ this -> routeStack -> push ( $ match -> getName ( ) ) ; $ response = $ this -> mapper -> mapResponse ( $ this -> dispatcher -> dispatch ( $ match ) ) ; $ this -> routeStack -> pop ( ) ; if ( null !== $ request ) { $ this -> url -> setRequestContext ( $ request ) ; } return $ response ; }
Dispatches a request .
23,836
protected function registerComment ( ) { $ this -> app -> singleton ( 'jlourenco.comments.comment' , function ( $ app ) { $ baseConfig = $ app [ 'config' ] -> get ( 'jlourenco.base' ) ; $ config = $ app [ 'config' ] -> get ( 'jlourenco.comments' ) ; $ model = array_get ( $ config , 'models.comment' ) ; $ users = array_get ( $ baseConfig , 'models.User' ) ; if ( class_exists ( $ model ) && method_exists ( $ model , 'setUsersModel' ) ) forward_static_call_array ( [ $ model , 'setUsersModel' ] , [ $ users ] ) ; return new CommentRepository ( $ model ) ; } ) ; }
Registers the blog posts .
23,837
protected function registerComments ( ) { $ this -> app -> singleton ( 'comments' , function ( $ app ) { $ blog = new Comments ( $ app [ 'jlourenco.comments.comment' ] ) ; return $ blog ; } ) ; $ this -> app -> alias ( 'comments' , 'jlourenco\comments\Comments' ) ; }
Registers log .
23,838
public function dispatchNotFound ( ) { if ( isset ( $ this -> notFoundHandler ) ) { $ notFoundHandler = $ this -> notFoundHandler ; $ controllerName = implode ( '\\' , [ $ this -> baseNamespace , $ this -> controllerName , $ notFoundHandler [ 'controler' ] ] ) ; $ controllerInstance = new $ controllerName ( ) ; return call_user_func ( [ $ controllerInstance , $ this -> actionName . $ notFoundHandler [ 'action' ] ] ) ; } return null ; }
Called if any of route did not match the request .
23,839
private function transformHandler ( $ matches , $ parameters , $ handler ) { $ transformed = [ ] ; foreach ( $ handler as $ target => $ placeholder ) { foreach ( $ parameters as $ key => $ parameterName ) { if ( $ parameterName [ 0 ] [ 0 ] == $ placeholder ) { if ( $ target == 'controler' ) { $ transformed [ $ target ] = $ matches [ $ key ] . 'Controler' ; } else { $ transformed [ $ target ] = $ matches [ $ key ] ; } } } } return $ transformed ; }
Transform provided handler with variables and parameters
23,840
private function resolveNamespace ( $ parameters , $ handler , $ matches ) { if ( isset ( $ handler [ 'module' ] ) ) { $ moduleName = $ handler [ 'module' ] ; if ( $ this -> isPlaceholder ( $ moduleName ) ) { foreach ( $ handler as $ target => $ placeholder ) { foreach ( $ parameters as $ key => $ parameterName ) { if ( $ parameterName [ 0 ] [ 0 ] == $ placeholder ) { if ( $ target == 'module' ) { $ moduleName = $ matches [ $ key ] ; } } } } } return implode ( '\\' , [ $ this -> baseNamespace , $ this -> moduleName , $ moduleName , $ this -> controllerName ] ) ; } return $ this -> baseNamespace . '\\' . $ this -> controllerName ; }
Resolve proper namespace according parameters handler and matches
23,841
private function isPlaceholder ( string $ value ) : bool { if ( strrchr ( $ value , '}' ) && ( 0 === strpos ( $ value , '{' ) ) ) { return true ; } return false ; }
Check if the variable is placeholder
23,842
private function getFunctionArgumentsControlers ( $ paramMap , $ matches , $ parameters , $ handlers ) { $ output = [ ] ; $ matches = array_values ( $ matches ) ; if ( isset ( $ parameters ) ) { foreach ( $ handlers as $ placeholder ) { if ( $ this -> isPlaceholder ( $ placeholder ) ) { foreach ( $ parameters as $ key => $ parameterName ) { if ( $ parameterName [ 0 ] [ 0 ] == $ placeholder ) { unset ( $ parameters [ $ key ] ) ; unset ( $ matches [ $ key ] ) ; } } } } $ parameters = array_values ( $ parameters ) ; $ matches = array_values ( $ matches ) ; foreach ( $ parameters as $ key => $ valueName ) { foreach ( $ paramMap as $ possition => $ value ) { if ( $ value == $ valueName [ 1 ] [ 0 ] ) { $ output [ ] = $ matches [ $ possition ] ; } } } } return $ output ; }
Get function arguments for controler
23,843
private function getMethodParameters ( string $ class , string $ methodName ) : array { $ methodReflection = new ReflectionMethod ( $ class , $ methodName ) ; $ parametersName = [ ] ; foreach ( $ methodReflection -> getParameters ( ) as $ parameter ) { $ parametersName [ ] = $ parameter -> name ; } return $ parametersName ; }
Get names of parameters for provided class and method
23,844
public function setDMS ( $ string ) { $ string = preg_replace ( "/[^a-zA-Z0-9,.\s]/" , ' ' , trim ( $ string ) ) ; $ string = str_replace ( array ( 'S' , 'N' , 'E' , 'W' ) , array ( ' S' , ' N' , ' E' , ' W' ) , strtoupper ( $ string ) ) ; $ string = preg_replace ( '/\s+/' , ' ' , $ string ) ; $ this -> dms = explode ( ' ' , $ string ) ; }
Clean input DMS and set as array .
23,845
public function withProxySettings ( $ proxySettings ) { if ( ! empty ( $ proxySettings ) ) { $ this -> extraCapabilities [ WebDriverCapabilityType :: PROXY ] = [ 'proxyType' => $ proxySettings [ 'proxyType' ] , 'httpProxy' => $ proxySettings [ 'httpProxy' ] , 'sslProxy' => $ proxySettings [ 'sslProxy' ] , ] ; } return $ this ; }
Sets the given proxy settings and returns self .
23,846
public function build ( ) { $ capabilities = $ this -> makeCapabilities ( $ this -> type , $ this -> extraCapabilities ) ; $ this -> remoteWebDriver = RemoteWebDriver :: create ( $ this -> url , $ capabilities , $ this -> connectionTimeout , $ this -> requestTimeout ) ; if ( $ this -> implicitTimeout > 0 ) { $ this -> remoteWebDriver -> manage ( ) -> timeouts ( ) -> implicitlyWait ( $ this -> implicitTimeout ) ; } $ baseUrlId = UrlTranslator :: BASE_URL_IDENTIFIER ; $ baseUrl = array_key_exists ( $ baseUrlId , $ this -> urls ) ? $ this -> urls [ $ baseUrlId ] : null ; $ this -> urlTranslator = new UrlTranslator ( $ this -> urls , $ baseUrl ) ; return $ this ; }
Builds a Facebook RemoteWebDriver .
23,847
public function impersonateAccount ( \ TYPO3 \ Flow \ Security \ Account $ account = NULL ) { if ( $ this -> impersonatedAccount !== $ account ) { $ this -> impersonatedAccount = $ account ; $ this -> destroyRegisteredClientSessions ( ) ; $ this -> emitAccountImpersonated ( $ account ) ; } }
Impersonate another account
23,848
private function handleForConsole ( Exception $ e ) { if ( $ e instanceof StopException ) { $ output = $ e -> getMessage ( ) ; } else { $ data = $ this -> convertException ( $ e ) ; $ class = get_class ( $ e ) ; $ file = $ this -> stripFile ( $ data [ 'file' ] ) ; $ line = $ data [ 'line' ] ; $ code = $ data [ 'code' ] ; if ( $ e instanceof HttpException ) { $ message = http_status_text ( $ data [ 'status' ] ) . ' (' . $ data [ 'status' ] . ')' ; if ( ! empty ( $ data [ 'message' ] ) ) { $ message .= '. ' . $ data [ 'message' ] ; } } else if ( $ e instanceof QueryException ) { $ message = $ data [ 'message' ] . '; sql: ' . $ data [ 'sql' ] ; } else { $ message = $ data [ 'message' ] ; } $ output = $ class . ' in "' . $ file . '", line ' . $ line . ':' . PHP_EOL . $ message . ' (code ' . $ code . ')' ; } stdio ( ) -> error ( $ output ) ; $ exitCode = $ e -> getCode ( ) ; if ( $ exitCode === null ) { $ exitCode = Command :: EXIT_FAILURE ; } exit ( $ exitCode ) ; }
Write a error message to the console and exit the script .
23,849
private function handleForBrowser ( Exception $ e ) { $ data = $ this -> convertException ( $ e ) ; if ( $ e instanceof HttpException ) { $ data [ 'title' ] = http_status_text ( $ data [ 'status' ] ) ; $ data [ 'subtitle' ] = get_class ( $ e ) . ', Status Code ' . $ data [ 'status' ] ; } else if ( $ e instanceof QueryException ) { $ data [ 'title' ] = 'SQL Error' ; $ data [ 'subtitle' ] = get_class ( $ e ) . ' (Exception code: ' . $ data [ 'code' ] . ')' ; if ( $ data [ 'ansiCode' ] !== null ) { $ data [ 'subtitle' ] .= ', ANSI SQLSTATE Error Code: ' . $ data [ 'ansiCode' ] ; } if ( $ data [ 'driverCode' ] !== null ) { $ data [ 'subtitle' ] .= ', Driver-specific Error Code: ' . $ data [ 'driverCode' ] ; } } else { $ data [ 'title' ] = 'Error' ; $ data [ 'subtitle' ] = get_class ( $ e ) . ' (Exception code: ' . $ data [ 'code' ] . ')' ; } if ( $ e instanceof QueryException ) { if ( preg_match ( '/at line (\d)$/' , $ data [ 'message' ] , $ match ) ) { $ sqlLine = $ match [ 1 ] ; } else { $ sqlLine = 0 ; } $ data [ 'source' ] = $ this -> renderSQL ( $ data [ 'sql' ] , $ sqlLine ) ; } else { $ data [ 'source' ] = $ this -> renderPHP ( $ data [ 'file' ] , $ data [ 'line' ] ) ; } $ data [ 'trace' ] = $ this -> renderTrace ( $ data [ 'trace' ] ) ; $ data [ 'file' ] = $ this -> stripFile ( $ data [ 'file' ] ) ; $ view = config ( 'app.debug' ) ? 'errors.debug' : 'errors.default' ; if ( ! config ( 'app.debug' ) && view ( ) -> exists ( 'errors.' . $ data [ 'status' ] ) ) { $ view = 'errors.' . $ data [ 'status' ] ; } $ headers = ( $ e instanceof HttpException ) ? $ e -> getHeaders ( ) : [ ] ; return response ( ) -> view ( $ view , $ data , $ data [ 'status' ] , $ headers ) -> send ( ) ; }
Send a error message as a HTTP response .
23,850
private function convertException ( Exception $ e ) { $ data = [ ] ; $ data [ 'message' ] = $ e -> getMessage ( ) ; $ data [ 'code' ] = $ e -> getCode ( ) ; $ data [ 'trace' ] = $ this -> filterTrace ( $ e -> getTrace ( ) ) ; $ data [ 'status' ] = Response :: HTTP_INTERNAL_SERVER_ERROR ; $ firstTraceEntry = ! empty ( $ data [ 'trace' ] ) ? reset ( $ data [ 'trace' ] ) : null ; if ( $ firstTraceEntry !== null && isset ( $ firstTraceEntry [ 'file' ] ) && isset ( $ firstTraceEntry [ 'line' ] ) ) { $ data [ 'file' ] = $ firstTraceEntry [ 'file' ] ; $ data [ 'line' ] = $ firstTraceEntry [ 'line' ] ; } else { $ data [ 'file' ] = $ e -> getFile ( ) ; $ data [ 'line' ] = $ e -> getLine ( ) ; } if ( $ e instanceof HttpException ) { $ data [ 'status' ] = $ e -> getStatusCode ( ) ? : Response :: HTTP_INTERNAL_SERVER_ERROR ; } else if ( $ e instanceof QueryException ) { $ data [ 'ansiCode' ] = isset ( $ e -> errorInfo [ 0 ] ) ? $ e -> errorInfo [ 0 ] : null ; $ data [ 'driverCode' ] = isset ( $ e -> errorInfo [ 1 ] ) ? $ e -> errorInfo [ 1 ] : null ; if ( ! empty ( $ e -> errorInfo [ 2 ] ) ) { $ data [ 'message' ] = $ e -> errorInfo [ 2 ] ; } $ data [ 'sql' ] = $ e -> getDump ( ) ; } return $ data ; }
Convert a Exception to a simple array .
23,851
private function renderSQL ( $ sql , $ line ) { try { $ sql = trim ( $ sql ) ; $ count = count ( explode ( PHP_EOL , $ sql ) ) ; $ code = '<code>' . SqlFormatter :: highlight ( $ sql ) . '</code>' ; return $ this -> wrapLineNumbers ( $ count , $ code , $ line ) ; } catch ( Throwable $ e ) { return null ; } catch ( Exception $ e ) { return null ; } }
Render SQL .
23,852
private function wrapLineNumbers ( $ count , $ code , $ line ) { $ length = max ( strlen ( $ count ) , 2 ) ; $ numbers = [ ] ; for ( $ number = 1 ; $ number <= $ count ; $ number ++ ) { $ numbers [ ] = str_pad ( $ number , $ length , '0' , STR_PAD_LEFT ) ; } if ( $ line > 0 ) { $ numbers [ $ line - 1 ] = '<span class="errorline">' . $ numbers [ $ line - 1 ] . '</span>' ; } $ numbers = implode ( '<br/>' , $ numbers ) . '<br/>' ; return '<table class="code"><tr>' . '<td><code>' . $ numbers . '</code></td>' . '<td>' . $ code . '</td>' . '</tr></table>' ; }
Render code with line numbers
23,853
private function filterTrace ( $ trace ) { $ ignore = 'app/Services/Database.php' ; $ j = strlen ( $ ignore ) ; foreach ( $ trace as $ i => $ entry ) { if ( isset ( $ entry [ 'file' ] ) ) { $ s = $ this -> stripFile ( $ entry [ 'file' ] ) ; if ( substr ( $ s , 0 , $ j ) == $ ignore ) { unset ( $ trace [ $ i ] ) ; } } } return $ trace ; }
Filter Trace to relevant entries
23,854
private function dumpArgs ( $ args ) { foreach ( $ args as $ key => $ arg ) { if ( is_object ( $ arg ) ) { $ v = '{' . get_class ( $ arg ) . '}' ; } else if ( is_array ( $ arg ) ) { $ v = '[' . $ this -> dumpArgs ( $ arg ) . ']' ; } else if ( is_string ( $ arg ) ) { $ v = '"' . ( strlen ( $ arg ) <= 16 ? $ arg : trim ( substr ( $ arg , 0 , 15 ) ) . '...' ) . '"' ; } else if ( is_bool ( $ arg ) ) { $ v = $ arg ? 'true' : 'false' ; } else if ( $ arg === null ) { $ v = 'null' ; } else { $ v = $ arg ; } $ args [ $ key ] = is_string ( $ key ) ? '"' . $ key . '" => ' . $ v : $ v ; } return implode ( ', ' , $ args ) ; }
Render the arguments of a function .
23,855
public static function toString ( $ value ) : string { if ( $ value === null ) { return 'NULL' ; } if ( $ value === true ) { return 'TRUE' ; } if ( $ value === false ) { return 'FALSE' ; } if ( is_object ( $ value ) ) { return static :: readObject ( $ value ) ; } if ( is_array ( $ value ) ) { return static :: readArray ( $ value ) ; } if ( is_resource ( $ value ) ) { return static :: readResource ( $ value ) ; } return ( string ) $ value ; }
Reads a string representation from a value
23,856
protected static function readObject ( $ object ) : string { if ( $ object instanceof Closure ) { return 'Function' ; } if ( $ object instanceof DateTime ) { return sprintf ( 'DateTime(%s)' , $ object -> format ( 'Y-m-d\TH:i:sP' ) ) ; } if ( method_exists ( $ object , 'toString' ) ) { return ( string ) $ object -> toString ( ) ; } if ( method_exists ( $ object , '__toString' ) ) { return ( string ) $ object ; } return sprintf ( 'Object(%s)' , get_class ( $ object ) ) ; }
Reads a string representation from an object
23,857
protected static function readArray ( array $ array ) : string { $ data = [ ] ; foreach ( $ array as $ key => $ value ) { $ data [ ] = sprintf ( '%s => %s' , $ key , static :: toString ( $ value ) ) ; } return sprintf ( 'Array(%s)' , implode ( ', ' , $ data ) ) ; }
Reads a string representation from an array
23,858
public static function print_html ( ) { echo ( '<div class="debuginfo">' ) ; echo ( '<p><b>Debug information:</b></p>' ) ; foreach ( self :: $ strings as $ msg ) { $ style = '' ; switch ( $ msg -> level ) { case LL_GENERAL : case LL_DEBUG : case LL_INFO : $ style = '' ; break ; case LL_WARNING : case LL_ERROR : $ style = 'color: red;' ; break ; } echo ( '<p style="' . $ style . '">' ) ; if ( self :: $ memprof ) { echo ( '(<span class="time">' . sprintf ( '%.7f' , $ msg -> time ) . '</span> : ' ) ; echo ( '<span class="mem" title="' . $ msg -> mem . ' bytes">' . sprintf ( '%.2f Mb' , ( $ msg -> mem / 1048576 ) ) . ')</span> - ' ) ; } else { echo ( '<span class="time">(' . sprintf ( '%.7f' , $ msg -> time ) . ')</span> - ' ) ; } echo ( htmlspecialchars ( $ msg -> text ) ) ; echo ( '</p>' ) ; } echo ( '</div>' ) ; }
Print HTML log .
23,859
public function dequeue ( $ platform = null ) { if ( null === $ platform ) { return array_shift ( $ this -> queue ) ; } reset ( $ this -> queue ) ; do { $ index = key ( $ this -> queue ) ; $ method = current ( $ this -> queue ) ; next ( $ this -> queue ) ; } while ( $ method instanceof MethodInterface && ! $ method -> supports ( $ platform ) ) ; if ( null !== $ index ) { unset ( $ this -> queue [ $ index ] ) ; } if ( false === $ method ) { $ method = null ; } return $ method ; }
Removes the method at the beginning of the queue . You can optionally filter to dequeue a specific platform method .
23,860
protected function moveDown ( $ id ) { $ model = $ this -> getModel ( $ id ) ; $ orderAttrName = $ this -> positionAttribute ; $ orderDir = SORT_ASC ; $ swapModel = $ model :: find ( ) -> where ( [ '>' , $ orderAttrName , $ model -> $ orderAttrName ] ) -> orderBy ( [ $ orderAttrName => $ orderDir ] ) -> one ( ) ; if ( $ swapModel ) { $ newOrderNumeric = $ swapModel -> $ orderAttrName ; $ swapModel -> $ orderAttrName = $ model -> $ orderAttrName ; $ model -> $ orderAttrName = $ newOrderNumeric ; $ swapModel -> save ( ) && $ model -> save ( ) ; } return $ this -> redirect ( $ model ) ; }
Move model to down
23,861
protected function moveUp ( $ id ) { $ model = $ this -> getModel ( $ id ) ; $ orderAttrName = $ this -> positionAttribute ; $ orderDir = SORT_DESC ; $ swapModel = $ model :: find ( ) -> where ( [ '<' , $ orderAttrName , $ model -> $ orderAttrName ] ) -> orderBy ( [ $ orderAttrName => $ orderDir ] ) -> one ( ) ; if ( $ swapModel ) { $ newOrderNumeric = $ swapModel -> $ orderAttrName ; $ swapModel -> $ orderAttrName = $ model -> $ orderAttrName ; $ model -> $ orderAttrName = $ newOrderNumeric ; $ swapModel -> save ( ) && $ model -> save ( ) ; } return $ this -> redirect ( $ model ) ; }
Move model to up
23,862
public function onFinish ( MvcEvent $ event ) { $ connection = $ this -> getObjectManager ( ) -> getConnection ( ) ; if ( $ connection -> isTransactionActive ( ) ) { $ connection -> commit ( ) ; } }
Listen to the finish event and attempt to commit a transaction
23,863
public function setupAreaLocTaxonomy ( array & $ form , FormStateInterface $ formState ) { $ limit_arealocs = $ formState -> getValue ( 'attribute_code_limit' ) ? : NULL ; $ new_arr = [ ] ; if ( isset ( $ limit_arealocs ) ) { $ new_arr = array_map ( 'trim' , explode ( ',' , $ limit_arealocs ) ) ? : [ ] ; } $ locData = $ this -> propertyMethods -> getAreaLocationDataFromTabs ( $ new_arr ) ; $ arealocDataUpdateStatus = $ this -> propertyMethods -> createAreaLocTermsFromTabs ( $ locData ) ; drupal_set_message ( print_r ( 'Updated Areas: ' . $ arealocDataUpdateStatus [ 0 ] , TRUE ) ) ; drupal_set_message ( print_r ( 'Updated Locations: ' . $ arealocDataUpdateStatus [ 1 ] , TRUE ) ) ; }
Runs the necessary methods in the property service to setup the taxonomy .
23,864
public function loadPropertyBatchAll ( array & $ form , FormStateInterface $ formState ) { $ batch_size = $ formState -> getValue ( 'batch_size' ) ? : 6 ; $ modify_replace = $ formState -> getValue ( 'modify_replace_batch' ) ? : 0 ; NT8PropertyBatch :: propertyBatchLoad ( $ batch_size , $ modify_replace ) ; }
Initiates a batch method to load all properties .
23,865
public function createUmbrellaFile ( UploadedFile $ file , $ upload = false ) { $ umbrellaFile = new UmbrellaFile ( ) ; $ umbrellaFile -> name = $ file -> getClientOriginalName ( ) ; $ umbrellaFile -> md5 = md5_file ( $ file -> getRealPath ( ) ) ; $ umbrellaFile -> mimeType = $ file -> getMimeType ( ) ; $ umbrellaFile -> size = $ file -> getSize ( ) ; if ( $ upload ) { $ umbrellaFile -> path = $ this -> upload ( $ file ) ; } else { $ umbrellaFile -> file = $ file ; } return $ umbrellaFile ; }
Create Umbrella file from UploadedFile If upload set to true = > process upload else upload will be processed on postPersist
23,866
public static function assertObjectIsA ( $ object , string $ type , Throwable $ exception ) { static :: makeAssertion ( \ is_a ( $ object , $ type ) , $ exception ) ; return $ object ; }
Asserts that the given object is an instance of the given type .
23,867
public static function assertPropertiesInCascade ( $ object , Throwable $ exception , string ... $ propertiesInCascade ) { foreach ( $ propertiesInCascade as $ property ) { static :: makeAssertion ( \ property_exists ( $ object , $ property ) , $ exception ) ; $ object = $ object -> { $ property } ; } return $ object ; }
Asserts that a list of properties exist in cascade from an original object .
23,868
private static function parseParams ( array $ arguments ) : string { if ( 0 === count ( $ arguments ) ) { return '' ; } $ arguments = array_map ( function ( $ argument ) { return beautify_parse ( '<argument:argument>' , [ 'argument' => sprintf ( '"%s"' , $ argument ) , ] ) ; } , $ arguments ) ; $ parameters = implode ( ', ' , $ arguments ) ; return sprintf ( '(%s)' , $ parameters ) ; }
Convierte los argumentos en una cadena de texto
23,869
public function changeState ( $ name ) { $ this -> state = $ name ; $ this -> history [ ] = $ name ; $ this -> hasChanged = true ; }
Set new state to subject
23,870
public function always ( callable $ onFulfilledOrRejected ) { return $ this -> then ( function ( $ value ) use ( $ onFulfilledOrRejected ) { return resolve ( $ onFulfilledOrRejected ( $ this -> sharedData ) ) -> then ( function ( ) use ( $ value ) { return $ value ; } ) ; } , function ( $ reason ) use ( $ onFulfilledOrRejected ) { return resolve ( $ onFulfilledOrRejected ( $ this -> sharedData ) ) -> then ( function ( ) use ( $ reason ) { return new RejectedPromiseWithSD ( $ reason , $ this -> sharedData ) ; } ) ; } ) ; }
Always callable after resolving or rejecting
23,871
protected function resolver ( callable $ onFulfilled = null , callable $ onRejected = null , callable $ onProgress = null ) { return function ( $ resolve , $ reject , $ notify ) use ( $ onFulfilled , $ onRejected , $ onProgress ) { if ( $ onProgress ) { $ progressHandler = function ( $ update ) use ( $ notify , $ onProgress ) { try { $ notify ( $ onProgress ( $ update ) , $ this -> sharedData ) ; } catch ( \ Throwable $ e ) { $ notify ( $ e , $ this -> sharedData ) ; } } ; } else { $ progressHandler = $ notify ; } $ this -> handlers [ ] = function ( ExtendedPromiseInterface $ promise ) use ( $ onFulfilled , $ onRejected , $ resolve , $ reject , $ progressHandler ) { $ promise -> then ( $ onFulfilled , $ onRejected ) -> done ( $ resolve , $ reject , $ progressHandler ) ; } ; $ this -> progressHandlers [ ] = $ progressHandler ; } ; }
Promise resolver callback generator
23,872
protected static function resolveFunction ( self & $ target ) { return function ( $ value = null ) use ( & $ target ) { if ( $ target !== null ) { $ target -> settle ( resolve ( $ value , $ target -> sharedData ) ) ; $ target = null ; } } ; }
Creates a static resolver callback that is not bound to a promise instance .
23,873
public function execute ( Input $ input ) : Input { if ( ! $ input -> isEvaluableForTypes ( ... $ this -> types ) ) { return $ input ; } return $ this -> resolve ( $ input ) ; }
Manipula un input
23,874
public function addRecipient ( $ name , $ email , $ amount ) { $ this -> recipients -> addRecipient ( $ name , $ email , $ amount ) ; return $ this ; }
Este metodo se encarga de adjuntar un destinatario al objeto .
23,875
public function run ( CliCommandOptions $ options = null ) { $ options = $ this -> getOptions ( $ options ) ; $ command = $ this -> buildCommand ( $ options ) ; $ startTime = microtime ( true ) ; $ response = $ this -> executor -> execute ( $ command , $ options -> getCwd ( ) , $ options -> getEnv ( ) ) ; $ elapsedTime = microtime ( true ) - $ startTime ; $ output = $ response -> getOutput ( ) ; $ returnCode = $ response -> getReturnCode ( ) ; return new CliCommandResponse ( [ 'command' => $ command , 'elapsed_time' => $ elapsedTime , 'output' => $ output , 'start_time' => $ startTime , 'return_code' => $ returnCode , 'successful' => $ returnCode === 0 , ] ) ; }
Executes a cli command
23,876
protected static function getDbConfig ( ) { static $ config = null ; if ( ! $ config ) { $ config = Container :: getConfig ( ) -> getConfig ( 'db' ) ; if ( ! is_array ( $ config ) ) { throw new ArchException ( 'Key db must be declared in application configuration' ) ; } } return $ config ; }
Configuration de la db dans la configuration de l application
23,877
public function createIfNecessary ( QueueBindings $ queueBindings ) { $ addresses = array_merge ( $ queueBindings -> getReceivingAddresses ( ) , $ queueBindings -> getSendingAddresses ( ) ) ; foreach ( $ addresses as $ address ) { $ this -> routingTopology -> setupForEndpointUse ( $ this -> brokerModel , $ address ) ; } }
Creates message queues for the defined queue bindings .
23,878
public function extract ( $ parts = null ) { if ( $ this -> isEmpty ( ) ) { return false ; } if ( $ parts === null ) { return $ this -> content ; } if ( is_array ( $ parts ) ) { $ result = array ( ) ; foreach ( $ parts as $ key ) { if ( isset ( $ this -> content [ $ key ] ) ) { $ result [ $ key ] = $ this -> content [ $ key ] ; } } return $ result ; } return isset ( $ this -> content [ $ parts ] ) ? $ this -> content [ $ parts ] : false ; }
Extract result parts of current query .
23,879
public function find ( $ re , $ filter = null ) { if ( $ this -> isEmpty ( ) ) { return self :: getEmptyContext ( ) ; } $ result = null ; if ( $ filter ) { $ this -> findAll ( $ re ) -> each ( function ( $ context ) use ( $ filter , & $ result ) { if ( $ filter ( $ context ) ) { $ result = $ context ; return false ; } } ) ; return $ result ? : self :: getEmptyContext ( ) ; } if ( ! preg_match ( $ re , $ this -> toString ( ) , $ match ) ) { return self :: getEmptyContext ( ) ; } return new self ( $ match ) ; }
Find with regexp in current context
23,880
public function findAll ( $ re , $ filter = null ) { if ( $ this -> isEmpty ( ) ) { return self :: getEmptyContext ( ) ; } if ( ! preg_match_all ( $ re , $ this -> toString ( ) , $ matches , PREG_SET_ORDER ) ) { $ matches = array ( ) ; } $ result = array ( ) ; foreach ( $ matches as $ match ) { $ context = new self ( $ match ) ; if ( ! $ filter || $ filter ( $ context ) ) { $ result [ ] = $ match ; } } return new ContextCollection ( $ result ) ; }
Find all matching data in the context .
23,881
public static function addToQueue ( $ path , $ type ) { if ( $ type != self :: TYPE_DIR && $ type != self :: TYPE_FILE ) { throw new \ Exception ( sprintf ( 'Invalid $type parameter "%s"' , $ type ) ) ; } self :: $ cleanupQueue [ ] = [ 'path' => $ path , 'type' => $ type ] ; }
Add a file or a folder to the cleanup queue .
23,882
public static function doCleanup ( ) { Service :: $ log -> msg ( 'Cleanup started' ) ; foreach ( self :: $ cleanupQueue as $ cq ) { Service :: $ log -> msg ( sprintf ( 'Removing %s %s' , $ cq [ 'type' ] , $ cq [ 'path' ] ) ) ; if ( strpos ( $ cq [ 'path' ] , self :: $ tempFolder ) !== 0 ) { throw new \ Exception ( sprintf ( 'Path "%s" is not within the defined temp folder location "%s".' , $ cq [ 'path' ] , self :: $ tempFolder ) ) ; } if ( $ cq [ 'type' ] == self :: TYPE_DIR ) { system ( 'rm -rf ' . $ cq [ 'path' ] ) ; } if ( $ cq [ 'type' ] == self :: TYPE_FILE ) { system ( 'rm ' . $ cq [ 'path' ] ) ; } } Service :: $ log -> msg ( 'Cleanup ended' ) ; }
Method that does the actual cleanup .
23,883
public function setIdPrefix ( string $ prefix = null ) { foreach ( ( array ) $ this as $ element ) { if ( is_object ( $ element ) ) { $ element -> setIdPrefix ( $ prefix ) ; } } }
Sets the ID prefix for this group . The ID prefix is optionally prefixed to all generated IDs to resolve ambiguity .
23,884
public function valueSuppliedByUser ( bool $ status = null ) : bool { $ is = false ; foreach ( ( array ) $ this as $ field ) { if ( is_string ( $ field ) ) { continue ; } if ( isset ( $ status ) ) { $ field -> getElement ( ) -> valueSuppliedByUser ( $ status ) ; } if ( $ field -> getElement ( ) -> valueSuppliedByUser ( ) ) { $ is = true ; } } return $ is ; }
Mark the entire group as set by the user .
23,885
protected function _setTransitioner ( $ transitioner ) { if ( $ transitioner !== null && ! ( $ transitioner instanceof TransitionerInterface ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Argument is not a valid booking transitioner' ) , null , null , $ transitioner ) ; } $ this -> transitioner = $ transitioner ; }
Sets the booking transitioner for this instance .
23,886
public static function directoryToArray ( string $ directory , bool $ recursive = false , bool $ listDirs = false , bool $ listFiles = true , string $ exclude = '' , array $ allowedFileTypes = [ ] , bool $ relativePath = false ) : array { $ arrayItems = [ ] ; $ skipByExclude = false ; $ handle = opendir ( $ directory ) ; if ( $ handle ) { while ( false !== ( $ file = readdir ( $ handle ) ) ) { preg_match ( '/(^(([\.]) {1,2})$|(\.(svn|git|md|htaccess))|(Thumbs\.db|\.DS_STORE|\.|\.\.))$/iu' , $ file , $ skip ) ; if ( $ exclude ) { preg_match ( $ exclude , $ file , $ skipByExclude ) ; } if ( $ allowedFileTypes && ! is_dir ( $ directory . DIRECTORY_SEPARATOR . $ file ) ) { $ ext = strtolower ( preg_replace ( '/^.*\.([^.]+)$/D' , '$1' , $ file ) ) ; if ( ! in_array ( $ ext , $ allowedFileTypes ) ) { $ skip = true ; } } if ( ! $ skip && ! $ skipByExclude ) { if ( is_dir ( $ directory . DIRECTORY_SEPARATOR . $ file ) ) { if ( $ recursive ) { $ arrayItems = array_merge ( $ arrayItems , self :: directoryToArray ( $ directory . DIRECTORY_SEPARATOR . $ file , $ recursive , $ listDirs , $ listFiles , $ exclude , $ allowedFileTypes , $ relativePath ) ) ; } if ( $ listDirs ) { $ arrayItems [ ] = ( $ relativePath ? $ file : $ directory . DIRECTORY_SEPARATOR . $ file ) ; } } else { if ( $ listFiles ) { $ arrayItems [ ] = ( $ relativePath ? $ file : $ directory . DIRECTORY_SEPARATOR . $ file ) ; } } } } closedir ( $ handle ) ; } return $ arrayItems ; }
Get an array that represents directory tree
23,887
function isAbsolute ( ) { $ p = $ this -> getPath ( ) ; reset ( $ p ) ; $ fi = current ( $ p ) ; return $ this -> _isRoot ( $ fi ) ; }
Is Absolute Path?
23,888
function joint ( iUriSequence $ pathUri ) { $ muchLength = $ this -> getPath ( ) ; $ less = $ pathUri -> getPath ( ) ; if ( count ( $ less ) > count ( $ muchLength ) ) { $ muchLength = $ less ; $ less = $ this -> getPath ( ) ; } $ similar = array ( ) ; foreach ( $ muchLength as $ i => $ v ) { if ( ! array_key_exists ( $ i , $ less ) || $ v != $ less [ $ i ] ) break ; $ similar [ ] = $ v ; } $ path = clone $ this ; $ path -> setPath ( $ similar ) ; return $ path ; }
Joint Given PathUri with Current Path
23,889
function mask ( iUriSequence $ pathUri , $ toggle = true ) { if ( ( $ this -> isAbsolute ( ) || $ pathUri -> isAbsolute ( ) ) && ! ( $ this -> isAbsolute ( ) && $ pathUri -> isAbsolute ( ) ) ) { $ uri = clone $ this ; if ( $ pathUri -> isAbsolute ( ) ) $ uri -> setPath ( $ pathUri -> getPath ( ) ) ; return $ uri ; } $ muchLength = $ this -> getPath ( ) ; $ less = $ pathUri -> getPath ( ) ; if ( $ toggle && ( count ( $ less ) > count ( $ muchLength ) ) ) { $ muchLength = $ less ; $ less = $ this -> getPath ( ) ; } $ masked = $ muchLength ; foreach ( $ muchLength as $ i => $ v ) { if ( ! array_key_exists ( $ i , $ less ) || $ v != $ less [ $ i ] ) break ; unset ( $ masked [ $ i ] ) ; } $ uri = clone $ this ; $ uri -> setPath ( $ masked ) ; return $ uri ; }
Mask Given PathUri with Current Path
23,890
function normalize ( ) { $ normalized = array ( ) ; $ paths = $ this -> getPath ( ) ; if ( empty ( $ paths ) ) return $ normalized ; if ( '~' === $ paths [ 0 ] ) { $ home = explode ( $ this -> getSeparator ( ) , str_replace ( '\\' , '/' , $ this -> _getHomeDir ( ) ) ) ; $ paths = $ paths + $ home ; } $ isRoot = $ this -> _isRoot ( $ paths [ 0 ] ) ; $ paths = array_filter ( $ paths , function ( $ p , $ i ) use ( & $ isRoot , $ paths ) { if ( ( $ isRoot && $ i > 0 ) || $ i + 1 == count ( $ paths ) ) { $ isRoot = false ; return true ; } return ( $ p !== '' && $ p !== '.' ) ; } , ARRAY_FILTER_USE_BOTH ) ; foreach ( $ paths as $ path ) { if ( '..' === $ path && count ( $ normalized ) > 0 && '..' !== $ normalized [ count ( $ normalized ) - 1 ] ) { if ( ! $ this -> _isRoot ( $ normalized [ count ( $ normalized ) - 1 ] ) ) array_pop ( $ normalized ) ; continue ; } $ normalized [ ] = $ path ; } $ this -> setPath ( $ normalized ) ; return $ this ; }
Normalize Array Path Stored On Class
23,891
public function findBySelector ( $ selector , $ media = '' , $ rootId = null ) { $ where = array ( 'selector' => ( string ) $ selector , 'media' => ( string ) $ media , ) ; if ( empty ( $ rootId ) ) { $ where [ ] = new Predicate \ IsNull ( 'rootParagraphId' ) ; } else { $ where [ 'rootParagraphId' ] = ( int ) $ rootId ; } return $ this -> findOne ( $ where ) ; }
Find structure by selector & media
23,892
public function findAllByRoot ( $ rootId = null , $ order = null , $ limit = null , $ offset = null ) { $ select = $ this -> select ( ) ; if ( empty ( $ rootId ) ) { $ where = array ( new Predicate \ IsNull ( 'rootParagraphId' ) ) ; } else { $ where = array ( 'rootParagraphId' => ( int ) $ rootId , ) ; } $ select -> where ( $ where ) -> order ( $ order ? : array ( ) ) -> limit ( $ limit ) -> offset ( $ offset ) ; $ return = array ( ) ; $ result = $ this -> sql ( ) -> prepareStatementForSqlObject ( $ select ) -> execute ( ) ; foreach ( $ result as $ row ) { $ return [ ] = $ this -> selected ( $ row ) ; } return $ return ; }
Find all structure by rootId
23,893
public function deleteByRoot ( $ rootId = null , array $ except = array ( ) ) { if ( null === $ rootId ) { $ where = array ( new Predicate \ IsNull ( 'rootParagraphId' ) ) ; } else { $ where = array ( 'rootParagraphId' => ( int ) $ rootId , ) ; } if ( ! empty ( $ except ) ) { $ where [ ] = new Predicate \ NotIn ( 'id' , $ except ) ; } $ delete = $ this -> sql ( ) -> delete ( ) -> where ( $ where ) ; $ result = $ this -> sql ( ) -> prepareStatementForSqlObject ( $ delete ) -> execute ( ) ; return $ result -> getAffectedRows ( ) ; }
Delete rules by root - id
23,894
protected static function _resolvePaginated ( array $ pagination , array $ data ) { $ client = new Client ( ) ; if ( ! $ pagination ) { Logger :: debug ( "Instagram-API finished resolving pagination." ) ; return $ data ; } Logger :: debug ( "Instagram-API retrieving next page `{$pagination['next_url']}`." ) ; $ response = $ client -> request ( 'GET' , $ pagination [ 'next_url' ] ) ; $ result = json_decode ( $ response -> getBody ( ) , true ) ; return static :: _resolvePaginated ( $ result [ 'pagination' ] , array_merge ( $ data , $ result [ 'data' ] ) ) ; }
Will never cache first page but cache all subsequent pages .
23,895
public function genAI ( $ sTable ) { $ sTable = '`' . addslashes ( $ sTable ) . '`' ; $ sQuery = 'INSERT INTO ' . $ sTable . ' () VALUES ()' ; $ iID = $ this -> getInsertID ( $ sQuery ) ; if ( $ iID && ( $ iID % 1000 == 0 ) ) { $ sQuery = 'DELETE FROM ' . $ sTable ; $ this -> exec ( $ sQuery ) ; } return $ iID ; }
auto increment id generator
23,896
private function getRecursive ( string $ name ) { if ( $ name === self :: SELF_NAME ) { return $ this ; } if ( ! isset ( $ this -> services [ $ name ] ) ) { if ( in_array ( $ name , $ this -> usedNames ) ) { throw new Exception ( "Cyclic dependency found while resolving $name" ) ; } $ this -> usedNames [ ] = $ name ; if ( ! isset ( $ this -> initializers [ $ name ] ) ) { throw new Exception ( "No initializer for $name" ) ; } $ this -> services [ $ name ] = $ this -> produceRecursive ( $ this -> initializers [ $ name ] ) ; } return $ this -> services [ $ name ] ; }
Return an initialized service .
23,897
public static function bootAttributable ( ) { $ models = array_merge ( [ static :: class ] , array_values ( class_parents ( static :: class ) ) ) ; $ attributes = DB :: table ( config ( 'rinvex.attributable.tables.attribute_entity' ) ) -> whereIn ( 'entity_type' , $ models ) -> get ( ) -> pluck ( 'attribute_id' ) ; static :: $ entityAttributes = Attribute :: whereIn ( 'id' , $ attributes ) -> get ( ) -> keyBy ( 'slug' ) ; static :: addGlobalScope ( new EagerLoadScope ( ) ) ; static :: saved ( EntityWasSaved :: class . '@handle' ) ; static :: deleted ( EntityWasDeleted :: class . '@handle' ) ; }
Boot the attributable trait for a model .
23,898
public function setEntityAttribute ( string $ key , $ value ) { $ current = $ this -> getEntityAttributeRelation ( $ key ) ; $ attribute = $ this -> getEntityAttributes ( ) -> get ( $ key ) ; if ( $ attribute -> is_collection ) { if ( is_null ( $ current ) ) { $ this -> setRelation ( $ key , $ current = new ValueCollection ( ) ) ; } $ current -> replace ( $ value ) ; return $ this ; } if ( is_null ( $ current ) ) { return $ this -> setEntityAttributeValue ( $ attribute , $ value ) ; } if ( $ value instanceof Value ) { $ value = $ value -> getAttribute ( 'content' ) ; } $ current -> setAttribute ( 'entity_type' , get_class ( $ this ) ) ; return $ current -> setAttribute ( 'content' , $ value ) ; }
Set the entity attribute .
23,899
public function toHtml ( ) { echo $ this -> getCssHtml ( ) ; echo $ this -> getJsHtml ( ) ; echo $ this -> getAdditionalHtml ( ) ; $ this -> rendered = true ; }
Renders the HTML in charge of loading CSS and JS files . The Html is echoed directly into the output . This function should be called within the head tag .