idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
55,000
|
public function setTemplate ( $ type , $ template ) { if ( ! is_callable ( $ template ) ) { $ template = ( string ) $ template ; } $ this -> templates [ $ type ] = $ template ; }
|
Defines a template for the given media type .
|
55,001
|
protected function render ( $ type , array $ data = [ ] ) { $ templateName = empty ( $ data [ 'title' ] ) ? $ type . '_notitle' : $ type ; $ template = $ this -> templates [ $ templateName ] ; if ( is_callable ( $ template ) ) { return $ template ( $ data ) ; } else { $ replace = array ( ) ; foreach ( $ data as $ key => $ value ) { $ replace [ '{' . $ key . '}' ] = $ key != 'html' ? $ this -> escapeHtml ( $ value ) : ( string ) $ value ; } return strtr ( $ template , $ replace ) ; } }
|
Renders the HTML for the given media type .
|
55,002
|
protected function parseJson ( $ data ) { $ result = json_decode ( trim ( $ data ) , false ) ; return json_last_error ( ) == JSON_ERROR_NONE ? $ result : false ; }
|
Parses a JSON response .
|
55,003
|
public function generate_class ( ) { function gen_spaces ( $ amount ) { $ spaces = '' ; for ( $ i = 0 ; $ i < $ amount ; $ i ++ ) { $ spaces .= ' ' ; } return $ spaces ; } if ( empty ( $ this -> table_model ) ) { return false ; } $ this -> init ( ) ; $ this -> generate_class_definition ( ) ; if ( strpos ( $ this -> class_name , '_' ) !== false ) { $ tmp = explode ( '_' , $ this -> class_name ) ; foreach ( $ tmp as $ key => $ part ) { $ tmp [ $ key ] = ucfirst ( strtolower ( $ part ) ) ; } $ this -> class_name = implode ( '_' , $ tmp ) ; } $ this -> tpl_replacements [ 'class_name' ] = $ this -> class_name ; $ file = new File ( ) ; $ file -> open ( $ this -> tpl_path ) ; $ this -> generated_code = $ file -> read ( ) ; foreach ( $ this -> tpl_replacements as $ pattern => $ value ) { if ( ! is_string ( $ value ) ) continue ; $ pattern = '#' . strtoupper ( $ pattern ) . '#' ; $ this -> generated_code = str_replace ( $ pattern , $ value , $ this -> generated_code ) ; } $ this -> generated_code = str_replace ( "\t" , gen_spaces ( self :: SPACE_AMOUNT ) , $ this -> generated_code ) ; return true ; }
|
major class generation body needs to be redone i am sure but for the beta this will work
|
55,004
|
public function generate_class_definition ( ) { $ this -> tpl_replacements [ 'class_definition' ] = '' ; $ this -> tpl_replacements [ 'class_definition_list' ] = '' ; if ( $ this -> is_final == true ) { $ this -> tpl_replacements [ 'class_definition' ] .= 'final ' ; } if ( $ this -> is_abstract == true ) { $ this -> tpl_replacements [ 'class_definition' ] .= 'abstract ' ; } $ this -> tpl_replacements [ 'class_definition' ] .= 'class ' . ucfirst ( strtolower ( $ this -> class_name ) ) ; $ this -> tpl_replacements [ 'class_definition_list' ] .= 'class ' . ucfirst ( strtolower ( $ this -> class_name ) ) . 'List' ; if ( empty ( $ this -> extend_class ) && empty ( $ this -> implement_interface ) ) return true ; if ( ! empty ( $ this -> extend_class ) ) { $ this -> tpl_replacements [ 'class_definition' ] .= ' extends ' . ucfirst ( strtolower ( $ this -> extend_class ) ) ; $ this -> tpl_replacements [ 'class_definition_list' ] .= ' extends ' . ucfirst ( strtolower ( $ this -> extend_class ) ) . 'List' ; } if ( ! empty ( $ this -> implement_interface ) ) { $ this -> tpl_replacements [ 'class_definition' ] .= ' implements ' . implode ( ',' , $ this -> implement_interface ) ; $ this -> tpl_replacements [ 'class_definition_list' ] .= ' implements ' . implode ( 'List,' , $ this -> implement_interface ) . 'List' ; } return true ; }
|
generates the class definiton
|
55,005
|
public function get_table_short_tag ( ) { if ( empty ( $ this -> table_name ) ) return false ; $ tmp = null ; if ( strpos ( $ this -> table_name , '_' ) !== false ) { $ tmp = explode ( '_' , $ this -> table_name ) ; } if ( ! empty ( $ tmp ) ) { foreach ( $ tmp as $ val ) { $ this -> table_short_tag .= strtolower ( substr ( $ val , 0 , 1 ) ) ; } } else { $ this -> table_short_tag .= strtolower ( substr ( $ this -> table_name , 0 , 1 ) ) ; } $ this -> tpl_replacements [ 'table_short_tag' ] = $ this -> table_short_tag ; return true ; }
|
get table short tag parses based on the table name the first character or based on the underscores for example PX_GALLERY - > pg CUSTOMER - > c
|
55,006
|
protected function validateLimitsUpload ( ) { $ files = $ this -> request -> file ( 'files' ) ; if ( ! gplcart_file_multi_upload ( $ files ) ) { return false ; } if ( $ this -> user -> isSuperadmin ( ) ) { return true ; } $ role_id = $ this -> user -> getRoleId ( ) ; $ settings = $ this -> module -> getSettings ( 'file_manager' ) ; $ maxfilesize = 0 ; $ extensions = array ( ) ; if ( ! empty ( $ settings [ 'filesize_limit' ] [ $ role_id ] ) ) { $ maxfilesize = $ settings [ 'filesize_limit' ] [ $ role_id ] ; } if ( ! empty ( $ settings [ 'extension_limit' ] [ $ role_id ] ) ) { $ extensions = $ settings [ 'extension_limit' ] [ $ role_id ] ; } $ errors = array ( ) ; foreach ( $ files as $ file ) { if ( $ maxfilesize && filesize ( $ file [ 'tmp_name' ] ) > $ maxfilesize ) { unlink ( $ file [ 'tmp_name' ] ) ; $ errors [ ] = "{$file['name']}: " . $ this -> translation -> text ( 'File size exceeds %num bytes' , array ( '%num' => $ maxfilesize ) ) ; continue ; } if ( $ extensions && ! in_array ( pathinfo ( $ file [ 'name' ] , PATHINFO_EXTENSION ) , $ extensions ) ) { unlink ( $ file [ 'tmp_name' ] ) ; $ errors [ ] = "{$file['name']}: " . $ this -> translation -> text ( 'Unsupported file extension' ) ; } } if ( empty ( $ errors ) ) { return true ; } $ this -> setError ( 'files' , implode ( '<br>' , $ errors ) ) ; return false ; }
|
Validates file limits
|
55,007
|
protected function validateFileUpload ( ) { if ( $ this -> isError ( ) ) { return null ; } $ submitted_files = $ this -> getSubmitted ( 'files' ) ; $ file = reset ( $ submitted_files ) ; $ request_files = $ this -> request -> file ( 'files' ) ; if ( empty ( $ request_files [ 'name' ] [ 0 ] ) ) { $ this -> setErrorRequired ( 'files' , $ this -> translation -> text ( 'Files' ) ) ; return false ; } $ result = $ this -> file_transfer -> uploadMultiple ( $ request_files , false , $ file -> getRealPath ( ) ) ; $ this -> setSubmitted ( 'uploaded' , $ result ) ; return true ; }
|
Validates uploaded files
|
55,008
|
public static function price ( $ value ) { $ bool = preg_match ( self :: $ regularExpressions [ 'price' ] , $ value ) ; if ( ! $ bool ) { return false ; } return true ; }
|
check price format
|
55,009
|
public static function postcode ( $ value ) { $ bool = preg_match ( self :: $ regularExpressions [ 'postcode' ] , $ value ) ; if ( ! $ bool ) { return false ; } return true ; }
|
check post code format
|
55,010
|
public static function nip ( $ value ) { if ( ! empty ( $ value ) ) { $ weights = [ 6 , 5 , 7 , 2 , 3 , 4 , 5 , 6 , 7 ] ; $ nip = preg_replace ( '#[\\s-]#' , '' , $ value ) ; return self :: processNip ( $ nip , $ weights ) ; } return false ; }
|
check NIP number format
|
55,011
|
public static function stringLength ( $ value , $ min = null , $ max = null ) { $ length = mb_strlen ( $ value ) ; return self :: range ( $ length , $ min , $ max ) ; }
|
check string length possibility to set range
|
55,012
|
public static function range ( $ value , $ min = null , $ max = null ) { list ( $ value , $ min , $ max ) = self :: getProperValues ( $ value , $ min , $ max ) ; return ! ( ( $ min !== null && $ min > $ value ) || ( $ max !== null && $ max < $ value ) ) ; }
|
check range on numeric values allows to check decimal hex octal an binary values
|
55,013
|
public static function regon ( $ value ) { $ value = preg_replace ( '#[\\s-]#' , '' , $ value ) ; $ length = strlen ( $ value ) ; if ( ! ( $ length === 9 || $ length === 14 ) ) { return false ; } $ arrSteps = [ 8 , 9 , 2 , 3 , 4 , 5 , 6 , 7 ] ; $ intSum = 0 ; foreach ( $ arrSteps as $ key => $ step ) { $ intSum += $ step * $ value [ $ key ] ; } $ int = $ intSum % 11 ; $ intControlNr = ( $ int === 10 ) ? 0 : $ int ; return ( string ) $ intControlNr === $ value [ 8 ] ; }
|
check REGON number format
|
55,014
|
public static function nrb ( $ value ) { $ iNRB = preg_replace ( '#[\\s- ]#' , '' , $ value ) ; if ( strlen ( $ iNRB ) !== 26 ) { return false ; } $ iNRB .= '2521' ; $ iNRB = substr ( $ iNRB , 2 ) . substr ( $ iNRB , 0 , 2 ) ; $ iNumSum = 0 ; $ aNumWeight = [ 1 , 10 , 3 , 30 , 9 , 90 , 27 , 76 , 81 , 34 , 49 , 5 , 50 , 15 , 53 , 45 , 62 , 38 , 89 , 17 , 73 , 51 , 25 , 56 , 75 , 71 , 31 , 19 , 93 , 57 ] ; foreach ( $ aNumWeight as $ key => $ num ) { $ iNumSum += $ num * $ iNRB [ 29 - $ key ] ; } return $ iNumSum % 97 === 1 ; }
|
check account number format in NRB standard
|
55,015
|
public static function iban ( $ value ) { $ values = '' ; $ mod = 0 ; $ remove = [ ' ' , '-' , '_' , '.' , ',' , '/' , '|' ] ; $ cleared = str_replace ( $ remove , '' , $ value ) ; $ temp = strtoupper ( $ cleared ) ; $ firstChar = $ temp { 0 } <= '9' ; $ secondChar = $ temp { 1 } <= '9' ; if ( $ firstChar && $ secondChar ) { $ temp = 'PL' . $ temp ; } $ temp = substr ( $ temp , 4 ) . substr ( $ temp , 0 , 4 ) ; foreach ( str_split ( $ temp ) as $ val ) { $ values .= self :: IBAN_CHARS [ $ val ] ; } $ sum = strlen ( $ values ) ; for ( $ i = 0 ; $ i < $ sum ; $ i += 6 ) { $ separated = $ mod . substr ( $ values , $ i , 6 ) ; $ mod = ( int ) ( $ separated ) % 97 ; } return $ mod === 1 ; }
|
check account number format in IBAN standard
|
55,016
|
public static function url ( $ url , $ type = null ) { switch ( $ type ) { case 1 : $ type = self :: $ regularExpressions [ 'url_extend' ] ; break ; case 2 : $ type = self :: $ regularExpressions [ 'url_full' ] ; break ; default : $ type = self :: $ regularExpressions [ 'url' ] ; break ; } $ bool = preg_match ( $ type , $ url ) ; if ( ! $ bool ) { return false ; } return true ; }
|
check URL address
|
55,017
|
public static function step ( $ value , $ step , $ default = 0 ) { if ( ! self :: valid ( $ step , 'rational' ) || ! self :: valid ( $ default , 'rational' ) || ! self :: valid ( $ value , 'rational' ) ) { return false ; } $ check = ( abs ( $ value ) - abs ( $ default ) ) % $ step ; if ( $ check ) { return false ; } return true ; }
|
check step of value
|
55,018
|
public function run ( ) { DB :: beginTransaction ( ) ; try { $ this -> down ( ) ; $ this -> addNotification ( [ 'category' => 'default' , 'severity' => 'high' , 'type' => 'email' , 'event' => 'email.sample-module-notification' , 'contents' => [ 'en' => [ 'title' => 'Sample Email Template' , 'content' => file_get_contents ( __DIR__ . '/../../views/notification/module_sample_notification.twig' ) ] , ] ] ) ; } catch ( Exception $ ex ) { DB :: rollback ( ) ; throw $ ex ; } DB :: commit ( ) ; }
|
Creates module notifications
|
55,019
|
protected function makeIndexDDL ( $ type , $ name = null ) { return implode ( ' ' , array_filter ( [ strtoupper ( $ type ) , $ name !== null ? '`' . $ name . '`' : null , $ this -> makeIndexedColumnsDDL ( ) , $ this -> hasComment ( ) ? "COMMENT '" . addslashes ( $ this -> getComment ( ) ) . "'" : null ] ) ) ; }
|
Makes the DDL statement for the index .
|
55,020
|
protected function makeIndexedColumnsDDL ( ) { $ columnDDLs = [ ] ; foreach ( $ this -> indexedColumns as $ indexedColumn ) { $ columnDDLs [ ] = '`' . $ indexedColumn -> getColumnName ( ) . '`' . ( $ indexedColumn -> hasLength ( ) ? '(' . $ indexedColumn -> getLength ( ) . ')' : null ) . ( $ indexedColumn -> hasCollation ( ) ? ' ' . strtoupper ( $ indexedColumn -> getCollation ( ) ) : null ) ; } return '(' . implode ( ',' , $ columnDDLs ) . ')' ; }
|
Makes the column portion of the index DDL statement .
|
55,021
|
public function prepare ( ) { if ( empty ( $ this -> targetBundle ) && empty ( $ this -> bundleExtensionDir ) ) { throw new \ RuntimeException ( sprintf ( "Runtime Error: Any Bundle was selected for ui generation." ) ) ; } $ this -> reader = $ this -> readerFactory -> load ( $ this -> metaFile ) ; $ elementType = $ this -> reader -> getElement ( ) -> getXtype ( ) ; $ bundleDir = empty ( $ this -> targetBundle ) ? $ this -> bundleExtensionDir . DS . $ elementType . DS : $ this -> bundleExtensionDir . DS . $ this -> targetBundle . DS . $ elementType . DS ; if ( ! file_exists ( $ bundleDir . 'components.genscript' ) && ! file_exists ( $ bundleDir . 'mapping.php' ) ) { $ bundleDir = __DIR__ . DS . 'bundle' . DS . $ this -> targetBundle . DS . $ elementType . DS ; if ( ! file_exists ( $ bundleDir . 'components.genscript' ) && ! file_exists ( $ bundleDir . 'mapping.php' ) ) { throw new \ Exception ( sprintf ( "Error: Bundle '%s' does not exist!." , $ this -> targetBundle ) ) ; } } $ genscriptFilename = $ bundleDir . 'components.genscript' ; $ mappingFilename = $ bundleDir . 'mapping.php' ; if ( ! file_exists ( $ genscriptFilename ) ) { throw new \ Exception ( sprintf ( "Error: genscript file for '%s' bundle is missing." , $ this -> targetBundle ) ) ; } if ( ! file_exists ( $ genscriptFilename ) ) { throw new \ Exception ( sprintf ( "Error: mapping file for '%s' bundle is missing." , $ this -> targetBundle ) ) ; } if ( ! file_exists ( $ this -> metaFile ) ) { throw new \ Exception ( sprintf ( "Error: meta file '%s' does not exist." , $ this -> metaFile ) ) ; } $ this -> parser -> setScriptFile ( $ genscriptFilename ) ; $ this -> parser -> parse ( ) ; $ this -> mapping = file_exists ( $ mappingFilename ) ? include ( $ mappingFilename ) : null ; }
|
Prepare all engine dependencies
|
55,022
|
protected function mapElementInformation ( Element $ widget ) { $ mapping = $ this -> mapping [ 'widget_mapping' ] ; $ widgetInfo = $ widget -> getInfo ( ) ; if ( ! array_key_exists ( $ widget -> getXtype ( ) , $ mapping ) ) { return $ widgetInfo ; } $ overrides = $ mapping [ $ widget -> getXtype ( ) ] ; foreach ( $ overrides as $ attributeName => $ attribInfo ) { $ isAttribute = false ; if ( array_key_exists ( $ attributeName , $ widgetInfo ) ) { $ value = $ widgetInfo [ $ attributeName ] ; } elseif ( array_key_exists ( $ attributeName , $ widgetInfo [ 'attributes' ] ) ) { $ value = $ widgetInfo [ 'attributes' ] [ $ attributeName ] ; $ isAttribute = true ; } else { continue ; } if ( array_key_exists ( 'name' , $ attribInfo ) ) { unset ( $ widgetInfo [ $ attributeName ] ) ; $ attributeName = $ this -> processMappedWidgetInfo ( $ widget , $ attribInfo [ 'name' ] , $ value ) ; } if ( array_key_exists ( 'value' , $ attribInfo ) ) { $ widgetInfo [ $ attributeName ] = $ this -> processMappedWidgetInfo ( $ widget , $ attribInfo [ 'value' ] , $ value ) ; } if ( $ isAttribute ) { $ widgetInfo [ 'attributes' ] [ $ attributeName ] = $ widgetInfo [ $ attributeName ] ; } } return $ widgetInfo ; }
|
Map the widget attributes & properties to a determined UI language
|
55,023
|
private function processMappedWidgetInfo ( WidgetInterface $ widget , $ info , $ value ) { if ( is_string ( $ info ) ) { $ result = $ info ; } elseif ( is_array ( $ info ) ) { $ strValue = self :: toString ( $ value ) ; if ( array_key_exists ( $ strValue , $ info ) ) { $ result = $ info [ $ strValue ] ; } else { $ result = $ value ; } } elseif ( $ info instanceof \ Closure ) { $ result = $ info ( $ widget ) ; } else { throw new \ RuntimeException ( sprintf ( "Runtime Error: invalid data type '%s' for widget attribute" , gettype ( $ value ) ) ) ; } return $ result ; }
|
Process the mapped widget information
|
55,024
|
public function setState ( $ state ) { $ oldState = $ this -> getState ( ) ; if ( $ oldState === $ state ) { return $ this ; } $ this -> getLogger ( ) -> debug ( 'Changing state from: ' . $ oldState . ' to: ' . $ state . '.' ) ; $ this -> state = $ state ; return $ this ; }
|
Set the current state of this Worker .
|
55,025
|
public function setActions ( $ actions ) { if ( $ this -> getState ( ) != self :: INIT ) { throw new \ RuntimeException ( 'Invalid state.' ) ; } if ( count ( $ actions ) == 0 ) { $ this -> setState ( self :: INVALID ) ; throw new \ RuntimeException ( 'No actions given.' ) ; } $ this -> actions = array_combine ( $ actions , $ actions ) ; $ this -> setState ( self :: REGISTER ) ; return $ this ; }
|
Set the actions that this worker can handle .
|
55,026
|
public function setResult ( $ requestId , $ result ) { $ this -> requestId = $ requestId ; $ this -> result = $ result ; $ this -> setState ( self :: RESULT_AVAILABLE ) ; }
|
Set the result for the currently handled request .
|
55,027
|
public function cleanup ( ) { $ this -> requestId = null ; $ this -> result = null ; $ this -> setState ( self :: READY ) ; }
|
Reset this worker to get ready for another Request .
|
55,028
|
public function onServiceDown ( ) { if ( ! $ this -> serviceRunning ) { return ; } $ this -> getLogger ( ) -> debug ( 'Service is no longer alive.' ) ; $ this -> serviceRunning = false ; $ this -> shutdown ( ) ; }
|
Let the worker know the service is down .
|
55,029
|
protected function startSession ( $ session ) { if ( is_bool ( $ session ) || is_string ( $ session ) ) { if ( $ session === false || isset ( $ _SESSION ) ) { return ; } if ( is_string ( $ session ) ) { session_name ( $ session ) ; } return session_start ( ) ; } $ prefix = 'Session variable must be of type \'boolean\' or \'string\', \'' ; throw new \ InvalidArgumentException ( $ prefix . gettype ( $ session ) . '\' given.' ) ; }
|
Start a session or abort if set .
|
55,030
|
private function castValue ( $ value ) { foreach ( [ '/^-?\d+$/' => function ( $ value ) { return ( int ) $ value ; } , '/^-?\d+\.\d+$/' => function ( $ value ) { return ( float ) $ value ; } , '/^(?:true|false)$/' => function ( $ value ) { return filter_var ( $ value , \ FILTER_VALIDATE_BOOLEAN ) ; } , ] as $ format => $ castFunction ) { if ( preg_match ( $ format , $ value ) ) { return $ castFunction ( $ value ) ; } } return $ value ; }
|
Casts the passed string value to its supposed expected type .
|
55,031
|
public function generate ( ) : string { try { $ token = random_bytes ( 32 ) ; } catch ( \ Throwable $ e ) { throw new InsufficientStrengthException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } return $ token ; }
|
Generates a token
|
55,032
|
public static function with ( callable $ callable , int $ options = 0 ) { $ enabled = self :: hasXdebug ( ) ; $ inherited = self :: isEnabled ( ) ; if ( $ enabled && ! $ inherited ) { xdebug_start_code_coverage ( $ options ) ; } $ result = $ callable ( ) ; if ( $ enabled && ! $ inherited ) { xdebug_stop_code_coverage ( false ) ; } return $ result ; }
|
Executes a callable with code coverage enabled .
|
55,033
|
public function injectViewModelLayout ( MvcEvent $ e ) { $ model = $ e -> getResult ( ) ; if ( ! Share :: isOnAdmin ( ) || ! $ model instanceof ViewModel ) { return false ; } $ response = $ e -> getResponse ( ) ; if ( $ response -> getStatusCode ( ) != 400 && $ response -> getStatusCode ( ) != 500 ) { $ template = $ model -> getTemplate ( ) ; $ template = 'admin' . '/' . $ template ; $ model -> setTemplate ( $ template ) ; } }
|
Set admin prefix to viewModel Layouts
|
55,034
|
final public function parse ( \ Gettext \ Translations $ translations , $ concrete5version ) { $ fqClassName = $ this -> getClassNameForExtractor ( ) ; if ( is_string ( $ fqClassName ) && ( $ fqClassName !== '' ) && class_exists ( $ fqClassName , true ) && method_exists ( $ fqClassName , 'exportTranslations' ) ) { $ translations -> mergeWith ( call_user_func ( $ fqClassName . '::exportTranslations' ) ) ; } else { $ this -> parseManual ( $ translations , $ concrete5version ) ; } }
|
Extract specific items from the running concrete5 .
|
55,035
|
final protected function addTranslation ( \ Gettext \ Translations $ translations , $ string , $ context = '' ) { if ( is_string ( $ string ) && ( $ string !== '' ) ) { $ translations -> insert ( $ context , $ string ) ; } }
|
Adds a translation to the \ Gettext \ Translations object .
|
55,036
|
final public function getDynamicItemsParserHandler ( ) { $ chunks = explode ( '\\' , get_class ( $ this ) ) ; return \ C5TL \ Parser :: handlifyString ( end ( $ chunks ) ) ; }
|
Returns the handle of the DynamicItem handle .
|
55,037
|
public function send ( $ prv_request , $ no_add_tags = false ) { if ( $ no_add_tags ) { return $ this -> client -> sendRequest ( $ prv_request ) ; } return $ this -> client -> sendRequest ( $ this -> addProvision ( $ this -> addStore ( $ prv_request ) ) ) ; }
|
Send a remote provision request
|
55,038
|
private function normalizarUri ( $ uri ) { if ( ( $ temp = strpos ( $ uri , '?' ) ) !== false ) { $ uri = substr ( $ uri , 0 , $ temp ) ; } if ( strpos ( $ uri , '/' ) !== 0 ) { $ uri = '/' . $ uri ; } if ( $ uri !== '/' && substr ( $ uri , - 1 , 1 ) == '/' ) { $ uri = substr ( $ uri , 0 , - 1 ) ; } return $ uri ; }
|
Convierte el URI en un formato adecuado para trabajar .
|
55,039
|
public function agregarRuta ( $ metodo , $ ruta , $ accion , array $ parametros = null , $ estado_http = 200 ) { $ ruta = $ this -> normalizarUri ( $ ruta ) ; $ partes = explode ( '/' , trim ( $ ruta , '/ ' ) ) ; $ conteo_partes = count ( $ partes ) ; $ rama_actual = & $ this -> arbol_rutas ; $ es_simple = true ; if ( ! ( $ conteo_partes === 1 && $ partes [ 0 ] === '' ) ) { for ( $ i = 0 ; $ i < $ conteo_partes ; $ i ++ ) { if ( substr ( $ partes [ $ i ] , 0 , 1 ) == ':' ) { $ es_simple = false ; if ( ! isset ( $ rama_actual [ 'ramas' ] [ '*' ] ) ) { $ rama_actual [ 'ramas' ] [ '*' ] = [ 'ramas' => [ ] , 'nombre' => substr ( $ partes [ $ i ] , 1 ) ] ; } $ rama_actual = & $ rama_actual [ 'ramas' ] [ '*' ] ; } else { if ( ! isset ( $ rama_actual [ 'ramas' ] [ $ partes [ $ i ] ] ) ) { $ rama_actual [ 'ramas' ] [ $ partes [ $ i ] ] = [ 'ramas' => [ ] ] ; } $ rama_actual = & $ rama_actual [ 'ramas' ] [ $ partes [ $ i ] ] ; } } } $ metodo = ( array ) $ metodo ; $ rama_actual [ 'ruta' ] = $ ruta ; if ( ! isset ( $ rama_actual [ 'x' ] ) ) { $ rama_actual [ 'x' ] = [ ] ; } foreach ( $ metodo as $ m ) { if ( $ es_simple ) { $ this -> rutas_simples [ $ ruta ] [ strtoupper ( $ m ) ] [ 'accion' ] = $ accion ; $ this -> rutas_simples [ $ ruta ] [ strtoupper ( $ m ) ] [ 'estado_http' ] = $ estado_http ; if ( isset ( $ parametros ) ) { $ this -> rutas_simples [ $ ruta ] [ strtoupper ( $ m ) ] [ 'parametros' ] = $ parametros ; } } else { $ rama_actual [ 'x' ] [ strtoupper ( $ m ) ] [ 'accion' ] = $ accion ; $ rama_actual [ 'x' ] [ strtoupper ( $ m ) ] [ 'estado_http' ] = $ estado_http ; if ( isset ( $ parametros ) ) { $ rama_actual [ 'x' ] [ strtoupper ( $ m ) ] [ 'parametros' ] = $ parametros ; } } } unset ( $ rama_actual ) ; }
|
Agrega una nueva ruta al arbol de rutas .
|
55,040
|
public function agregarRutaEstadoHttp ( $ estado_http , $ accion ) { $ this -> rutas_simples [ $ estado_http ] [ 'accion' ] = $ accion ; $ this -> rutas_simples [ $ estado_http ] [ 'estado_http' ] = $ estado_http ; }
|
Agrega una nueva ruta sobre Estado HTTP .
|
55,041
|
public function importarRutas ( array $ rutas ) { foreach ( $ rutas as $ ruta ) { if ( isset ( $ ruta [ 4 ] ) ) { $ this -> agregarRuta ( $ ruta [ 0 ] , $ ruta [ 1 ] , $ ruta [ 2 ] , $ ruta [ 3 ] , $ ruta [ 4 ] ) ; } elseif ( isset ( $ ruta [ 3 ] ) ) { $ this -> agregarRuta ( $ ruta [ 0 ] , $ ruta [ 1 ] , $ ruta [ 2 ] , $ ruta [ 3 ] ) ; } elseif ( is_int ( $ ruta [ 0 ] ) ) { $ this -> agregarRutaEstadoHttp ( $ ruta [ 0 ] , $ ruta [ 1 ] ) ; } else { $ this -> agregarRuta ( $ ruta [ 0 ] , $ ruta [ 1 ] , $ ruta [ 2 ] ) ; } } }
|
Importa las rutas desde un arreglo .
|
55,042
|
public function getSlug ( ) { if ( $ this -> package -> getVendor ( ) == 'keeko' ) { return $ this -> package -> getName ( ) ; } return str_replace ( '/' , '.' , $ this -> package -> getFullName ( ) ) ; }
|
Returns the slug for this module
|
55,043
|
public function addAction ( ActionSchema $ action ) { $ action -> setPackage ( $ this -> package ) ; $ this -> actions -> set ( $ action -> getName ( ) , $ action ) ; return $ this ; }
|
Adds an action
|
55,044
|
public static function processPcreError ( ) { if ( preg_last_error ( ) != PREG_NO_ERROR ) { switch ( preg_last_error ( ) ) { case PREG_INTERNAL_ERROR : throw new Exception ( 'PCRE PREG internal error' ) ; case PREG_BACKTRACK_LIMIT_ERROR : throw new Exception ( 'PCRE PREG Backtrack limit error' ) ; case PREG_RECURSION_LIMIT_ERROR : throw new Exception ( 'PCRE PREG Recursion limit error' ) ; case PREG_BAD_UTF8_ERROR : throw new Exception ( 'PCRE PREG Bad UTF-8 error' ) ; case PREG_BAD_UTF8_OFFSET_ERROR : throw new Exception ( 'PCRE PREG Bad UTF-8 offset error' ) ; } } }
|
Check PCRE PREG error and throw exception
|
55,045
|
public function push ( Notification $ notification ) { $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , self :: ENDPOINT ) ; curl_setopt ( $ curl , CURLOPT_USERAGENT , self :: USER_AGENT ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ this -> createPostFields ( $ notification ) ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_exec ( $ curl ) ; $ info = curl_getinfo ( $ curl ) ; curl_close ( $ curl ) ; switch ( $ info [ 'http_code' ] ) { case 201 : return true ; case 401 : throw new InvalidAccessTokenException ( 'Not Authorized: Access token not recognized' ) ; case 404 : throw new NoDeviceAssociatedException ( 'Not Found: No device associated with provided access token' ) ; } return false ; }
|
Push notification to Boxcar
|
55,046
|
private function createPostFields ( Notification $ notification ) { $ data = [ 'user_credentials' => $ this -> accessToken , 'notification[title]' => $ notification -> getTitle ( ) , 'notification[long_message]' => $ notification -> getContent ( ) ] ; if ( ! empty ( $ this -> getSourceName ( ) ) ) { $ data [ 'notification[source_name]' ] = $ this -> getSourceName ( ) ; } if ( ! empty ( $ this -> getIconUrl ( ) ) ) { $ data [ 'notification[icon_url]' ] = $ this -> getIconUrl ( ) ; } if ( ! empty ( $ this -> getSound ( ) ) ) { $ data [ 'notification[sound]' ] = $ this -> getSound ( ) ; } if ( ! empty ( $ this -> getOpenUrl ( ) ) ) { $ data [ 'notification[open_url]' ] = $ this -> getOpenUrl ( ) ; } return $ data ; }
|
Create post fields for API request based on provided notification object
|
55,047
|
public function find ( $ typeKey , $ identifier ) { if ( true === $ this -> cache -> has ( $ typeKey , $ identifier ) ) { return $ this -> cache -> get ( $ typeKey , $ identifier ) ; } $ record = $ this -> retrieveRecord ( $ typeKey , $ identifier ) ; return $ this -> loadModel ( $ typeKey , $ record ) ; }
|
Finds a single record from the persistence layer by type and id . Will return a Model object if found or throw an exception if not .
|
55,048
|
public function findQuery ( $ typeKey , array $ criteria , array $ fields = [ ] , array $ sort = [ ] , $ offset = 0 , $ limit = 0 ) { $ metadata = $ this -> getMetadataForType ( $ typeKey ) ; $ persister = $ this -> getPersisterFor ( $ typeKey ) ; $ this -> dispatcher -> dispatch ( Events :: preQuery , new PreQueryArguments ( $ metadata , $ this , $ persister , $ criteria ) ) ; $ recordSet = $ persister -> query ( $ metadata , $ this , $ criteria , $ fields , $ sort , $ offset , $ limit ) ; $ models = $ this -> loadModels ( $ typeKey , $ recordSet ) ; return new Collections \ Collection ( $ metadata , $ this , $ models , $ recordSet -> totalCount ( ) ) ; }
|
Queries records based on a provided set of criteria .
|
55,049
|
public function delete ( $ typeKey , $ identifier ) { $ model = $ this -> find ( $ typeKey , $ identifier ) ; return $ model -> delete ( ) -> save ( ) ; }
|
Deletes a model . The moel will be immediately deleted once retrieved .
|
55,050
|
public function retrieveRecord ( $ typeKey , $ identifier ) { $ persister = $ this -> getPersisterFor ( $ typeKey ) ; $ record = $ persister -> retrieve ( $ this -> getMetadataForType ( $ typeKey ) , $ identifier , $ this ) -> getSingleResult ( ) ; if ( null === $ record ) { throw StoreException :: recordNotFound ( $ typeKey , $ identifier ) ; } return $ record ; }
|
Retrieves a RecordSet object from the persistence layer .
|
55,051
|
public function retrieveRecords ( $ typeKey , array $ identifiers , array $ fields = [ ] , array $ sort = [ ] , $ offset = 0 , $ limit = 0 ) { $ persister = $ this -> getPersisterFor ( $ typeKey ) ; return $ persister -> all ( $ this -> getMetadataForType ( $ typeKey ) , $ this , $ identifiers , $ fields , $ sort , $ offset , $ limit ) ; }
|
Retrieves multiple Record objects from the persistence layer .
|
55,052
|
public function retrieveInverseRecords ( $ ownerTypeKey , $ relTypeKey , array $ identifiers , $ inverseField ) { $ persister = $ this -> getPersisterFor ( $ relTypeKey ) ; return $ persister -> inverse ( $ this -> getMetadataForType ( $ ownerTypeKey ) , $ this -> getMetadataForType ( $ relTypeKey ) , $ this , $ identifiers , $ inverseField ) ; }
|
Retrieves multiple Record objects from the persistence layer for an inverse relationship .
|
55,053
|
protected function dispatchLifecycleEvent ( $ eventName , Model $ model ) { $ args = new ModelLifecycleArguments ( $ model ) ; $ this -> dispatcher -> dispatch ( $ eventName , $ args ) ; return $ this ; }
|
Dispatches a model lifecycle event via the event dispatcher .
|
55,054
|
public function loadProxyModel ( $ relatedTypeKey , $ identifier ) { $ identifier = $ this -> convertId ( $ identifier ) ; if ( true === $ this -> cache -> has ( $ relatedTypeKey , $ identifier ) ) { return $ this -> cache -> get ( $ relatedTypeKey , $ identifier ) ; } $ metadata = $ this -> getMetadataForType ( $ relatedTypeKey ) ; $ model = new Model ( $ metadata , $ identifier , $ this ) ; $ this -> cache -> push ( $ model ) ; return $ model ; }
|
Loads a has - one model proxy .
|
55,055
|
public function createInverseCollection ( RelationshipMetadata $ relMeta , Model $ owner ) { $ metadata = $ this -> getMetadataForType ( $ relMeta -> getEntityType ( ) ) ; return new Collections \ InverseCollection ( $ metadata , $ this , $ owner , $ relMeta -> inverseField ) ; }
|
Loads a has - many inverse model collection .
|
55,056
|
public function createEmbedCollection ( EmbeddedPropMetadata $ embededPropMeta , array $ embedDocs = null ) { if ( empty ( $ embedDocs ) ) { $ embedDocs = [ ] ; } if ( false === $ this -> isSequentialArray ( $ embedDocs ) ) { throw StoreException :: badRequest ( sprintf ( 'Improper has-many data detected for embed "%s" - a sequential array is required.' , $ embededPropMeta -> getKey ( ) ) ) ; } $ embeds = [ ] ; foreach ( $ embedDocs as $ embedDoc ) { $ embeds [ ] = $ this -> loadEmbed ( $ embededPropMeta -> embedMeta , $ embedDoc ) ; } return new Collections \ EmbedCollection ( $ embededPropMeta -> embedMeta , $ this , $ embeds ) ; }
|
Loads a has - many embed collection .
|
55,057
|
public function createCollection ( RelationshipMetadata $ relMeta , array $ references = null ) { $ metadata = $ this -> getMetadataForType ( $ relMeta -> getEntityType ( ) ) ; if ( empty ( $ references ) ) { $ references = [ ] ; } if ( false === $ this -> isSequentialArray ( $ references ) ) { throw StoreException :: badRequest ( sprintf ( 'Improper has-many data detected for relationship "%s" - a sequential array is required.' , $ relMeta -> getKey ( ) ) ) ; } $ models = [ ] ; foreach ( $ references as $ reference ) { $ models [ ] = $ this -> loadProxyModel ( $ reference [ 'type' ] , $ reference [ 'id' ] ) ; } return new Collections \ Collection ( $ metadata , $ this , $ models , count ( $ models ) ) ; }
|
Loads a has - many model collection .
|
55,058
|
public function getPersisterFor ( $ typeKey ) { $ metadata = $ this -> getMetadataForType ( $ typeKey ) ; return $ this -> storageManager -> getPersister ( $ metadata -> persistence -> getKey ( ) ) ; }
|
Determines the persister to use for the provided model key .
|
55,059
|
public function commit ( Model $ model ) { $ this -> dispatchLifecycleEvent ( Events :: preCommit , $ model ) ; if ( false === $ this -> shouldCommit ( $ model ) ) { return $ model ; } if ( true === $ model -> getState ( ) -> is ( 'new' ) ) { $ this -> doCommitCreate ( $ model ) ; } elseif ( true === $ model -> getState ( ) -> is ( 'deleting' ) ) { $ this -> doCommitDelete ( $ model ) ; } elseif ( true === $ model -> isDirty ( ) ) { $ this -> doCommitUpdate ( $ model ) ; } else { throw new \ RuntimeException ( 'Unable to commit model.' ) ; } $ this -> dispatchLifecycleEvent ( Events :: postCommit , $ model ) ; return $ model ; }
|
Commits a model by persisting it to the database .
|
55,060
|
private function doCommitCreate ( Model $ model ) { $ this -> dispatchLifecycleEvent ( Events :: preCreate , $ model ) ; $ this -> getPersisterFor ( $ model -> getType ( ) ) -> create ( $ model ) ; $ model -> getState ( ) -> setNew ( false ) ; $ model -> reload ( ) ; $ this -> dispatchLifecycleEvent ( Events :: postCreate , $ model ) ; return $ model ; }
|
Performs a Model creation commit and persists to the database .
|
55,061
|
private function doCommitDelete ( Model $ model ) { $ this -> dispatchLifecycleEvent ( Events :: preDelete , $ model ) ; $ this -> getPersisterFor ( $ model -> getType ( ) ) -> delete ( $ model ) ; $ model -> getState ( ) -> setDeleted ( ) ; $ this -> dispatchLifecycleEvent ( Events :: postDelete , $ model ) ; return $ model ; }
|
Performs a Model delete commit and persists to the database .
|
55,062
|
private function doCommitUpdate ( Model $ model ) { $ this -> dispatchLifecycleEvent ( Events :: preUpdate , $ model ) ; $ this -> getPersisterFor ( $ model -> getType ( ) ) -> update ( $ model ) ; $ model -> reload ( ) ; $ this -> dispatchLifecycleEvent ( Events :: postUpdate , $ model ) ; return $ model ; }
|
Performs a Model update commit and persists to the database .
|
55,063
|
public function validateRelationshipSet ( EntityMetadata $ owningMeta , $ typeToAdd ) { if ( true === $ owningMeta -> isPolymorphic ( ) ) { $ canSet = in_array ( $ typeToAdd , $ owningMeta -> ownedTypes ) ; } else { $ canSet = $ owningMeta -> type === $ typeToAdd ; } if ( false === $ canSet ) { throw StoreException :: badRequest ( sprintf ( 'The model type "%s" cannot be added to "%s", as it is not supported.' , $ typeToAdd , $ owningMeta -> type ) ) ; } return $ this ; }
|
Validates that a model type can be set to an owning metadata type .
|
55,064
|
protected function shouldCommit ( Model $ model ) { $ state = $ model -> getState ( ) ; return $ model -> isDirty ( ) || $ state -> is ( 'new' ) || $ state -> is ( 'deleting' ) ; }
|
Determines if a model is eligible for commit .
|
55,065
|
protected function isSequentialArray ( array $ arr ) { if ( empty ( $ arr ) ) { return true ; } return ( range ( 0 , count ( $ arr ) - 1 ) === array_keys ( $ arr ) ) ; }
|
Determines if an array is sequential .
|
55,066
|
function setScope ( $ scope ) { $ scopes = array_merge ( $ this -> getScopes ( ) , array ( ( string ) $ scope ) ) ; $ this -> setScopes ( $ scopes ) ; return $ this ; }
|
Add Scope To Current Scopes
|
55,067
|
public static function getHostForLookup ( $ hostname , $ blacklist , $ isIP = true ) { if ( $ isIP && filter_var ( $ hostname , FILTER_VALIDATE_IP ) ) { return self :: buildLookUpIP ( $ hostname , $ blacklist ) ; } if ( $ isIP && ! filter_var ( $ hostname , FILTER_VALIDATE_IP ) ) { $ resolver = new \ Net_DNS_Resolver ; $ response = @ $ resolver -> query ( $ hostname ) ; $ ip = isset ( $ response -> answer [ 0 ] -> address ) ? $ response -> answer [ 0 ] -> address : null ; if ( ! $ ip || ! filter_var ( $ ip , FILTER_VALIDATE_IP ) ) { return null ; } return self :: buildLookUpIP ( $ ip , $ blacklist ) ; } return self :: buildLookUpHost ( $ hostname , $ blacklist ) ; }
|
Get host to lookup . Lookup a host if neccessary and get the complete FQDN to lookup .
|
55,068
|
public function validateRename ( & $ submitted , $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateNameRename ( ) ; $ this -> validateDestinationRename ( ) ; return $ this -> getResult ( ) ; }
|
Validates an array of submitted data while renaming a file
|
55,069
|
protected function _prepareCommand ( $ operation , $ args ) { $ args = ( $ args ) ? : $ this -> args ; $ command = new Command ( $ this -> service , $ operation , $ args ) ; if ( $ this -> context ) { $ command -> setContext ( $ this -> context ) ; } else { $ command -> setContext ( $ this -> broker -> getDefaultContext ( ) ) ; } if ( $ this -> identity ) { $ command -> setIdentity ( $ this -> identity ) ; } else { $ command -> setIdentity ( $ this -> broker -> getDefaultIdentity ( ) ) ; } return $ command ; }
|
Prepare command for operation
|
55,070
|
public function renew ( $ key , $ ttl = self :: DEFAULT_TTL ) { if ( ! $ this -> hasApc ) { return false ; } $ val = apc_fetch ( $ key , $ fetched ) ; if ( $ fetched ) { return apc_store ( $ key , $ val , $ ttl ) ; } return false ; }
|
Renew a cached item by key
|
55,071
|
private function cloneTreeRecursion ( int $ menuId , TreeBase $ item , $ parentId = null ) { if ( $ item -> hasChildren ( ) ) { $ previous = null ; foreach ( $ item -> getChildren ( ) as $ child ) { if ( $ previous ) { $ previous = $ this -> itemStorage -> insertAfter ( $ previous , $ child -> getNodeId ( ) , $ child -> getTitle ( ) , $ child -> getDescription ( ) ) ; } else if ( $ parentId ) { $ previous = $ this -> itemStorage -> insertAsChild ( $ parentId , $ child -> getNodeId ( ) , $ child -> getTitle ( ) , $ child -> getDescription ( ) ) ; } else { $ previous = $ this -> itemStorage -> insert ( $ menuId , $ child -> getNodeId ( ) , $ child -> getTitle ( ) , $ child -> getDescription ( ) ) ; } $ this -> cloneTreeRecursion ( $ menuId , $ child , $ previous ) ; } } }
|
Internal recursion for clone tree
|
55,072
|
public function cloneTreeIn ( int $ menuId , Tree $ tree ) : Tree { if ( $ this -> provider -> mayCloneTree ( ) ) { return $ this -> provider -> cloneTreeIn ( $ menuId , $ tree ) ; } $ this -> cloneTreeRecursion ( $ menuId , $ tree ) ; return $ this -> provider -> buildTree ( $ menuId , false ) ; }
|
Clone full tree in given menu
|
55,073
|
public function findTreeForNode ( int $ nodeId , array $ conditions = [ ] , bool $ withAccess = false , bool $ relocateOrphans = false ) { $ menuId = $ this -> provider -> findTreeForNode ( $ nodeId , $ conditions ) ; if ( $ menuId ) { return $ this -> buildTree ( $ menuId , $ withAccess , $ relocateOrphans ) ; } }
|
Arbitrary find a tree where the node is with the given conditions
|
55,074
|
public function session_write ( $ session_id , $ session_data ) { $ time = ( int ) time ( ) + ( int ) $ this -> _session_life_time ; $ session_id = mysql_real_escape_string ( $ session_id , $ this -> db -> db ) ; $ session_data = mysql_real_escape_string ( $ session_data ) ; $ date = date ( 'Y-m-d H:i:s' ) ; $ sql = ( string ) "REPLACE INTO `{$this->_db_name}`.`user_session` (`session_id`,`session_data`,`expires`, `created`, `updated`) VALUES ('$session_id','$session_data', $time , '$date', '$date')" ; if ( ! $ this -> db -> query ( $ sql ) ) return false ; $ this -> session_id = ( string ) $ session_id ; return true ; }
|
write the session data to the database
|
55,075
|
public function session_destroy ( $ session_id ) { if ( empty ( $ session_id ) ) return false ; $ escaped_id = ( string ) addslashes ( stripslashes ( $ session_id ) ) ; $ sql = ( string ) "DELETE FROM `{$this->_db_name}`.`user_session` WHERE `session_id` = '$escaped_id'" ; return $ this -> db -> query ( ( string ) $ sql ) ; }
|
destroy the session
|
55,076
|
public function alert ( String $ type , $ content ) { $ content = $ this -> stringOrCallback ( $ content ) ; $ this -> isBootstrapAttribute ( 'dismiss-fade' , function ( ) use ( & $ type ) { $ type .= ' alert-dismissible fade show' ; } ) ; $ this -> isBootstrapAttribute ( 'dismiss-button' , function ( $ attribute ) use ( & $ content ) { $ content .= $ this -> buttonDismissButton ( $ this -> spanDismissButton ( $ attribute ) ) ; } ) ; return $ this -> role ( 'alert' ) -> class ( 'alert alert-' . $ type ) -> div ( $ content ) ; }
|
Bootstrap alert component
|
55,077
|
protected function getURIsegments ( $ uri , $ segmentCount ) { if ( $ uri === NULL ) { $ uri = URI :: active ( ) ; } return explode ( '/' , rtrim ( Datatype :: divide ( $ uri , '/' , 0 , $ segmentCount ) , '/' ) ) ; }
|
Protected get uri segments
|
55,078
|
protected function breadcrumbOlList ( $ options ) { return $ this -> ol ( function ( $ option ) use ( $ options ) { $ link = NULL ; $ count = count ( $ options ) ; if ( $ count === 2 && $ options [ 1 ] === CURRENT_COPEN_PAGE ) { unset ( $ options [ 1 ] ) ; $ count -- ; } foreach ( $ options as $ key => $ val ) { $ link .= Base :: suffix ( $ val ) ; if ( $ key < $ count - 1 ) { $ item = $ this -> breadcrumbItem ( $ link , $ val ) ; echo $ option -> class ( 'breadcrumb-item active' ) -> ariaCurrent ( 'page' ) -> li ( $ item ) ; } else { echo $ option -> class ( 'breadcrumb-item' ) -> li ( ucfirst ( $ val ) ) ; } } } , [ 'class' => 'breadcrumb' ] ) ; }
|
Protected breadcrumb ol list
|
55,079
|
public function isStripped ( $ isStripped = null ) { if ( null === $ isStripped ) { return $ this -> _stripped ; } $ this -> _stripped = ( bool ) $ isStripped ; return $ this ; }
|
Get or set the stripped attribute for the table
|
55,080
|
public function isBordered ( $ isBordered = null ) { if ( null === $ isBordered ) { return $ this -> _bordered ; } $ this -> _bordered = ( bool ) $ isBordered ; return $ this ; }
|
Get or set the bordered attribute for the table
|
55,081
|
public function isHover ( $ isHover = null ) { if ( null === $ isHover ) { return $ this -> _hover ; } $ this -> _hover = ( bool ) $ isHover ; return $ this ; }
|
Get or set the hover attribute for the table
|
55,082
|
public function createMainMenu ( Request $ request ) { $ menu = $ this -> factory -> createItem ( 'root' ) ; $ repositoriesMenu = $ this -> repositoryMenu -> getMenu ( ) ; foreach ( $ repositoriesMenu as $ repositoryActions ) { $ oneRepoMenu = $ menu -> addChild ( $ repositoryActions -> getName ( ) ) ; foreach ( $ repositoryActions as $ action ) { $ oneRepoMenu -> addChild ( $ action -> getName ( ) , [ 'route' => $ action -> getRouteName ( ) ] ) ; } } return $ menu ; }
|
Creates the main menu the one on top of every page
|
55,083
|
public function create ( Description $ description ) { return new Photo ( new Identifier ( $ description -> getMandatoryProperty ( 'id' ) ) , ( new \ DateTimeImmutable ( ) ) -> setTimestamp ( $ description -> getMandatoryProperty ( 'createdAt' ) ) , sprintf ( '%s%sx%s%s' , $ description -> getMandatoryProperty ( 'prefix' ) , $ description -> getMandatoryProperty ( 'width' ) , $ description -> getMandatoryProperty ( 'height' ) , $ description -> getMandatoryProperty ( 'suffix' ) ) , $ description -> getMandatoryProperty ( 'visibility' ) ) ; }
|
Create a photo from a description .
|
55,084
|
public function dispatch ( Event $ event ) { $ message = sprintf ( self :: FMT_INF_DISPATCHING , $ event -> getId ( ) , count ( $ this -> subscriptions ) ) ; $ this -> logger -> info ( $ message ) ; $ dispatchCount = 0 ; foreach ( $ this -> subscriptions as $ subscription ) { $ result = $ this -> tryDispatch ( $ subscription , $ event ) ; $ dispatchCount += ( int ) $ result ; } $ message = sprintf ( self :: FMT_INF_DISPATCHED , $ event -> getId ( ) , $ dispatchCount ) ; $ this -> logger -> info ( $ message ) ; return $ dispatchCount ; }
|
Dispatches an event based on its category .
|
55,085
|
private function tryDispatch ( Subscription $ subscription , Event $ event ) { $ dispatched = false ; try { $ dispatched = $ this -> doDispatch ( $ subscription , $ event ) ; } catch ( \ Exception $ ex ) { if ( ! $ this -> silent ) { throw new \ RuntimeException ( 'Dispatch triggered an exception' , 0 , $ ex ) ; } $ message = sprintf ( self :: FMT_ERR_DISPATCH , $ event -> getId ( ) , $ ex -> getMessage ( ) ) ; $ this -> logger -> error ( $ message , array ( 'event-category' => $ event -> getCategory ( ) , 'subscription-filter' => $ subscription -> getCategoryFilter ( ) , 'subscriber_class' => get_class ( $ subscription -> getSubscriber ( ) ) , 'message' => $ ex -> getMessage ( ) , 'trace' => $ ex -> getTraceAsString ( ) ) ) ; } return $ dispatched ; }
|
Attempts to dispatch an event
|
55,086
|
protected function createNode ( NodeInterface $ commentCollection , CommentDtoInterface $ comment ) : NodeInterface { $ commentNodeType = $ this -> nodeTypeManager -> getNodeType ( self :: COMMENT_NODE_TYPE ) ; $ commentNodeTemplate = new NodeTemplate ( ) ; $ commentNodeTemplate -> setNodeType ( $ commentNodeType ) ; $ commentNode = $ commentCollection -> createNodeFromTemplate ( $ commentNodeTemplate ) ; $ commentNode -> setProperty ( 'name' , $ comment -> getName ( ) ) ; $ commentNode -> setProperty ( 'email' , $ comment -> getEmail ( ) ) ; $ commentNode -> setProperty ( 'content' , $ comment -> getContent ( ) ) ; $ commentNode -> setProperty ( 'createdAt' , $ comment -> getCreatedAt ( ) ) ; $ commentNode -> setHidden ( $ comment -> isHidden ( ) ) ; if ( $ this -> addCommentToTop ) { $ firstComment = $ commentCollection -> getChildNodes ( null , 1 ) ; if ( $ firstComment ) { $ commentNode -> moveBefore ( $ firstComment [ 0 ] ) ; } } return $ commentNode ; }
|
creates a comment node from the CommentDto
|
55,087
|
public function addComment ( NodeInterface $ commentableNode , CommentDtoInterface $ comment ) { if ( ! $ this -> isCommentableNode ( $ commentableNode ) ) { throw new InvalidNodeTypeException ( 'The commentable node type should implement the mixin ' . self :: COMMENTABLE_NODE_TYPE , 1536244558 ) ; } $ this -> createNode ( $ commentableNode -> getNode ( 'comments' ) , $ comment ) ; }
|
adds a comment node to a blog post node
|
55,088
|
public function sortByZoneType ( ) { return $ this -> sort ( function ( Zone $ zone1 , Zone $ zone2 ) { $ zone1Order = $ zone1 -> getZoneType ( ) -> getOrder ( ) ; $ zone2Order = $ zone2 -> getZoneType ( ) -> getOrder ( ) ; return $ zone1Order >= $ zone2Order ? 1 : - 1 ; } ) ; }
|
Sort zones by zone type order ascending order .
|
55,089
|
public function indexByZoneType ( ) { $ zoneCollection = array ( ) ; foreach ( $ this as $ zone ) { $ zoneCollection [ $ zone -> getZoneType ( ) -> getName ( ) ] = $ zone ; } return new self ( $ zoneCollection ) ; }
|
Index this collection by zone type name .
|
55,090
|
private function assertIsScalarOrArray ( $ value ) { if ( ! is_scalar ( $ value ) && ! is_array ( $ value ) ) { throw InvalidTypeException :: fromMessageAndPrototype ( "An unknown type must at least be a scalar or array value" , static :: prototype ( ) ) ; } if ( is_array ( $ value ) ) { foreach ( $ value as $ item ) $ this -> assertIsScalarOrArray ( $ item ) ; } }
|
This method checks recursively if the value only consists of arrays and scalar types
|
55,091
|
private function parseDataToString ( $ data ) { $ format = $ this -> allowedFormats [ $ this -> format ] ; $ className = "\\Ginger\\Response\\Format\\" . $ format [ 'class' ] ; return $ className :: Parse ( $ data ) ; }
|
Passes data to one of the format interfaces and returns string value
|
55,092
|
public function send ( ) { $ data = $ this -> parseDataToString ( $ this -> data ) ; $ format = $ this -> allowedFormats [ $ this -> format ] ; header ( $ this -> getStatus ( ) , true , $ this -> getStatus ( ) ) ; foreach ( self :: $ headers as $ key => $ value ) { header ( $ key . ": " . $ value ) ; } header ( "Content-Type: " . $ format [ 'mimetype' ] . "; charset=utf-8" ) ; header ( "Content-Length: " . strlen ( $ data ) ) ; if ( function_exists ( "ginger_log" ) ) { ginger_log ( $ this ) ; } echo $ data ; die ( ) ; }
|
Sets status header content - type header and outputs data . Die is there for making sure nothing else is processed after this .
|
55,093
|
public function setFormat ( $ format = false ) { if ( ! $ format ) { $ format = \ Ginger \ System \ Parameters :: $ format ; } $ this -> format = $ format ; if ( ! isset ( $ this -> allowedFormats [ $ this -> format ] ) ) { $ this -> format = $ this -> defaultFormat ; } }
|
setFormat function .
|
55,094
|
public function setCallback ( $ callback = false ) { if ( ! $ callback ) { $ callback = \ Ginger \ System \ Parameters :: $ callback ; } $ this -> callback = $ callback ; }
|
setCallback function .
|
55,095
|
public function post ( string $ name ) : string { if ( ! isset ( $ this -> post [ $ name ] ) ) { return "" ; } return $ this -> post [ $ name ] ; }
|
Obtener parametro de una peticion POST
|
55,096
|
public function get ( string $ name ) : string { if ( ! isset ( $ this -> get [ $ name ] ) ) { return "" ; } return $ this -> get [ $ name ] ; }
|
Obtener parametro de una peticion GET
|
55,097
|
public function server ( string $ name ) : string { if ( ! isset ( $ this -> server [ $ name ] ) ) { return "" ; } return $ this -> server [ $ name ] ; }
|
Obtener parametro del servidor apache .
|
55,098
|
public function file ( string $ name ) : string { if ( ! isset ( $ this -> file [ $ name ] ) ) { return "" ; } return $ this -> file [ $ name ] ; }
|
Obtener los paramtros del protocolo file .
|
55,099
|
public function cookie ( string $ name ) : string { if ( ! isset ( $ this -> cookies [ $ name ] ) ) { return "" ; } return $ this -> cookies [ $ name ] ; }
|
Obtener parametros de las cookies .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.