idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
57,000
public function get ( $ key ) { if ( isset ( $ this -> settings [ $ key ] ) ) { return $ this -> settings [ $ key ] ; } return null ; }
Get configuration parameter by key if exists else return null
57,001
public function cmdGetFieldValue ( ) { $ result = $ this -> getListFieldValue ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableFieldValue ( $ result ) ; $ this -> output ( ) ; }
Callback for field - value - get command
57,002
public function cmdDeleteFieldValue ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( $ this -> getParam ( 'field' ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> field_value -> getList ( array ( 'field_i...
Callback for field - value - delete command
57,003
public function cmdUpdateFieldValue ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ th...
Callback for field - value - update command
57,004
protected function getListFieldValue ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { return $ this -> field_value -> getList ( array ( 'limit' => $ this -> getLimit ( ) ) ) ; } if ( $ this -> getParam ( 'field' ) ) { return $ this -> field_value -> getList ( array ( 'field_id' => $ id , 'limit' => $ t...
Returns an array of field values
57,005
protected function addFieldValue ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> field_value -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new field value
57,006
protected function submitAddFieldValue ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'field_value' ) ; $ this -> addFieldValue ( ) ; }
Add a new field value at once
57,007
protected function wizardAddFieldValue ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'field_value' ) ; $ this -> validatePrompt ( 'field_id' , $ this -> text ( 'Field ID' ) , 'field_value' ) ; $ this -> validatePrompt ( 'color' , $ this -> text ( 'Color' ) , 'field_value' , '' ) ; $ this -> va...
Add a new field value step by step
57,008
protected function _stringableJoin ( $ parts , $ delim ) { $ parts = $ this -> _normalizeIterable ( $ parts ) ; $ i = 0 ; $ result = '' ; foreach ( $ parts as $ _part ) { try { $ _part = $ this -> _normalizeString ( $ _part ) ; } catch ( InvalidArgumentException $ e ) { throw $ this -> _createOutOfRangeException ( $ th...
Joins a list of parts using a delimiter .
57,009
public static function reorder ( array $ data , array $ order , $ throwExceptionIfKeyNotFound = false , $ throwExceptionIfExtraData = false ) { $ result = array ( ) ; foreach ( $ order as $ orderedKey ) { if ( array_key_exists ( $ orderedKey , $ data ) ) { $ result [ $ orderedKey ] = $ data [ $ orderedKey ] ; unset ( $...
Orders data based on order of values in order array
57,010
public function init ( $ config = NULL ) { parent :: init ( $ config ) ; if ( isset ( $ config [ 'id' ] ) ) { $ this -> id = ( int ) $ config [ 'id' ] ; } $ this -> doAction ( self :: ON_MODEL_INIT_ACTION ) ; }
Initialises the model .
57,011
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Config' ) ; $ navigationConfig = $ config [ 'navigation' ] ; $ navigation = new Navigation ( $ navigationConfig ) ; return $ navigation ; }
Create navigation service
57,012
public function getProperty ( ) { return ' /** * @var ' . $ this -> getType ( ) -> getType ( ) . ' $' . $ this -> getPropertyName ( ) . ' */ protected $' . $ this -> getPropertyName ( ) . ' = ' . $ this -> getDefault ( true ) . ';' ; }
Get property declaration .
57,013
public function getGetter ( ) { return ' /** * Get value for field "' . $ this -> getName ( ) . '" * * @return ' . $ this -> getType ( ) -> getType ( ) . ' */ public function ' . $ this -> getMethodNameGet ( ) . '() { return $this->' . $ this -> getPropertyName ( ) . '; }' ; }
Get method getter .
57,014
public function getSetter ( ) { $ varname = '$' . $ this -> getPropertyName ( ) ; $ autoinc = '' ; $ cast = $ this -> getType ( ) -> getCastMethod ( ) . ' ' ; if ( $ this -> isNullable ( ) ) { $ forceCast = $ varname . ' = (' . $ varname . ' === null ? ' . $ varname . ' : ' . $ cast . $ varname . ');' ; } else { $ forc...
Get method setter .
57,015
public function getName ( $ withoutPrefix = false ) { $ name = $ this -> name ; if ( $ withoutPrefix && stripos ( $ name , $ this -> dbPrefix ) === 0 ) { $ name = substr ( $ name , strlen ( $ this -> dbPrefix ) ) ; } return $ name ; }
Get name . Can remove table prefix .
57,016
protected function setData ( \ stdClass $ column ) { $ this -> setName ( $ column -> Field ) ; $ this -> setIsPrimaryKey ( ( $ column -> Key === 'PRI' ) ) ; $ this -> setIsKey ( ! empty ( $ column -> Key ) ) ; $ this -> setType ( $ column -> Type ) ; $ this -> setIsNullable ( ( $ column -> Null === 'YES' ) ) ; $ this -...
Set column data from db query
57,017
public function getMethodNameGet ( ) { $ methodName = str_replace ( ' ' , '' , ucwords ( str_replace ( array ( '_is_' , '_has_' , '_in_' , '_' , ) , ' ' , strtolower ( $ this -> getName ( true ) ) ) ) ) ; $ type = $ this -> getType ( ) ; switch ( true ) { case ( $ type instanceof Type \ TypeBool ) && stripos ( $ this -...
Get method name for getter .
57,018
protected function setExtra ( $ extra ) { if ( empty ( $ extra ) ) { return $ this ; } switch ( $ extra ) { case 'auto_increment' : $ this -> isAutoIncrement = true ; break ; } return $ this ; }
Set extra info .
57,019
protected function getCheck ( ) { $ check = array ( 0 => '' , 1 => '' ) ; $ type = $ this -> getType ( ) ; switch ( $ type -> getType ( ) ) { case 'int' : case 'float' : if ( $ type -> isUnsigned ( ) ) { $ check [ 1 ] = '\UnderflowException' ; $ check [ 0 ] = ' if ($this->' . $ this -> getPropertyName ( ) . ' < ...
Get check condition for numeric values & underflow if necessary .
57,020
public function run ( $ url = null , $ method = null ) { $ route = $ this -> altoRouter -> match ( $ url , $ method ) ; if ( ! $ route ) { throw new NotFoundException ( ( ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) && ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ) ? $ _SERVER [ 'REQUEST_URI' ] : ( ( $ url != null ) ? $ url : "/...
This function runs the router and call the apropriate
57,021
public function filterByFiles ( $ files = null , $ comparison = null ) { if ( is_array ( $ files ) ) { $ useMinMax = false ; if ( isset ( $ files [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_FILES , $ files [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ files [ 'max...
Filter the query on the files column
57,022
public function filterBySubcats ( $ subcats = null , $ comparison = null ) { if ( is_array ( $ subcats ) ) { $ useMinMax = false ; if ( isset ( $ subcats [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_SUBCATS , $ subcats [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ ...
Filter the query on the subcats column
57,023
public function filterBySize ( $ size = null , $ comparison = null ) { if ( is_array ( $ size ) ) { $ useMinMax = false ; if ( isset ( $ size [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_SIZE , $ size [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ size [ 'max' ] ) )...
Filter the query on the size column
57,024
public function filterByHidden ( $ hidden = null , $ comparison = null ) { if ( is_string ( $ hidden ) ) { $ hidden = in_array ( strtolower ( $ hidden ) , array ( 'false' , 'off' , '-' , 'no' , 'n' , '0' , '' ) ) ? false : true ; } return $ this -> addUsingAlias ( CategoryTableMap :: COL_HIDDEN , $ hidden , $ compariso...
Filter the query on the hidden column
57,025
public function filterByTreeLeft ( $ treeLeft = null , $ comparison = null ) { if ( is_array ( $ treeLeft ) ) { $ useMinMax = false ; if ( isset ( $ treeLeft [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_TREE_LEFT , $ treeLeft [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( iss...
Filter the query on the tree_left column
57,026
public function filterByTreeRight ( $ treeRight = null , $ comparison = null ) { if ( is_array ( $ treeRight ) ) { $ useMinMax = false ; if ( isset ( $ treeRight [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_TREE_RIGHT , $ treeRight [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if...
Filter the query on the tree_right column
57,027
public function filterByTreeLevel ( $ treeLevel = null , $ comparison = null ) { if ( is_array ( $ treeLevel ) ) { $ useMinMax = false ; if ( isset ( $ treeLevel [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_TREE_LEVEL , $ treeLevel [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if...
Filter the query on the tree_level column
57,028
public function filterBySource ( $ source , $ comparison = null ) { if ( $ source instanceof \ Attogram \ SharedMedia \ Orm \ Source ) { return $ this -> addUsingAlias ( CategoryTableMap :: COL_SOURCE_ID , $ source -> getId ( ) , $ comparison ) ; } elseif ( $ source instanceof ObjectCollection ) { if ( null === $ compa...
Filter the query by a related \ Attogram \ SharedMedia \ Orm \ Source object
57,029
public function filterByC2M ( $ c2M , $ comparison = null ) { if ( $ c2M instanceof \ Attogram \ SharedMedia \ Orm \ C2M ) { return $ this -> addUsingAlias ( CategoryTableMap :: COL_ID , $ c2M -> getCategoryId ( ) , $ comparison ) ; } elseif ( $ c2M instanceof ObjectCollection ) { return $ this -> useC2MQuery ( ) -> fi...
Filter the query by a related \ Attogram \ SharedMedia \ Orm \ C2M object
57,030
public function descendantsOf ( ChildCategory $ category ) { return $ this -> addUsingAlias ( ChildCategory :: LEFT_COL , $ category -> getLeftValue ( ) , Criteria :: GREATER_THAN ) -> addUsingAlias ( ChildCategory :: LEFT_COL , $ category -> getRightValue ( ) , Criteria :: LESS_THAN ) ; }
Filter the query to restrict the result to descendants of an object
57,031
public function childrenOf ( ChildCategory $ category ) { return $ this -> descendantsOf ( $ category ) -> addUsingAlias ( ChildCategory :: LEVEL_COL , $ category -> getLevel ( ) + 1 , Criteria :: EQUAL ) ; }
Filter the query to restrict the result to children of an object
57,032
public function siblingsOf ( ChildCategory $ category , ConnectionInterface $ con = null ) { if ( $ category -> isRoot ( ) ) { return $ this -> add ( ChildCategory :: LEVEL_COL , '1<>1' , Criteria :: CUSTOM ) ; } else { return $ this -> childrenOf ( $ category -> getParent ( $ con ) ) -> prune ( $ category ) ; } }
Filter the query to restrict the result to siblings of an object . The result does not include the object passed as parameter .
57,033
public function ancestorsOf ( ChildCategory $ category ) { return $ this -> addUsingAlias ( ChildCategory :: LEFT_COL , $ category -> getLeftValue ( ) , Criteria :: LESS_THAN ) -> addUsingAlias ( ChildCategory :: RIGHT_COL , $ category -> getRightValue ( ) , Criteria :: GREATER_THAN ) ; }
Filter the query to restrict the result to ancestors of an object
57,034
public function orderByBranch ( $ reverse = false ) { if ( $ reverse ) { return $ this -> addDescendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; } else { return $ this -> addAscendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; } }
Order the result by branch i . e . natural tree order
57,035
public function orderByLevel ( $ reverse = false ) { if ( $ reverse ) { return $ this -> addDescendingOrderByColumn ( ChildCategory :: LEVEL_COL ) -> addDescendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; } else { return $ this -> addAscendingOrderByColumn ( ChildCategory :: LEVEL_COL ) -> addAscendingOrderByColumn...
Order the result by level the closer to the root first
57,036
public function findRoot ( ConnectionInterface $ con = null ) { return $ this -> addUsingAlias ( ChildCategory :: LEFT_COL , 1 , Criteria :: EQUAL ) -> findOne ( $ con ) ; }
Returns the root node for the tree
57,037
static public function retrieveRoot ( ConnectionInterface $ con = null ) { $ c = new Criteria ( CategoryTableMap :: DATABASE_NAME ) ; $ c -> add ( ChildCategory :: LEFT_COL , 1 , Criteria :: EQUAL ) ; return ChildCategoryQuery :: create ( null , $ c ) -> findOne ( $ con ) ; }
Returns the root node for a given scope
57,038
static public function retrieveTree ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { if ( null === $ criteria ) { $ criteria = new Criteria ( CategoryTableMap :: DATABASE_NAME ) ; } $ criteria -> addAscendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; return ChildCategoryQuery :: create ( null , $ ...
Returns the whole tree node for a given scope
57,039
static public function isValid ( ChildCategory $ node = null ) { if ( is_object ( $ node ) && $ node -> getRightValue ( ) > $ node -> getLeftValue ( ) ) { return true ; } else { return false ; } }
Tests if node is valid
57,040
static public function updateLoadedNodes ( $ prune = null , ConnectionInterface $ con = null ) { if ( Propel :: isInstancePoolingEnabled ( ) ) { $ keys = array ( ) ; foreach ( CategoryTableMap :: $ instances as $ obj ) { if ( ! $ prune || ! $ prune -> equals ( $ obj ) ) { $ keys [ ] = $ obj -> getPrimaryKey ( ) ; } } i...
Reload all already loaded nodes to sync them with updated db
57,041
protected function resizeImage ( $ path , $ width , $ height ) { $ this -> images -> open ( 'Gd' , $ path ) ; $ this -> images -> resize ( $ width , $ height ) ; }
resizes an image
57,042
public static function get_colors ( $ type = 'hex' ) { $ cached = self :: $ colorsCached ; if ( isset ( $ cached [ $ type ] ) ) return $ cached [ $ type ] ; $ colors = Config :: inst ( ) -> get ( 'Identity' , 'colors' ) ; if ( $ type == 'rgb' ) { $ rgbColors = [ ] ; foreach ( $ colors as $ name => $ c ) { $ rgbColors [...
Identify colors in either hex or rgb
57,043
public static function hex2rgb ( $ hex ) { $ hex = str_replace ( "#" , "" , $ hex ) ; $ r = hexdec ( substr ( $ hex , 0 , 2 ) ) ; $ g = hexdec ( substr ( $ hex , 2 , 2 ) ) ; $ b = hexdec ( substr ( $ hex , 4 , 2 ) ) ; return "$r,$g,$b" ; }
Helper for converting a color to rbg
57,044
public function getResourceTypes ( ) { $ types = [ ] ; foreach ( $ this as $ entity ) { $ types [ ] = $ entity -> getType ( ) ; } return array_unique ( $ types ) ; }
Gets a unique list of all entity types assigned to this collection .
57,045
public function on_common ( ) { if ( substr ( $ GLOBALS [ 'request' ] -> server ( 'SCRIPT_NAME' ) , - 7 ) === 'app.php' ) { return ; } try { $ this -> request_stack -> push ( $ this -> symfony_request ) ; $ this -> dispatcher -> dispatch ( KernelEvents :: REQUEST , new GetResponseEvent ( $ this -> http_kernel , $ this ...
Emulate the kernel request event
57,046
public function on_garbage_collection ( ) { if ( substr ( $ GLOBALS [ 'request' ] -> server ( 'SCRIPT_NAME' ) , - 7 ) === 'app.php' ) { return ; } set_exception_handler ( array ( $ this , 'exception_handler' ) ) ; try { $ response = new Response ( '<html><body></body></html>' ) ; $ this -> dispatcher -> dispatch ( Kern...
Emulate the kernel response event
57,047
public function onKernelResponse ( FilterResponseEvent $ event ) { $ result = parent :: onKernelResponse ( $ event ) ; $ content = ob_get_contents ( ) ; if ( $ this -> request_stack -> getCurrentRequest ( ) -> getMethod ( ) === 'POST' && empty ( $ content ) ) { $ event -> stopPropagation ( ) ; } return $ result ; }
Avoid the injection of the toolbar
57,048
public function & refScopeStatistic ( $ scope ) { if ( ! isset ( $ this -> statistics [ $ scope ] ) ) $ this -> statistics [ $ scope ] = [ ] ; return $ this -> statistics [ $ scope ] ; }
Return a reference for batch editing . Do not replace the whole variable into non - array value!
57,049
public function load ( ) { $ output = [ ] ; $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( is_array ( $ arg ) ) { $ output = array_merge ( call_user_func_array ( [ $ this , 'load' ] , $ arg ) , $ output ) ; } else { $ this -> loadHandler ( $ arg ) ; $ output [ ] = $ arg ; } } return $ output ; }
Load a collection of assets into the Di container . Provides a whole load of syntatic sugar so you can basically pass this a combination of arrays assets multiple args ... whatever The actual work is done by loadHandler
57,050
public function getList ( ) { $ category = $ this -> getCategory ( ) ; $ list = $ this -> getCategoryConfig ( $ category ) ; foreach ( $ list as $ context => $ config ) { $ list [ $ context ] = $ this -> getAll ( $ context ) ; } return $ list ; }
Get All config entries
57,051
public function classname ( $ id ) { return isset ( $ this -> classes [ $ id ] ) ? $ this -> classes [ $ id ] : null ; }
Returns the default or configured classname with namespace
57,052
function run ( ) { $ request = $ this -> getServerRequest ( ) ; $ response = $ this -> getResponse ( ) ; $ uri = $ request -> getUri ( ) ; $ basepath = $ uri -> getBasePath ( ) ; $ args = explode ( '/' , htmlspecialchars ( $ basepath ) ) ; $ response = $ this -> process ( $ request , $ response , $ args ) ; $ this -> f...
Runs the engine the processes the request
57,053
public function setFilePointer ( $ pointer ) { if ( ! is_resource ( $ pointer ) ) throw new InvalidArgumentException ( "Invalid type - not a file resource" ) ; $ this -> pointer = $ pointer ; $ metadata = stream_get_meta_data ( $ this -> pointer ) ; if ( isset ( $ metadata [ "mode" ] ) ) { $ mode = rtrim ( $ metadata [...
Set the file pointer
57,054
protected function getResults ( string $ username , ServerRequestInterface $ request ) : \ MongoDB \ Driver \ Cursor { $ q = new \ MongoDB \ Driver \ Query ( array_merge ( $ this -> query , [ ( $ this -> fieldUser ) => $ username ] ) , [ 'projection' => [ ( $ this -> fieldUser ) => true , ( $ this -> fieldPass ) => tru...
Queries the MongoDB collection .
57,055
protected function fetchResult ( \ MongoDB \ Driver \ Cursor $ results , string $ username ) : \ stdClass { $ values = $ results -> toArray ( ) ; if ( count ( $ values ) > 1 ) { throw new \ Caridea \ Auth \ Exception \ UsernameAmbiguous ( $ username ) ; } elseif ( count ( $ values ) == 0 ) { throw new \ Caridea \ Auth ...
Fetches a single result from the Mongo Cursor .
57,056
public function destroy ( $ sessionId ) { $ sql = 'DELETE from tbl_sessions where SESSION_ID=:SESSID' ; $ delete = $ this -> _db -> prepare ( $ sql ) ; $ delete -> execute ( array ( ':SESSID' => $ sessionId ) ) ; $ this -> _cache -> delete ( $ sessionId ) ; return true ; }
destroy Destroying the session deletes it from the cache as well as the backend database .
57,057
public function gc ( $ lifetime ) { $ sql = 'DELETE from tbl_sessions where LAST_ACCESSED < DATE_SUB(NOW(), INTERVAL :LIFETIME SECOND)' ; $ delete = $ this -> _db -> prepare ( $ sql ) ; $ count = $ delete -> execute ( array ( ':LIFETIME' => $ lifetime ) ) ; return true ; }
Garbage collection causes all expired sessions to be deleted .
57,058
public function open ( $ savePath , $ sessionName ) { $ sql = 'INSERT INTO tbl_sessions (SESSION_ID, SESSION_DATA) values (:SESSID, :SESSDATA) ON DUPLICATE KEY UPDATE LAST_ACCESSED=NOW()' ; $ stmt = $ this -> _db -> prepare ( $ sql ) ; $ stmt -> execute ( array ( ':SESSID' => session_id ( ) , ':SESSDATA' => '' ) ) ; }
open Opening the session causes an insert into the sessions table .
57,059
public static function lockTables ( $ table = NULL , $ blockType = 'WRITE' ) { $ sql = "LOCK TABLES " ; if ( $ table === NULL ) { $ sql .= self :: tableName ( ) . " $blockType" ; } else { $ tmpSql = '' ; foreach ( ( is_array ( $ table ) ? $ table : [ $ table ] ) as $ key => $ value ) { $ tmpSql .= empty ( $ tmpSql ) ? ...
Lock DB tables
57,060
public function renderOut ( ) { foreach ( Error :: all ( ) as $ file => $ error ) { foreach ( $ error as $ line ) { $ this -> addMessage ( 'Template error: ' . $ line . '(' . $ file . ')' , 'error' ) ; } } return $ this -> render -> render ( ) ; }
Render debug bar code
57,061
public function addException ( $ e ) { if ( $ e instanceof \ Exception ) { try { $ this -> bar -> getCollector ( 'exceptions' ) -> addException ( $ e ) ; } catch ( \ Exception $ ie ) { } } }
Add exception into debug bar and stop execute
57,062
public function addMessage ( $ m , $ type = 'info' ) { if ( ! Any :: isStr ( $ m ) || ! Any :: isStr ( $ type ) ) { return ; } $ m = App :: $ Security -> secureHtml ( $ m ) ; try { $ mCollector = $ this -> bar -> getCollector ( 'messages' ) ; if ( method_exists ( $ mCollector , $ type ) ) { $ this -> bar -> getCollecto...
Add message into debug bar
57,063
public static function autobox ( $ value ) { if ( is_numeric ( $ value ) ) { if ( strpos ( $ value , '.' ) !== false ) { return ( float ) $ value ; } else { return ( int ) $ value ; } } else if ( is_bool ( $ value ) ) { return ( bool ) $ value ; } else if ( $ value === 'true' || $ value === 'false' ) { return ( $ value...
Autobox a value by type casting it .
57,064
public static function isJson ( $ data ) { if ( ! is_string ( $ data ) || empty ( $ data ) ) { return false ; } $ json = @ json_decode ( $ data , true ) ; return ( json_last_error ( ) === JSON_ERROR_NONE && $ json !== null ) ; }
Check to see if data passed is a JSON object .
57,065
public static function isSerialized ( $ data ) { if ( ! is_string ( $ data ) || empty ( $ data ) ) { return false ; } return ( @ unserialize ( $ data ) !== false ) ; }
Check to see if data passed has been serialized .
57,066
public static function isXml ( $ data ) { if ( ! is_string ( $ data ) || substr ( $ data , 0 , 5 ) !== '<?xml' ) { return false ; } return ( @ simplexml_load_string ( $ data ) instanceof SimpleXMLElement ) ; }
Check to see if data passed is an XML document .
57,067
public function route ( ) { $ this -> dashboardRouting ( $ this -> relativeCmsUri ) ; $ this -> logOffRouting ( $ this -> request , $ this -> relativeCmsUri ) ; $ this -> apiRouting ( $ this -> relativeCmsUri ) ; $ this -> documentRouting ( $ this -> userRights , $ this -> relativeCmsUri ) ; $ this -> valuelistsRouting...
Call the different routing methods
57,068
public function getTemplate ( TemplatableNodeInterface $ node ) { $ template = $ node -> getTemplate ( ) ; if ( ! $ template ) { $ meta = $ this -> manager -> getClassMetadata ( get_class ( $ node ) ) ; if ( ! empty ( $ this -> templates [ $ meta -> name ] ) && count ( $ this -> templates [ $ meta -> name ] ) > 0 ) $ t...
get the assigned template of the given TemplatableNodeInterface handles the template selection if no template is assigned
57,069
protected static function getBundleNameFromEntity ( $ entityNamespace , $ bundles ) { $ dataBaseNamespace = substr ( $ entityNamespace , 0 , strpos ( $ entityNamespace , '\\Entity' ) ) ; foreach ( $ bundles as $ type => $ bundle ) { $ bundleRefClass = new \ ReflectionClass ( $ bundle ) ; if ( $ bundleRefClass -> getNam...
Get the bundle name from an Entity namespace
57,070
public function getTransaction ( $ transactionId ) : QueryInterface { $ uri = $ this -> getUri ( 'query' , $ this -> getParameters ( [ 'transactionId' => $ transactionId ] ) ) ; $ response = $ this -> performRequest ( ( string ) $ uri ) ; Assert :: isInstanceOf ( $ response , QueryInterface :: class , 'Invalid response...
Get a Query response object for the provided transaction ID .
57,071
public function registerTransaction ( array $ transactionData ) : RegisterInterface { $ uri = $ this -> getUri ( 'register' , $ this -> getParameters ( $ transactionData ) ) ; $ response = $ this -> performRequest ( ( string ) $ uri ) ; Assert :: isInstanceOf ( $ response , RegisterInterface :: class , 'Invalid respons...
Registers a transaction
57,072
public function processTransaction ( array $ transactionData , string $ operation ) : ProcessInterface { $ transactionData = array_filter ( $ transactionData + [ 'operation' => $ operation ] , function ( $ k ) { return in_array ( $ k , [ 'transactionId' , 'operation' , 'transactionAmount' ] ) ; } , ARRAY_FILTER_USE_KEY...
Processes a transaction
57,073
public function getTerminalUri ( string $ transactionId ) : Uri { $ uri = $ this -> getUri ( 'terminal' , [ 'merchantId' => $ this -> merchantId , 'transactionId' => $ transactionId ] ) ; return $ uri ; }
Given the transaction ID returns a URI that the user should be redirected to in order to enter their card details for that transaction .
57,074
protected function performRequest ( string $ uri ) { $ httpResponse = $ this -> client -> get ( $ uri ) ; Assert :: eq ( $ httpResponse -> getStatusCode ( ) , 200 , 'Request failed.' ) ; $ content = $ httpResponse -> getBody ( ) -> getContents ( ) ; $ xml = simplexml_load_string ( $ content ) ; $ this -> exceptionOnErr...
Performs a request to the provided URI and returns the appropriate response object based on the content of the HTTP response .
57,075
protected function getUri ( string $ endpoint , array $ parameters = [ ] ) : Uri { Assert :: keyExists ( self :: ENDPOINTS , $ endpoint , "Named endpoint {$endpoint} is unknown." ) ; $ uri = $ this -> sandbox ? self :: SANDBOX_URL : self :: PRODUCTION_URL ; $ uri .= self :: ENDPOINTS [ $ endpoint ] ; if ( $ parameters ...
Builds a URI based on the named endpoint and provided parameters . The Netaxept API claims to be a REST API but it is not in any way shape or form a REST API . It requires all requests to be GET requests and all parameters to be URLencoded and provided in the query string . About as far away from REST as you can get .
57,076
public function getFormattedDate ( int $ dateType , $ date ) : string { if ( $ date == '' ) return '' ; switch ( $ dateType ) { case self :: FORMAT_FULL : $ format = $ this -> language [ 'lan_date_format_full' ] ; break ; case self :: FORMAT_LONG : $ format = $ this -> language [ 'lan_date_format_long' ] ; break ; case...
Returns a date formatted according to a date format specifier .
57,077
public function getText ( int $ txtId ) : string { return Abc :: $ DL -> abcBabelCoreTextGetText ( $ txtId , $ this -> language [ 'lan_id' ] ) ; }
Returns the value of a text .
57,078
public function getWord ( int $ wrdId ) : string { return Abc :: $ DL -> abcBabelCoreWordGetWord ( $ wrdId , $ this -> language [ 'lan_id' ] ) ; }
Returns the text of a word .
57,079
public function popLanguage ( ) : void { array_pop ( $ this -> stack ) ; $ this -> language = $ this -> stack [ count ( $ this -> stack ) - 1 ] ; }
Restores the previous language as the current language .
57,080
public function pushLanguage ( int $ lanId ) : void { $ this -> language = Abc :: $ DL -> abcBabelCoreLanguageGetDetails ( $ lanId ) ; array_push ( $ this -> stack , $ this -> language ) ; }
Sets and pushes a new current language .
57,081
public function setLanguage ( int $ lanId ) : void { $ this -> language = Abc :: $ DL -> abcBabelCoreLanguageGetDetails ( $ lanId ) ; $ this -> stack [ max ( 0 , count ( $ this -> stack ) - 1 ) ] = $ this -> language ; }
Replaces the current language .
57,082
public function getIcon ( ) { if ( ! $ this -> icon ) { return "" ; } return Html :: get ( ) -> image ( $ this -> icon , $ this -> translate ( $ this -> label ) ) ; }
Get HTML image for selected icon
57,083
public function getURL ( ) { if ( is_string ( $ this -> url ) ) { return $ this -> url ; } return \ mpf \ WebApp :: get ( ) -> request ( ) -> createURL ( isset ( $ this -> url [ 0 ] ) ? $ this -> url [ 0 ] : 'home' , isset ( $ this -> url [ 1 ] ) ? $ this -> url [ 1 ] : null , ( isset ( $ this -> url [ 2 ] ) && is_arra...
Get string url from array|string input
57,084
public function isSelected ( ) { if ( ! is_null ( $ this -> isSelected ) ) return $ this -> isSelected ; if ( is_string ( $ this -> url ) && $ this -> url == \ mpf \ WebApp :: get ( ) -> request ( ) -> getCurrentURL ( ) ) { return true ; } elseif ( is_array ( $ this -> url ) ) { $ controller = isset ( $ this -> url [ 0...
Check if this is the current page .
57,085
protected function getModule ( ) { $ module = \ mpf \ WebApp :: get ( ) -> request ( ) -> getModule ( ) ; if ( isset ( $ this -> url [ 2 ] ) && ! is_array ( $ this -> url [ 2 ] ) ) { $ module = $ this -> url [ 2 ] ; } elseif ( isset ( $ this -> url [ 3 ] ) && ! is_array ( $ this -> url [ 3 ] ) ) { $ module = $ this -> ...
Get name of the link module ;
57,086
public function isVisible ( ) { if ( ( ! is_array ( $ this -> url ) ) || ( ! $ this -> visible ) ) { return $ this -> visible ; } $ controller = isset ( $ this -> url [ 0 ] ) ? $ this -> url [ 0 ] : 'home' ; $ action = isset ( $ this -> url [ 1 ] ) ? $ this -> url [ 1 ] : null ; if ( false !== strpos ( $ controller , '...
Check if current item is visible or not .
57,087
public function format ( PhoneNumber $ phoneNumber , $ format = PhoneNumberFormat :: INTERNATIONAL ) { if ( true === is_string ( $ format ) ) { $ constant = '\libphonenumber\PhoneNumberFormat::' . $ format ; if ( false === defined ( $ constant ) ) { throw new InvalidArgumentException ( 'The format must be either a cons...
Format a phone number .
57,088
public function publish ( $ queue , MessageInterface $ message ) { $ message -> setQueue ( $ queue ) ; $ this -> getAdapter ( ) -> publish ( $ queue , $ message ) ; }
Publish a message
57,089
public function consumeOne ( MessageInterface $ message ) { $ consumeEvent = new ConsumeEvent ( $ message ) ; try { $ this -> dispatcher -> dispatch ( BarbeQEvents :: PRE_CONSUME , $ consumeEvent ) ; $ message -> start ( ) ; $ this -> messageDispatcher -> dispatch ( $ message -> getQueue ( ) , $ consumeEvent ) ; $ mess...
Dispatches a Message to all interested consumers
57,090
public function addConsumer ( $ queue , ConsumerInterface $ consumer , $ priority = 0 ) { $ this -> messageDispatcher -> addListener ( $ queue , array ( $ consumer , 'consume' ) , $ priority ) ; }
Adds a consumer for messages from the given queue name
57,091
private static function headers_to_array ( $ headerContent ) { $ headers = array ( ) ; $ arrRequests = explode ( "\r\n\r\n" , $ headerContent ) ; foreach ( explode ( "\r\n" , $ arrRequests [ 0 ] ) as $ i => $ line ) { if ( $ i === 0 ) { $ headers [ 'http_code' ] = $ line ; } else { list ( $ key , $ value ) = explode ( ...
Converts a string containing multiple headers into an array that can be used programatically .
57,092
public function exec ( ) { if ( $ response = curl_exec ( $ this -> _ch ) ) { $ header_size = $ this -> getinfo ( CURLINFO_HEADER_SIZE ) ; return array ( 'http_status_code' => $ this -> getinfo ( CURLINFO_HTTP_CODE ) , 'body' => substr ( $ response , $ header_size ) , 'headers' => self :: headers_to_array ( substr ( $ r...
This function should be called after initializing a cURL session and all the options for the session are set
57,093
public function parse ( $ className ) { try { $ class = new \ ReflectionClass ( $ className ) ; } catch ( \ ReflectionException $ e ) { return new ClassAnnotations ( $ className , array ( ) , array ( ) , array ( ) ) ; } $ classComment = $ class -> getDocComment ( ) ; $ classAnnotations = $ this -> getCommentAnnotations...
Parse annotations for a class
57,094
private function cleanComment ( $ comment ) { $ commentLines = explode ( PHP_EOL , $ comment ) ; for ( $ i = sizeof ( $ commentLines ) - 1 ; $ i >= 0 ; $ i -- ) { $ commentLine = $ commentLines [ $ i ] ; if ( is_numeric ( strpos ( $ commentLine , "/**" ) ) || is_numeric ( strpos ( $ commentLine , "*/" ) ) || preg_match...
Clean a comment
57,095
static public function isValid ( $ operator , $ throwException = false ) { $ operator = intval ( $ operator ) ; if ( $ operator > 0 && $ operator <= static :: IS_NOT_NULL ) { return true ; } if ( $ throwException ) { throw new InvalidArgumentException ( 'Unexpected filter operator.' ) ; } return false ; }
Returns whether the operator is valid or not .
57,096
static public function getChoices ( array $ operators ) { $ choices = [ ] ; foreach ( $ operators as $ operator ) { $ choices [ static :: getLabel ( $ operator ) ] = $ operator ; } return $ choices ; }
Returns the available operators choices .
57,097
private function isPropertyAccessible ( $ propertyName ) { $ result = false ; $ className = get_class ( $ this ) ; $ reflectionService = ReflectionService :: get ( ) ; if ( $ reflectionService -> isClassPropertyAccessible ( $ className , $ propertyName ) ) { $ property = $ reflectionService -> getClassAccessiblePropert...
Returns true if the given property name is accessible for the current instance of this class .
57,098
function queryColumn ( $ query ) { $ data = [ ] ; $ res = $ this -> q ( $ query ) ; while ( $ row = $ res -> fetch_row ( ) ) { if ( $ res -> field_count == 1 ) $ data [ ] = $ row [ 0 ] ; else $ data [ $ row [ 0 ] ] = $ row [ 1 ] ; } $ res -> close ( ) ; return $ data ; }
If two fields are queried the first is used as an index .
57,099
public function getPageManager ( ) { if ( $ this -> pageManager === null ) { $ this -> pageManager = new PageManager ( $ this ) ; } return $ this -> pageManager ; }
Gets the page manager .