idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
8,700
public function addArrayChild ( & $ parent , $ arr ) { $ num = 0 ; if ( ! empty ( $ arr ) && ! empty ( $ parent ) ) { foreach ( $ arr as $ node ) { $ this -> appChild ( $ parent , $ node , '' ) ; $ num ++ ; } } return $ num ; }
addArrayChild Adiciona a um DOMNode parent outros elementos passados em um array de DOMElements .
8,701
public function setKey ( $ key ) { $ this -> key = $ key ; if ( ! session ( ) -> has ( 'bzarzuela.filters' ) ) { session ( [ 'bzarzuela.filters' => [ $ key => [ ] ] ] ) ; } return $ this ; }
Sets a unique key to hold the filter form data in the session .
8,702
public function getFormData ( $ field = null ) { $ filters = session ( 'bzarzuela.filters' ) ; if ( isset ( $ filters [ $ this -> key ] [ 'form_data' ] ) ) { if ( ! is_null ( $ field ) ) { if ( ! isset ( $ filters [ $ this -> key ] [ 'form_data' ] [ $ field ] ) ) { return null ; } return $ filters [ $ this -> key ] [ '...
Gets either the whole form data or just a field inside .
8,703
public function afterStep ( StepEvent $ event ) { $ color = $ this -> getResultColorCode ( $ event -> getResult ( ) ) ; $ capture = $ this -> captureAll || $ color == 'failed' ; if ( $ capture ) { try { $ screenshot = $ this -> driver -> getScreenshot ( ) ; if ( $ screenshot ) { $ date = new \ DateTime ( 'now' ) ; $ fi...
Listens to step . after event .
8,704
protected function importResource ( BaseConfig $ baseConfig ) { foreach ( $ baseConfig as $ key => $ value ) { if ( $ value instanceof BaseConfig ) { $ this -> importResource ( $ value ) ; } elseif ( is_string ( $ value ) ) { if ( $ key === self :: RESOURCES_KEY ) { $ resources = $ this -> clear ( $ baseConfig , $ this...
Import encountered files in the configuration
8,705
public function clear ( Config $ means , Config $ target ) { foreach ( $ target as $ key => $ value ) { if ( $ value instanceof BaseConfig && isset ( $ means [ $ key ] ) ) { $ this -> clear ( $ means [ $ key ] , $ value ) ; } else { if ( isset ( $ means [ $ key ] ) ) { $ target -> offsetUnset ( $ key ) ; } } } return n...
Delete variables that are already defined in the main configuration file
8,706
protected function moduleConfigCreate ( $ path ) { $ value = explode ( '::' , $ path ) ; $ ref = new ReflectionClass ( $ value [ 0 ] ) ; if ( $ ref -> hasConstant ( 'DIR' ) === false ) { throw new ConstantDirNotFoundException ( 'Not found constant DIR in class ' . $ value [ 0 ] ) ; } return $ this -> create ( $ value [...
Create a configuration of the module for further imports
8,707
public function put ( $ data , $ priority = \ Pheanstalk_PheanstalkInterface :: DEFAULT_PRIORITY , $ delay = \ Pheanstalk_PheanstalkInterface :: DEFAULT_DELAY , $ timeToRun = \ Pheanstalk_PheanstalkInterface :: DEFAULT_TTR ) { $ this -> pheanstalk -> put ( $ data , $ priority , $ delay , $ timeToRun ) ; return $ this ;...
Puts a task string into the current
8,708
public function getTab ( ) : string { return '<span title="Doctrine 2">' . '<svg viewBox="0 0 2048 2048"><path fill="#aaa" d="M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280' . '-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-3...
Renders tab for Tracy Debug Bar .
8,709
public function getPanel ( ) : string { if ( empty ( $ this -> queries ) ) { return '' ; } $ params = $ this -> connection -> getParams ( ) ; $ host = ( $ params [ 'driver' ] === 'pdo_sqlite' && isset ( $ params [ 'path' ] ) ) ? 'path: ' . basename ( $ params [ 'path' ] ) : sprintf ( 'host: %s%s/%s' , $ this -> connect...
Renders panel for Tracy Debug Bar .
8,710
private function renderPanelCacheStatistics ( ) : string { if ( empty ( $ this -> entityManager ) ) { return '' ; } $ config = $ this -> entityManager -> getConfiguration ( ) ; if ( ! $ config -> isSecondLevelCacheEnabled ( ) ) { return '' ; } $ loggerChain = $ config -> getSecondLevelCacheConfiguration ( ) -> getCache...
Renders cache statistics .
8,711
private function renderPanelQueries ( ) : string { if ( empty ( $ this -> queries ) ) { return '' ; } $ s = '' ; foreach ( $ this -> queries as $ query ) { [ $ sql , $ params , $ time , $ types , $ source ] = $ query ; $ q = SqlDumper :: dump ( $ sql , $ params ) ; $ q .= $ source ? Helpers :: editorLink ( $ source [ 0...
Renders SQL queries .
8,712
public function setEntityManager ( EntityManager $ entityManager ) { $ this -> entityManager = $ entityManager ; $ this -> connection = $ entityManager -> getConnection ( ) ; $ bar = Debugger :: getBar ( ) ; $ bar -> addPanel ( $ this ) ; $ config = $ this -> connection -> getConfiguration ( ) ; $ logger = $ config -> ...
Sets entity manager .
8,713
public function show ( $ key ) { $ this -> authorize ( 'read' , Option :: class ) ; try { $ option = $ this -> optionRepo -> getOptions ( $ key ) ; return $ this -> respondWithSuccess ( $ option , new OptionTransformer ) ; } catch ( RepositoryValidationException $ e ) { return $ this -> respondWithError ( $ e -> getMes...
Display all options from selected category .
8,714
static function isValid ( $ value ) { if ( ! \ Poirot \ Std \ isStringify ( $ value ) ) throw new \ InvalidArgumentException ( sprintf ( 'Header value must be string; given: (%s).' , \ Poirot \ Std \ flatten ( $ value ) ) ) ; $ value = ( string ) $ value ; if ( preg_match ( "#(?:(?:(?<!\r)\n)|(?:\r(?!\n))|(?:\r\n(?![ \...
Validate a header value .
8,715
public function addPath ( $ relativePath ) { if ( ! $ relativePath || $ relativePath == '/' ) { return $ this ; } if ( $ relativePath [ 0 ] != '/' ) { $ relativePath = '/' . $ relativePath ; } return $ this -> setPath ( str_replace ( '//' , '/' , $ this -> getPath ( ) . $ relativePath ) ) ; }
Add a relative path to the currently set path
8,716
protected function validateParameterCount ( $ name , $ parameterAmount , array $ parameters ) { if ( count ( $ parameters ) !== $ parameterAmount ) { throw new ValidationException ( '"' . $ name . '" expects ' . $ parameterAmount . ' parameter.' ) ; } }
Throws an exception if the parameters don t fulfill the expected parameter count .
8,717
public function emergency ( string $ id , string $ message , int $ status = 400 ) { Log :: error ( $ id . ' : ' . $ message ) ; return response ( ) -> json ( [ 'success' => false , 'id' => $ id , 'message' => $ message ] , $ status ) ; }
Create emergency response
8,718
public function notice ( string $ id , string $ message , int $ status = 400 ) { Log :: info ( $ id . ' : ' . $ message ) ; return response ( ) -> json ( [ 'success' => false , 'id' => $ id , 'message' => $ message ] , $ status ) ; }
Create notice response
8,719
public function success ( string $ id , string $ message , int $ status = 200 ) { Log :: info ( $ id . ' : ' . $ message ) ; return response ( ) -> json ( [ 'success' => true , 'id' => $ id , 'message' => $ message ] , $ status ) ; }
Create success response
8,720
function setOption ( $ option , $ value ) { $ ret = true ; if ( array_key_exists ( $ option , $ this -> _options ) ) { $ this -> _options [ $ option ] = $ value ; } else { throw new InvalidArgumentException ( 'Unknown option ' . $ option ) ; } }
Sets run - time configuration options
8,721
function loadFile ( $ filename ) { if ( file_exists ( $ filename ) ) { if ( ( $ this -> content = @ file_get_contents ( $ filename ) ) === false ) { throw new BibtexException ( 'Could not open file ' . $ filename ) ; } else { $ this -> _pos = 0 ; $ this -> _oldpos = 0 ; return true ; } } else { throw new BibtexExceptio...
Reads a give BibTex File
8,722
function _checkEqualSign ( $ entry , $ position ) { $ ret = true ; $ length = strlen ( $ entry ) ; $ open = 0 ; for ( $ i = $ length - 1 ; $ i >= $ position ; $ i -- ) { $ precedingchar = substr ( $ entry , $ i - 1 , 1 ) ; $ char = substr ( $ entry , $ i , 1 ) ; if ( ( '{' == $ char ) && ( '\\' != $ precedingchar ) ) {...
Checking whether the position of the = is correct
8,723
function _checkAt ( $ entry ) { $ ret = false ; $ opening = array_keys ( $ this -> _delimiters ) ; $ closing = array_values ( $ this -> _delimiters ) ; if ( strrpos ( $ entry , '=' ) !== false ) { $ position = strrpos ( $ entry , '=' ) ; $ proceed = true ; if ( substr ( $ entry , $ position - 1 , 1 ) == '\\' ) { $ proc...
Checking whether an at is outside an entry
8,724
function _wordwrap ( $ entry ) { if ( ( '' != $ entry ) && ( is_string ( $ entry ) ) ) { $ entry = wordwrap ( $ entry , $ this -> _options [ 'wordWrapWidth' ] , $ this -> _options [ 'wordWrapBreak' ] , $ this -> _options [ 'wordWrapCut' ] ) ; } return $ entry ; }
Wordwrap an entry
8,725
function _determineCase ( $ word ) { $ ret = - 1 ; $ trimmedword = trim ( $ word ) ; if ( is_string ( $ word ) && ( strlen ( $ trimmedword ) > 0 ) ) { $ i = 0 ; $ found = false ; $ openbrace = 0 ; while ( ! $ found && ( $ i <= strlen ( $ word ) ) ) { $ letter = substr ( $ trimmedword , $ i , 1 ) ; $ ord = ord ( $ lette...
Case Determination according to the needs of BibTex
8,726
function _validateValue ( $ entry , $ wholeentry ) { if ( preg_match ( '/^{.*@.*}$/' , $ entry ) ) { $ this -> _generateWarning ( 'WARNING_AT_IN_BRACES' , $ entry , $ wholeentry ) ; } if ( preg_match ( '/^\".*\\".*\"$/' , $ entry ) ) { $ this -> _generateWarning ( 'WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES' , $...
Validation of a value
8,727
function _removeCurlyBraces ( $ value ) { $ beginningdels = array_keys ( $ this -> _delimiters ) ; $ firstchar = substr ( $ value , 0 , 1 ) ; $ lastchar = substr ( $ value , - 1 , 1 ) ; $ begin = '' ; $ end = '' ; while ( in_array ( $ firstchar , $ beginningdels ) ) { if ( $ lastchar == $ this -> _delimiters [ $ firstc...
Remove curly braces from entry
8,728
function _generateWarning ( $ type , $ entry , $ wholeentry = '' ) { $ warning [ 'warning' ] = $ type ; $ warning [ 'entry' ] = $ entry ; $ warning [ 'wholeentry' ] = $ wholeentry ; $ this -> warnings [ ] = $ warning ; }
Generates a warning
8,729
function _formatAuthor ( $ array ) { if ( ! array_key_exists ( 'von' , $ array ) ) { $ array [ 'von' ] = '' ; } else { $ array [ 'von' ] = trim ( $ array [ 'von' ] ) ; } if ( ! array_key_exists ( 'last' , $ array ) ) { $ array [ 'last' ] = '' ; } else { $ array [ 'last' ] = trim ( $ array [ 'last' ] ) ; } if ( ! array_...
Returns the author formatted
8,730
function bibTex ( ) { $ bibtex = '' ; foreach ( $ this -> data as $ entry ) { $ bibtex .= '@' . strtolower ( $ entry [ 'entryType' ] ) . ' { ' . $ entry [ 'cite' ] . ",\n" ; foreach ( $ entry as $ key => $ val ) { if ( $ this -> _options [ 'wordWrapWidth' ] > 0 ) { $ val = $ this -> _wordWrap ( $ val ) ; } if ( ! in_ar...
Converts the stored BibTex entries to a BibTex String
8,731
function rtf ( ) { $ ret = "{\\rtf\n" ; foreach ( $ this -> data as $ entry ) { $ line = $ this -> rtfstring ; $ title = '' ; $ journal = '' ; $ year = '' ; $ authors = '' ; if ( array_key_exists ( 'title' , $ entry ) ) { $ title = $ this -> _unwrap ( $ entry [ 'title' ] ) ; } if ( array_key_exists ( 'journal' , $ entr...
Returns the stored data in RTF format
8,732
function _escape_tex ( $ tex ) { $ tex = str_replace ( "\\" , "\\\\" , $ tex ) ; $ tex = str_replace ( '#' , '\#' , $ tex ) ; $ tex = str_replace ( '$' , '\$' , $ tex ) ; $ tex = str_replace ( '%' , '\%' , $ tex ) ; $ tex = str_replace ( '^' , '\^' , $ tex ) ; $ tex = str_replace ( '&' , '\&' , $ tex ) ; $ tex = str_re...
Returns a string with special TeX characters escaped .
8,733
public function getTokens ( $ string , & $ needle = 0 ) { $ exprTokenizer = new ExpressionTokenizer ( ) ; $ ret = array ( ) ; $ depth = 0 ; $ needle = 0 ; $ len = strlen ( $ string ) ; while ( $ needle < $ len ) { $ before = $ needle ; $ substr = substr ( $ string , $ needle ) ; if ( $ depth === 0 ) { if ( preg_match (...
Returns an array of tokens
8,734
public function indexAction ( ) { if ( $ this -> getRequest ( ) -> isAjax ( ) ) { try { $ this -> loadLayout ( null , false , false ) ; $ this -> getLayout ( ) -> getUpdate ( ) -> setCacheId ( null ) ; $ this -> getLayout ( ) -> getUpdate ( ) -> addHandle ( strtolower ( $ this -> getFullActionName ( ) ) . '_AJAX' ) ; }...
List existing records via a grid
8,735
public function viewAction ( ) { $ model = $ this -> loadModel ( ) ; if ( ! $ model -> getId ( ) ) { $ this -> _forward ( 'noroute' ) ; return ; } $ this -> loadLayout ( ) ; $ this -> renderLayout ( ) ; }
View existing record
8,736
public function widgetExist ( $ name ) { $ name = strtolower ( $ name ) ; return isset ( $ this -> dataStore [ 0 ] [ $ name ] ) ? $ this -> dataStore [ 0 ] [ $ name ] : false ; }
Checks if a widget exists
8,737
public function sendNotificationInMany ( $ subscriber , $ contentObject , $ comment , $ tpl = null ) { if ( is_null ( $ tpl ) ) { $ tpl = eZTemplate :: factory ( ) ; } $ tpl -> setVariable ( 'subscriber' , $ subscriber ) ; $ tpl -> setVariable ( 'contentobject' , $ contentObject ) ; $ tpl -> setVariable ( 'comment' , $...
send one notification with one comment by one comment Exception if error happens
8,738
public function sendNotificationInOne ( $ subscriber , $ contentObject , $ commentList = null , $ tpl = null ) { if ( is_null ( $ tpl ) ) { $ tpl = eZTemplate :: factory ( ) ; } $ tpl -> setVariable ( 'subscriber' , $ subscriber ) ; $ tpl -> setVariable ( 'contentobject' , $ contentObject ) ; if ( ! is_null ( $ comment...
send notification with all comment in one notification Exception if error happens
8,739
public static function instance ( $ className = null ) { if ( is_null ( $ className ) ) { $ ini = eZINI :: instance ( 'ezcomments.ini' ) ; $ className = $ ini -> variable ( 'NotificationSettings' , 'NotificationManagerClass' ) ; } if ( ! isset ( self :: $ instance ) ) { self :: $ instance = new $ className ( ) ; } retu...
create instance of the object
8,740
public static function create ( $ className = null ) { if ( is_null ( $ className ) ) { $ ini = eZINI :: instance ( 'ezcomments.ini' ) ; $ className = $ ini -> variable ( 'NotificationSettings' , 'NotificationManagerClass' ) ; } return new $ className ( ) ; }
create instance of the object without using singleton
8,741
public function resources ( ) { $ options = Config :: get ( 'laravel-swagger::getResourceListOptions' ) ; $ excludedPath = Config :: get ( 'laravel-swagger::excludedPath' ) ; $ swagger = new Swagger ( $ this -> getPaths ( ) , $ excludedPath ) ; if ( Config :: get ( 'laravel-swagger::cache' ) ) { $ resourceList = Cache ...
Show all available Resources
8,742
public function showResource ( $ name ) { $ options = Config :: get ( 'laravel-swagger::getResourceOptions' ) ; $ resourceName = "/" . str_replace ( "-" , "/" , $ name ) ; $ excludedPath = Config :: get ( 'laravel-swagger::excludedPath' ) ; $ swagger = new Swagger ( $ this -> getPaths ( ) , $ excludedPath ) ; if ( Conf...
Show an specific Resource
8,743
function save ( ) { $ fw = Base :: instance ( ) ; if ( $ this -> flag ) { if ( ! is_dir ( $ dir = $ fw -> get ( 'TEMP' ) ) ) mkdir ( $ dir , Base :: MODE , TRUE ) ; $ this -> count ++ ; $ fw -> write ( $ dir . '/' . $ fw -> hash ( $ fw -> get ( 'ROOT' ) . $ fw -> get ( 'BASE' ) ) . '.' . $ fw -> hash ( $ this -> file )...
Save current state
8,744
function restore ( $ state = 1 ) { $ fw = Base :: instance ( ) ; if ( $ this -> flag && is_file ( $ file = ( $ path = $ fw -> get ( 'TEMP' ) . $ fw -> hash ( $ fw -> get ( 'ROOT' ) . $ fw -> get ( 'BASE' ) ) . '.' . $ fw -> hash ( $ this -> file ) . '-' ) . $ state . '.png' ) ) { if ( is_resource ( $ this -> data ) ) i...
Revert to specified state
8,745
function calcular_valor_cubierto ( $ mesaId = null ) { if ( ! empty ( $ mesaId ) ) { $ this -> id = $ mesaId ; } $ cant_comensales = $ this -> field ( 'cant_comensales' ) ; $ precioCubierto = Configure :: read ( 'Restaurante.valorCubierto' ) ; $ valor_cubierto = 0 ; if ( $ precioCubierto > 0 ) { $ valor_cubierto = $ pr...
Funcion que calcula el precio del cubierto
8,746
function estaCobrada ( $ id = null , $ force_db = false ) { $ ret = false ; if ( ! empty ( $ id ) ) { $ this -> id = $ id ; } if ( ! empty ( $ this -> data [ $ this -> name ] [ 'estado_id' ] ) ) { $ ret = $ this -> data [ $ this -> name ] [ 'estado_id' ] == MESA_COBRADA ; } if ( $ force_db ) { $ ret = $ this -> find ( ...
Dice si una mesa esta cobrada o no
8,747
function estaAbierta ( $ id = null ) { if ( ! empty ( $ id ) ) { $ this -> id = $ id ; } $ ret = $ this -> find ( 'count' , array ( 'conditions' => array ( 'Mesa.estado_id' => MESA_ABIERTA , 'Mesa.id' => $ this -> id , ) ) ) ; return ( $ ret > 0 ) ; }
Dice si una mesa esta abierta o no
8,748
function totalesDeMesasEntre ( $ fechaDesde = '' , $ fechaHasta = '' , $ conds = array ( ) ) { $ horarioCorte = Configure :: read ( 'Horario.corte_del_dia' ) ; if ( $ horarioCorte < 10 ) { $ horarioCorte = "0$horarioCorte" ; } $ sqlHorarioDeCorte = "DATE(SUBTIME(Mesa.checkin, '$horarioCorte:00:00'))" ; $ desde = empty ...
Me devuelve un listado agrupado por dia de mesas . Util para estadistica y contabilidad
8,749
public function changeRoomStateIfTodayInPeriod ( $ room , $ checkin , $ checkout ) { if ( ! is_array ( $ room ) && ( is_string ( $ room ) || is_int ( $ room ) ) ) { $ room = $ this -> Room -> findById ( $ room ) ; } $ today = date ( 'Y-m-d' ) ; if ( $ this -> hasRoomMesaInDate ( $ room , $ today ) ) { return $ this -> ...
change the room state if today is between period of Mesa for a given nombre_mesa_id or room object
8,750
public static function create ( ) { $ app = new CLIApplication ( 'Dachi' , Kernel :: getVersion ( true ) ) ; $ commands = array ( new \ Dachi \ Core \ Console \ Command \ TestCommand ( ) , new \ Dachi \ Core \ Console \ Command \ CreateCommand ( ) , new \ Dachi \ Core \ Console \ Command \ DocumentCommand ( ) , new \ D...
Create the CLI application
8,751
public function validateDocBlocks ( $ data ) { $ element = $ data -> getSubject ( ) ; $ docblock = $ data -> getDocblock ( ) ; $ type = substr ( get_class ( $ element ) , strrpos ( get_class ( $ element ) , '\\' ) + 1 , - 9 ) ; if ( $ docblock && $ docblock -> hasTag ( 'ignore' ) ) { return ; } $ validatorOptions = $ t...
Checks all phpDocumentor whether they match the given rules .
8,752
public function pdo ( PDO $ pdo = null ) { if ( $ pdo ) { $ this -> pdo = $ pdo ; } return $ this -> pdo ; }
Get or set PDO instance
8,753
public function quoteIdentifier ( $ identifier ) { $ parts = explode ( "." , $ identifier ) ; if ( count ( $ parts ) > 1 ) { return $ this -> quoteIdentifier ( $ parts [ 0 ] ) . '.' . $ this -> quoteIdentifier ( $ parts [ 1 ] ) ; } return '`' . str_replace ( '`' , '``' , $ identifier ) . '`' ; }
Quote an identifier for MySQL query usage
8,754
public function merge ( $ query , array $ data ) { $ expression = "/(\\?)(?=(?:[^']|'[^']*')*$)/" ; $ callback = function ( ) use ( & $ data ) { if ( ! $ data ) { return '?' ; } return $ this -> quote ( array_shift ( $ data ) ) ; } ; return preg_replace_callback ( $ expression , $ callback , $ query ) ; }
Merge data into an SQL query with placeholders
8,755
public function query ( $ query , ... $ data ) { if ( $ data ) { $ query = $ this -> merge ( $ query , $ data ) ; } try { $ statement = $ this -> pdo -> query ( $ query ) ; return new Result ( $ statement ) ; } catch ( PDOException $ exception ) { throw new QueryException ( $ exception , $ query ) ; } }
Run a query and return the result
8,756
public function fetch ( $ query , ... $ data ) { if ( $ data ) { $ query = $ this -> merge ( $ query , $ data ) ; } try { $ statement = $ this -> pdo -> query ( $ query ) ; return new FetchedResult ( $ statement -> fetchAll ( PDO :: FETCH_ASSOC ) ) ; } catch ( PDOException $ exception ) { throw new QueryException ( $ e...
Run a query and eagerly fetch the result into memory
8,757
public function execute ( $ query , ... $ data ) { if ( $ data ) { $ query = $ this -> merge ( $ query , $ data ) ; } try { return $ this -> pdo -> exec ( $ query ) ; } catch ( PDOException $ exception ) { throw new QueryException ( $ exception , $ query ) ; } }
Execute a query and return the number of rows affected
8,758
public function insert ( $ table , array $ data = null ) { $ insert = $ this -> build ( ) -> insert ( $ table ) ; if ( $ data ) { return $ insert -> values ( $ data ) -> execute ( ) ; } return $ insert ; }
Insert data into a table
8,759
public function update ( $ table , array $ data = null , $ where = null ) { $ update = $ this -> build ( ) -> update ( $ table ) ; if ( $ data ) { $ update -> set ( $ data ) ; } if ( $ where ) { $ update -> where ( $ where ) ; } if ( $ data && $ where ) { return $ update -> execute ( ) ; } return $ update ; }
Update data in a table
8,760
public function delete ( $ table , $ where = null ) { $ delete = $ this -> build ( ) -> delete ( $ table ) ; if ( $ where ) { return $ delete -> where ( $ where ) -> execute ( ) ; } return $ delete ; }
Delete from a table
8,761
public function transaction ( callable $ closure ) { $ this -> start ( ) ; try { $ result = $ closure ( ) ; } catch ( \ Throwable $ e ) { $ this -> rollback ( ) ; throw $ e ; } $ this -> commit ( ) ; return $ result ; }
Run a closure inside a transaction
8,762
public function encrypt ( $ string ) { $ td = mcrypt_module_open ( $ this -> cypher , '' , $ this -> mode , '' ) ; $ iv = mcrypt_create_iv ( mcrypt_enc_get_iv_size ( $ td ) , mcrypt_RAND ) ; mcrypt_generic_init ( $ td , $ this -> key , $ iv ) ; $ encrypted = mcrypt_generic ( $ td , $ string ) ; mcrypt_generic_deinit ( ...
Encrypts a string
8,763
public function decrypt ( $ string ) { $ decrypted = "" ; $ td = mcrypt_module_open ( $ this -> cypher , '' , $ this -> mode , '' ) ; $ ivsize = mcrypt_enc_get_iv_size ( $ td ) ; $ iv = substr ( $ string , 0 , $ ivsize ) ; $ string = substr ( $ string , $ ivsize ) ; if ( $ iv ) { mcrypt_generic_init ( $ td , $ this -> ...
Decrypts a string
8,764
public function getCurrentLogFilePath ( ) { $ rotateTimeMark = "" ; if ( $ this -> rotateTimeFormat !== null ) { $ rotateTimeMark .= "-" . date ( $ this -> rotateTimeFormat ) ; } if ( is_callable ( $ this -> prefix ) ) { $ prefix = call_user_func_array ( $ this -> prefix , [ ] ) ; } else { $ prefix = $ this -> prefix ;...
Sometime you may need to know where the log file is
8,765
public function print ( $ level , $ message , array $ context = array ( ) , $ enforceEndOfLine = true ) { if ( $ this -> shouldIgnoreThisLog ( $ level ) ) { return ; } $ msg = $ this -> generateLog ( $ level , $ message , $ context , $ enforceEndOfLine ) ; echo $ msg ; }
If you want to output log directly to STDOUT use this .
8,766
private static function _get_db ( ) : ? bbn \ db { if ( self :: $ db && self :: $ db -> check ( ) ) { return self :: $ db ; } return null ; }
Returns the database connection object .
8,767
private static function _get_databases ( ) : ? databases { if ( self :: check ( ) ) { if ( ! self :: $ databases_obj && ( $ db = self :: _get_db ( ) ) ) { self :: $ databases_obj = new databases ( $ db ) ; } return self :: $ databases_obj ; } return null ; }
Returns an instance of the appui \ database class .
8,768
private static function _insert ( array $ cfg ) : int { if ( isset ( $ cfg [ 'column' ] , $ cfg [ 'line' ] , $ cfg [ 'chrono' ] ) && self :: check ( ) && ( $ db = self :: _get_db ( ) ) ) { $ id = $ db -> last_id ( ) ; $ last = self :: $ db -> last ( ) ; $ last_params = self :: $ db -> last_params ; self :: disable ( ) ...
Adds a row in the history table
8,769
private static function _get_table_where ( string $ table ) : ? string { if ( bbn \ str :: check_name ( $ table ) && ( $ db = self :: _get_db ( ) ) && ( $ databases_obj = self :: _get_databases ( ) ) && ( $ model = $ databases_obj -> modelize ( $ table ) ) ) { $ col = $ db -> escape ( 'col' ) ; $ where_ar = [ ] ; forea...
Get a string for the WHERE in the query with all the columns selection
8,770
public static function get_id_column ( string $ column , string $ table ) : ? string { if ( ( $ db = self :: _get_db ( ) ) && ( $ full_table = $ db -> tfn ( $ table ) ) && ( $ databases_obj = self :: _get_databases ( ) ) ) { [ $ database , $ table ] = explode ( '.' , $ full_table ) ; return $ databases_obj -> column_id...
Returns the column s corresponding option s ID
8,771
public static function check ( ) : bool { return isset ( self :: $ user , self :: $ table , self :: $ db ) && self :: is_init ( ) && self :: _get_db ( ) ; }
Checks if all history parameters are set in order to read and write into history
8,772
public static function has_history ( bbn \ db $ db ) : bool { $ hash = $ db -> get_hash ( ) ; return \ in_array ( $ hash , self :: $ dbs , true ) ; }
Returns true if the given DB connection is configured for history
8,773
public static function set_column ( string $ column ) : void { if ( bbn \ str :: check_name ( $ column ) ) { self :: $ column = $ column ; } }
Sets the active column name
8,774
public static function set_admin_db ( string $ db_name ) : void { if ( bbn \ str :: check_name ( $ db_name ) ) { self :: $ admin_db = $ db_name ; self :: $ table = self :: $ admin_db . '.' . self :: $ prefix . 'history' ; } }
Sets the history table name
8,775
public static function set_user ( $ user ) : void { if ( bbn \ str :: is_uid ( $ user ) ) { self :: $ user = $ user ; } }
Sets the user ID that will be used to fill the user_id field
8,776
public function is_image ( $ path ) { if ( ! file_exists ( $ path ) || ! ( $ info = getimagesize ( $ path ) ) ) { return false ; } return ( bool ) preg_match ( "/^image\/(jpeg|png|gif)$/" , $ info [ 'mime' ] ) ; }
Detect if specified file is image
8,777
public function get_mime ( $ file ) { $ type = $ this -> get_content_type ( $ file ) ; if ( $ type ) { $ type = array_map ( 'trim' , explode ( ';' , $ type ) ) ; return $ type [ 0 ] ; } else { return '' ; } }
Return mime type
8,778
public function get_content_type ( $ path ) { if ( file_exists ( $ path ) ) { $ info = finfo_open ( FILEINFO_MIME ) ; $ type = finfo_file ( $ info , $ path ) ; finfo_close ( $ info ) ; return $ type ? : '' ; } else { return '' ; } }
Get content type
8,779
public function merge ( array $ metadata ) : array { $ tables = [ ] ; foreach ( $ metadata as $ entity ) { $ tables [ $ entity -> getTableName ( ) ] [ ] = $ entity ; } $ merged = [ ] ; foreach ( $ tables as $ table => $ metadata ) { if ( count ( $ metadata ) === 1 ) { $ merged [ ] = array_shift ( $ metadata ) ; continu...
Merges metadata of multiple doctrine entities .
8,780
public function init ( ) { $ args = $ this -> console -> arguments ; $ args -> parse ( ) ; if ( $ args -> defined ( 'hardstart' ) ) { $ this -> hardstart ( ) ; } if ( $ args -> defined ( 'daemon' ) ) { $ this -> daemonize ( ) ; } else if ( $ args -> defined ( 'foreground' ) ) { if ( $ args -> defined ( 'verbose' ) ) { ...
Parse console arguments and init the daemon
8,781
public function daemonize ( ) { $ pid = $ this -> fork ( ) ; $ this -> detach ( ) ; $ this -> pid = $ pid ; $ this -> start ( ) ; }
Start as a daemon forking main process and detaching it from terminal
8,782
public function url ( $ page ) { if ( $ page <= 0 ) { $ page = 1 ; } $ parameters = [ $ this -> pageName => $ page ] ; if ( count ( $ this -> query ) > 0 ) { $ parameters = array_merge ( $ this -> query , $ parameters ) ; } $ uri = Uri :: createFromString ( $ this -> path ) ; parse_str ( $ uri -> getQuery ( ) , $ query...
Get the URL for a given page number .
8,783
public function addClient ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Application \ API \ OAuth \ Client \ Client $ client ) { $ this -> clients [ ] = $ client ; return $ this ; }
Add client .
8,784
public function removeClient ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Application \ API \ OAuth \ Client \ Client $ client ) { return $ this -> clients -> removeElement ( $ client ) ; }
Remove client .
8,785
public function getLimits ( ) { $ totalPages = $ this -> getTotalPages ( ) ; $ this -> currentPage = ( $ this -> currentPage > $ totalPages ) ? $ totalPages : $ this -> currentPage ; $ dLimit = ( $ this -> currentPage - 1 ) * $ this -> itemsPerPage ; return array ( $ dLimit , $ this -> itemsPerPage ) ; }
Returns the offset ant length for limiting results to current page
8,786
public function post ( ... $ keys ) { if ( ! $ keys ) { return $ this -> request -> values ; } elseif ( count ( $ keys ) === 1 ) { return $ this -> request -> value ( $ keys [ 0 ] ) ; } $ values = [ ] ; foreach ( $ keys as $ key ) { $ values [ ] = $ this -> request -> value ( $ key ) ; } return $ values ; }
Get post value
8,787
public function initialize ( $ object ) { if ( ! is_object ( $ object ) ) { return ; } foreach ( $ this -> knownDependencies as $ interface => $ dependencyInfo ) { list ( $ setterMethod , $ serviceId ) = $ dependencyInfo ; if ( is_a ( $ object , $ interface ) ) { $ object -> $ setterMethod ( $ this -> container -> get ...
Initializes object dependencies
8,788
public function getWorkspaces ( ) { return $ this -> getCachedProperty ( 'workspaces' , function ( ) { $ workspaces = [ ] ; $ items = $ this -> getDomElement ( ) -> getElementsByTagNameNS ( $ this -> ns ( ) , 'workspace' ) ; foreach ( $ items as $ item ) { $ workspaces [ ] = $ this -> getExtensions ( ) -> parseElement ...
Return workspaces .
8,789
public function addWorkspace ( $ title ) { $ workspaces = $ this -> getWorkspaces ( ) ; $ workspace = $ this -> getExtensions ( ) -> createElement ( $ this , 'app:workspace' ) ; $ workspace -> addTitle ( $ title ) ; $ workspaces [ ] = $ workspace ; $ this -> setCachedProperty ( 'workspaces' , $ workspaces ) ; return $ ...
Add workspace to document .
8,790
public function getArticles ( $ articleNumber = null ) { $ requestData = new Get \ RequestData ( ) ; $ requestData -> setArticleNumber ( $ articleNumber ) ; $ request = new Get \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , Get \ ApiResponse :: class ) ; }
Get the articles .
8,791
public function getArticle ( $ articleNumber ) { $ requestData = new Get \ RequestData ( ) ; $ requestData -> setArticleNumber ( $ articleNumber ) ; $ request = new Get \ Request ( $ requestData ) ; $ request -> setLimit ( 1 ) ; $ apiResponse = $ this -> sendRequest ( $ request , Get \ ApiResponse :: class ) ; $ articl...
Get one article by article number .
8,792
public function getArticleNumberCheckoutURL ( $ articleNumber , Customer $ customer = null ) { $ article = $ this -> getArticle ( $ articleNumber ) ; if ( $ article === null ) { throw new \ OutOfBoundsException ( 'Article not found.' ) ; } return $ this -> getArticleCheckoutURL ( $ article , $ customer ) ; }
Get the checkout URL for an article .
8,793
protected function generateCheckoutURLForCustomer ( $ customerHash , $ articleNumber ) { return sprintf ( 'https://app.monsum.com/checkout/0/%s/%s/%s' , $ this -> transport -> getCredentials ( ) -> getAccountHash ( ) , $ customerHash , $ articleNumber ) ; }
Get the checkout URL of an article for a customer .
8,794
public function execute ( $ params = array ( ) ) { $ app = $ this -> router -> getAppInstance ( ) ; return $ app -> trigger ( "system.routing.route.execute" , function ( $ event ) { $ app = $ event -> props ( 'app' ) ; $ route = $ event -> props ( 'route' ) ; $ params = $ event -> props ( 'params' ) ; if ( count ( $ pa...
Execute this route
8,795
public function eachRole ( array $ roles , callable $ callback ) { $ roles = array_flatten ( $ roles ) ; foreach ( $ roles as $ role ) { if ( $ role = $ this -> prepareRole ( $ role ) ) { $ callback ( $ role ) ; } } }
Calc each rote
8,796
public function writeTimedLog ( $ message , $ operation , array $ arguments = array ( ) ) { $ this -> write ( sprintf ( '%-66.66s .. ' , $ message ) ) ; $ timerStart = microtime ( true ) ; call_user_func_array ( $ operation , $ arguments ) ; $ this -> writeln ( sprintf ( '%8.3fs' , microtime ( true ) - $ timerStart ) )...
Executes a callable piece of code and writes an entry to the log detailing how long it took .
8,797
public function write ( $ message , $ newline = false , $ type = 0 ) { $ messages = ( array ) $ message ; if ( $ this -> getLogger ( ) ) { foreach ( $ messages as $ message ) { $ this -> getLogger ( ) -> info ( $ this -> getFormatter ( ) -> format ( strip_tags ( $ message ) ) ) ; } } parent :: write ( $ messages , $ ne...
Write an entry to the console and to the provided logger .
8,798
protected function formatErrors ( string $ errors ) { $ errors = json_decode ( $ errors ) ; $ output = '' ; foreach ( $ errors as $ error ) foreach ( $ error as $ message ) $ output .= $ message . "\r\n" ; return $ output ; }
Must return string!!
8,799
public function hasFunctionAccess ( $ user , $ functionName , $ contentObject , $ languageCode , $ comment = null , $ scope = null , $ node = null ) { $ result = $ user -> hasAccessTo ( self :: $ moduleName , $ functionName ) ; if ( $ result [ 'accessWord' ] !== 'limited' ) { $ return = ( $ result [ 'accessWord' ] === ...
check if the user has Acceess to the object with limitation of class section owner language nodes subtrees