idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
56,800
protected function loadComposerFile ( ) { $ composerFile = $ this -> config [ 'appDir' ] . '/composer.json' ; if ( ! is_readable ( $ composerFile ) ) { throw new Exception ( sprintf ( 'Composer file "%s" is missing or not readable' , $ composerFile ) , ExitApp :: RUNTIME_ERROR ) ; } $ this -> config [ 'composer' ] = JS...
Parse composer . json
56,801
public function sayWelcome ( OutputInterface $ output ) { $ breakline = '' ; $ output = $ this -> createBlockTitle ( $ output ) ; $ title = $ this -> formatAsTitle ( 'RCHCapistranoBundle - Continuous Deployment' ) ; $ welcome = array ( $ breakline , $ title , $ breakline , 'This bundle provides continuous deployment fo...
Writes stylized welcome message in Output .
56,802
protected function formatAsTitle ( $ content ) { $ formatter = $ this -> getHelper ( 'formatter' ) ; $ title = $ formatter -> formatBlock ( $ content , 'title' , true ) ; return $ title ; }
Formats string as output block title .
56,803
public function show ( $ menu = null , $ model = null ) { return Redirect :: route ( 'admin.menus.menulinks.edit' , [ $ menu -> id , $ model -> id ] ) ; }
Show resource .
56,804
public function indexAction ( ) { $ extractedDoc = $ this -> get ( 'kreta_simple_api_doc.extractor.api_doc_extractor' ) -> all ( ) ; $ htmlContent = $ this -> get ( 'nelmio_api_doc.formatter.html_formatter' ) -> format ( $ extractedDoc ) ; return new Response ( $ htmlContent , 200 , [ 'Content-Type' => 'text/html' ] ) ...
The index action .
56,805
public function register ( $ method , $ path , $ action , $ filter = null ) { if ( strncmp ( $ path , '/' , 1 ) !== 0 ) { $ path = '/' . $ path ; } $ path = $ this -> app -> config ( 'url.root' ) . $ path ; $ params = [ ] ; $ matches = [ ] ; $ method = strtolower ( $ method ) ; if ( preg_match_all ( '/\{([\w-\.]+)\}/i'...
Register a url
56,806
public function routes ( $ method = null ) { if ( $ method && isset ( $ this -> methods [ $ method ] ) ) { return $ this -> routes [ $ method ] ; } return $ this -> routes ; }
Retrieve registered routes
56,807
public function getAction ( $ url ) { $ current = false ; $ method = $ this -> app -> request -> method ( ) ? : 'GET' ; $ method = strtolower ( $ method ) ; foreach ( $ this -> routes [ $ method ] as $ route ) { $ matches = [ ] ; if ( preg_match ( $ route [ 'pattern' ] , $ url , $ matches ) ) { if ( ! empty ( $ matches...
Retrieve model and method to execute
56,808
public function resource ( $ route , $ controller , $ filter = null ) { $ this -> register ( 'get' , $ route , [ $ controller , 'index' ] , $ filter ) ; $ this -> register ( 'get' , $ route . '/{id}' , [ $ controller , 'show' ] , $ filter ) ; $ this -> register ( 'post' , $ route , [ $ controller , 'store' ] , $ filter...
Register a resource
56,809
public function getFilter ( $ filterName = null ) { return isset ( $ this -> filters [ $ filterName ] ) ? $ this -> filters [ $ filterName ] : false ; }
Returns a route filter
56,810
public function performFilter ( $ filter ) { $ filter = $ this -> getFilter ( $ filter ) ; if ( ! $ filter ) { throw new \ Exception ( 'Filter not found' , 500 ) ; } if ( $ filter instanceof \ Closure ) { call_user_func ( $ filter ) ; return $ this -> setAppliedFilter ( $ filter ) ; } if ( is_array ( $ filter ) ) { lis...
Performs a filter
56,811
public function group ( ) { if ( func_num_args ( ) === 2 ) { list ( $ prefix , $ routes ) = func_get_args ( ) ; $ filter = null ; } elseif ( func_num_args ( ) === 3 ) { list ( $ filter , $ prefix , $ routes ) = func_get_args ( ) ; } if ( strncmp ( $ prefix , '/' , 1 ) !== 0 ) { $ prefix = '/' . $ prefix ; } if ( substr...
Register a group of routers with a common filter
56,812
public static function get ( $ name = 'default' ) { if ( ! isset ( self :: $ connections [ $ name ] ) ) { return null ; } $ connector = self :: $ connections [ $ name ] ; return $ connector -> connection ( ) ; }
Get a PDO - Connection
56,813
public function getCategoriesTree ( $ limit = 1000 , $ orderBy = 'hierarchy' , $ orderDir = 'asc' ) { return $ this -> dataset -> getResult ( 'tree' , [ 'limit' => $ limit , 'order_by' => $ orderBy , 'order_dir' => $ orderDir ] ) ; }
Returns categories tree
56,814
public static function getColoredString ( $ string , $ foreground_color = '' , $ background_color = '' ) { $ colored_string = '' ; if ( isset ( static :: $ foreground_colors [ $ foreground_color ] ) ) { $ colored_string .= "\033[" . static :: $ foreground_colors [ $ foreground_color ] . 'm' ; } if ( isset ( static :: $...
Returns colored string .
56,815
public function getDeviceType ( ) { $ device = $ this -> session -> get ( 'device' ) ; if ( empty ( $ device ) ) { $ detector = $ this -> getLibrary ( ) ; if ( $ detector -> isMobile ( ) ) { $ device = 'mobile' ; } else if ( $ detector -> isTablet ( ) ) { $ device = 'tablet' ; } else { $ device = 'desktop' ; } $ this -...
Returns a device type
56,816
protected function switchTheme ( Controller $ controller ) { if ( ! $ controller -> isInternalRoute ( ) ) { try { $ device = $ this -> getDeviceType ( ) ; $ store_id = $ controller -> getStoreId ( ) ; $ settings = $ this -> module -> getSettings ( 'device' ) ; if ( ! $ controller -> isBackend ( ) && $ device !== 'deskt...
Switch the current theme
56,817
public function sendEmailToSuperAdmins ( $ subject , $ event , $ emailBladeFile ) { $ superAdminEmails = config ( 'auth_frontend_registration_successful_admins_who_receive_notification_email' ) ; if ( count ( $ superAdminEmails ) == 0 ) { $ superAdminEmails [ ] = config ( 'lasallecmsusermanagement.administrator_first_a...
Send email notifications to the super admins
56,818
public function isSuperAdministrator ( $ email ) { $ userId = $ this -> findUserIdByEmail ( $ email ) ; if ( $ userId == 0 ) { return ; } if ( $ this -> isUserSuperAdministrator ( $ userId ) ) { return true ; } return false ; }
Does this email belong to a super administrator?
56,819
public function findUserIdByEmail ( $ email ) { $ userId = DB :: table ( 'users' ) -> where ( 'email' , $ email ) -> value ( 'id' ) ; if ( ! $ userId ) { return 0 ; } return $ userId ; }
Find the user s ID from their email address .
56,820
public function isUserSuperAdministrator ( $ userId ) { $ result = DB :: table ( 'user_group' ) -> where ( 'user_id' , $ userId ) -> where ( 'group_id' , 3 ) -> first ( ) ; if ( ! $ result ) { return false ; } return true ; }
Does the user belong to the Super Administrator user group?
56,821
public static function dbgTime ( $ s ) { if ( getenv ( 'DEBUG' ) == '1' ) { self :: printMessage ( '<' . Carbon :: now ( ) -> toTimeString ( ) . '> ' . self :: withCallsite ( $ s ) , 'comment' ) ; } }
Yellow text with current time
56,822
public static function nfoTime ( $ s ) { self :: printMessage ( '<' . Carbon :: now ( ) -> toTimeString ( ) . '> ' . self :: withCallsite ( $ s ) , 'info' ) ; }
Green text with current time
56,823
public static function errTime ( $ s ) { self :: printMessage ( '<' . Carbon :: now ( ) -> toTimeString ( ) . '> ' . self :: withCallsite ( $ s ) , 'error' ) ; }
White text on red background with current time
56,824
public function registerHandler ( $ handler , $ type = false ) { if ( ! is_object ( $ handler ) ) { throw new FilterExecutorException ( 'Handler must be an object.' ) ; } if ( $ type === false ) { $ type = $ this -> guessHandlerType ( $ handler ) ; if ( $ type === false ) { throw new FilterExecutorException ( 'Could no...
Registers specific filtration handler .
56,825
public function registerHandlers ( array $ handlers ) { foreach ( $ handlers as $ type => $ handler ) { if ( ! is_string ( $ type ) ) { $ type = $ this -> guessHandlerType ( $ handler ) ; } $ this -> registerHandler ( $ handler , $ type ) ; } return $ this ; }
Registers different filtration handlers .
56,826
protected function applyFilter ( FilterInterface $ filter , $ handler ) { if ( ! ( $ filter instanceof CustomApplyFilterInterface ) || ! is_callable ( $ filter -> getApplyFilterFunction ( ) ) ) { return $ filter -> applyFilter ( $ handler ) ; } return call_user_func ( $ filter -> getApplyFilterFunction ( ) , $ filter ,...
Applies filtration . If the filter has custom function for filtration applying than it will be used .
56,827
protected function guessHandlerType ( $ handler ) { if ( ! is_object ( $ handler ) ) { return false ; } foreach ( $ this -> availableHandlerTypes as $ type => $ classFQN ) { if ( $ handler instanceof $ classFQN ) { return $ type ; } } return false ; }
Guesses handler type by handler object class FQN . Basically it checks if the handler class name exists in the available handler types .
56,828
protected function getPluginClassByName ( $ name ) { if ( array_key_exists ( $ name , $ this -> plugins ) === false ) { return false ; } return $ this -> plugins [ $ name ] ; }
Returns the class name for the given name
56,829
protected function getPlugin ( $ name , callable $ constructClosure = null ) { static $ cache = array ( ) ; if ( array_key_exists ( $ name , $ cache ) === true ) { return $ cache [ $ name ] ; } $ class = $ this -> getPluginClassByName ( $ name ) ; if ( $ class === false ) { throw new Exception \ PluginNotFound ( "Plugi...
Method for fetching a singleton instance of a plugin
56,830
protected function readTypeFromJsonFileUniversal ( $ filePath , $ fileBaseName ) { $ fName = $ filePath . DIRECTORY_SEPARATOR . $ fileBaseName . '.min.json' ; $ fJson = fopen ( $ fName , 'r' ) ; $ jSonContent = fread ( $ fJson , filesize ( $ fName ) ) ; fclose ( $ fJson ) ; return json_decode ( $ jSonContent , true ) ;...
returns an array with non - standard holidays from a JSON file
56,831
public function setHolidays ( \ DateTime $ lngDate , $ inclCatholicEaster = false , $ inclWorkingHolidays = false ) { $ givenYear = $ lngDate -> format ( 'Y' ) ; $ daying = array_merge ( $ this -> setHolidaysOrthodoxEaster ( $ lngDate ) , $ this -> setHolidaysFixed ( $ lngDate ) ) ; if ( $ inclWorkingHolidays ) { $ day...
List of legal holidays
56,832
private function setHolidaysOrthodoxEaster ( \ DateTime $ lngDate ) { $ givenYear = $ lngDate -> format ( 'Y' ) ; $ daying = [ ] ; $ configPath = __DIR__ . DIRECTORY_SEPARATOR . 'json' ; $ statmentsArray = $ this -> readTypeFromJsonFileUniversal ( $ configPath , 'RomanianBankHolidays' ) ; if ( array_key_exists ( $ give...
List of all Orthodox holidays and Pentecost
56,833
public function setHolidaysInMonth ( \ DateTime $ lngDate , $ inclCatholicEaster = false ) { $ holidaysInGivenYear = $ this -> setHolidays ( $ lngDate , $ inclCatholicEaster ) ; $ thisMonthDayArray = $ this -> setMonthAllDaysIntoArray ( $ lngDate ) ; $ holidays = 0 ; foreach ( $ thisMonthDayArray as $ value ) { if ( in...
returns bank holidays in a given month
56,834
protected function setMonthAllDaysIntoArray ( \ DateTime $ lngDate ) { $ firstDayGivenMonth = strtotime ( $ lngDate -> modify ( 'first day of this month' ) -> format ( 'Y-m-d' ) ) ; $ lastDayInGivenMonth = strtotime ( $ lngDate -> modify ( 'last day of this month' ) -> format ( 'Y-m-d' ) ) ; $ secondsInOneDay = 24 * 60...
return an array with all days within a month from a given date
56,835
public function setWorkingDaysInMonth ( \ DateTime $ lngDate , $ inclCatholicEaster = false ) { $ holidaysInGivenYear = $ this -> setHolidays ( $ lngDate , $ inclCatholicEaster ) ; $ thisMonthDayArray = $ this -> setMonthAllDaysIntoArray ( $ lngDate ) ; $ workingDays = 0 ; foreach ( $ thisMonthDayArray as $ value ) { i...
returns working days in a given month
56,836
public function setDataCache ( \ TYPO3 \ CMS \ Core \ Cache \ Frontend \ VariableFrontend $ dataCache ) { $ this -> dataCache = $ dataCache ; }
Sets the data cache .
56,837
public function initialize ( ) { if ( $ this -> initialized ) { throw new Exception ( 'The Reflection Service can only be initialized once.' , 1232044696 ) ; } $ frameworkConfiguration = $ this -> configurationManager -> getConfiguration ( \ TYPO3 \ CMS \ Extbase \ Configuration \ ConfigurationManagerInterface :: CONFI...
Initializes this service
56,838
public function getClassTagsValues ( $ className ) { if ( ! isset ( $ this -> reflectedClassNames [ $ className ] ) ) { $ this -> reflectClass ( $ className ) ; } if ( ! isset ( $ this -> classTagsValues [ $ className ] ) ) { return [ ] ; } return isset ( $ this -> classTagsValues [ $ className ] ) ? $ this -> classTag...
Returns all tags and their values the specified class is tagged with
56,839
public function getClassTagValues ( $ className , $ tag ) { if ( ! isset ( $ this -> reflectedClassNames [ $ className ] ) ) { $ this -> reflectClass ( $ className ) ; } if ( ! isset ( $ this -> classTagsValues [ $ className ] ) ) { return [ ] ; } return isset ( $ this -> classTagsValues [ $ className ] [ $ tag ] ) ? $...
Returns the values of the specified class tag
56,840
public function isClassTaggedWith ( $ className , $ tag ) { if ( $ this -> initialized === false ) { return false ; } if ( ! isset ( $ this -> reflectedClassNames [ $ className ] ) ) { $ this -> reflectClass ( $ className ) ; } if ( ! isset ( $ this -> classTagsValues [ $ className ] ) ) { return false ; } return isset...
Tells if the specified class is tagged with the given tag
56,841
protected function getMethodReflection ( $ className , $ methodName ) { $ this -> dataCacheNeedsUpdate = true ; if ( ! isset ( $ this -> methodReflections [ $ className ] [ $ methodName ] ) ) { $ this -> methodReflections [ $ className ] [ $ methodName ] = new MethodReflection ( $ className , $ methodName ) ; } return ...
Returns the Reflection of a method .
56,842
protected function loadFromCache ( ) { $ data = $ this -> dataCache -> get ( $ this -> cacheIdentifier ) ; if ( $ data !== false ) { foreach ( $ data as $ propertyName => $ propertyValue ) { $ this -> { $ propertyName } = $ propertyValue ; } } }
Tries to load the reflection data from this service s cache .
56,843
protected function saveToCache ( ) { if ( ! is_object ( $ this -> dataCache ) ) { throw new Exception ( 'A cache must be injected before initializing the Reflection Service.' , 1232044697 ) ; } $ data = [ ] ; $ propertyNames = [ 'reflectedClassNames' , 'classPropertyNames' , 'classMethodNames' , 'classTagsValues' , 'me...
Exports the internal reflection data into the ReflectionData cache .
56,844
public function addListener ( $ event , $ method ) { if ( ! isset ( $ this -> listeners [ $ event ] ) ) { $ this -> listeners [ $ event ] = array ( ) ; } $ this -> listeners [ $ event ] [ ] = $ method ; }
Adds a listener for the specified event .
56,845
protected function addErrorToProperty ( string $ property , string $ key , string $ extensionName ) { $ errorMessage = LocalizationUtility :: translate ( $ key , $ extensionName ) ; $ error = $ this -> objectManager -> get ( Error :: class , $ errorMessage , time ( ) ) ; $ this -> result -> forProperty ( $ property ) -...
Adds an error to a property .
56,846
private function filterHrefWithPath ( $ matches ) { static $ script ; static $ observeRewrite ; static $ config ; static $ assetsPath ; if ( is_null ( $ config ) ) { $ application = Application :: getInstance ( ) ; $ config = $ application -> getConfig ( ) ; $ observeRewrite = $ application -> getRouter ( ) -> getServe...
callback to turn href shortcuts into site conform valid URLs tries to build a path reflecting the position of the page in a nested menu
56,847
private function filterHref ( $ matches ) { static $ script ; static $ observeRewrite ; if ( is_null ( $ script ) ) { $ script = trim ( Request :: createFromGlobals ( ) -> getScriptName ( ) , '/' ) ; } if ( is_null ( $ observeRewrite ) ) { $ observeRewrite = Application :: getInstance ( ) -> getRouter ( ) -> getServerS...
callback to turn href shortcuts into site conform valid URLs
56,848
public function optionLabelFilter ( $ value , $ objectName , $ fieldName ) { $ fieldConfiguration = $ this -> flexModel -> getField ( $ objectName , $ fieldName ) ; $ label = "" ; if ( is_array ( $ fieldConfiguration ) ) { if ( isset ( $ fieldConfiguration [ 'options' ] ) ) { if ( is_array ( $ value ) ) { foreach ( $ v...
Gets the option label based on the object and field name .
56,849
private function getLabelForValue ( $ fieldConfiguration , $ value ) { $ label = "" ; foreach ( $ fieldConfiguration [ 'options' ] as $ option ) { if ( $ option [ 'value' ] == $ value ) { $ label = $ option [ 'label' ] ; } } return $ label ; }
Gets the label for the set value .
56,850
public function fieldLabelFilter ( $ value , $ objectName , $ fieldName ) { $ fieldConfiguration = $ this -> flexModel -> getField ( $ objectName , $ fieldName ) ; $ label = "" ; if ( is_array ( $ fieldConfiguration ) ) { $ label = $ fieldConfiguration [ 'label' ] ; } return $ label ; }
Gets the field label based on the object and field name .
56,851
public function build ( $ type ) { if ( ! isset ( $ this -> types [ $ type ] ) ) { throw new \ Exception ( "Unknown request type." ) ; } return new $ this -> types [ $ type ] ( ) ; }
Builds the request object .
56,852
protected function processQuery ( Query $ query , $ context ) : Query { $ queryProperties = [ ] ; $ queryProperties [ 'table' ] = $ this -> processTable ( $ query -> table , $ context ) ; foreach ( $ query -> select as $ alias => $ select ) { $ queryProperties [ 'select' ] [ $ alias ] = $ this -> processSelect ( $ sele...
Processes a Query object . DOES NOT change the given query or it s components by the link but may return it .
56,853
protected function processTable ( $ table , $ context ) { if ( is_string ( $ table ) ) { return $ this -> processTableName ( $ table , $ context ) ; } else { return $ this -> processSubQuery ( $ table , $ context ) ; } }
Processes a table name or table subquery
56,854
protected function processSelect ( $ select , $ context ) { if ( $ select instanceof Aggregate ) { $ column = $ this -> processColumnOrSubQuery ( $ select -> column , $ context ) ; if ( $ column === $ select -> column ) { return $ select ; } else { return new Aggregate ( $ select -> function , $ column ) ; } } return $...
Processes a single select column .
56,855
protected function processColumnOrSubQuery ( $ column , $ context ) { if ( is_string ( $ column ) ) { return $ this -> processColumnName ( $ column , $ context ) ; } return $ this -> processSubQuery ( $ column , $ context ) ; }
Processes a column or subquery value .
56,856
protected function processSubQuery ( $ subQuery , $ context ) { if ( $ subQuery instanceof Query ) { return $ this -> processQuery ( $ subQuery , $ context ) ; } return $ subQuery ; }
Processes a subquery . Not - subquery values are just passed through .
56,857
protected function processInsert ( $ row , $ context ) { if ( $ row instanceof InsertFromSelect ) { return $ this -> processInsertFromSelect ( $ row , $ context ) ; } $ newRow = [ ] ; foreach ( $ row as $ column => $ value ) { $ column = $ this -> processColumnName ( $ column , $ context ) ; $ newRow [ $ column ] = $ t...
Processes a single insert statement .
56,858
protected function processInsertFromSelect ( InsertFromSelect $ row , $ context ) : InsertFromSelect { if ( $ row -> columns === null ) { $ columns = null ; } else { $ columns = [ ] ; foreach ( $ row -> columns as $ index => $ column ) { $ columns [ $ index ] = $ this -> processColumnName ( $ column , $ context ) ; } }...
Processes a single insert from select statement .
56,859
protected function processJoin ( Join $ join , $ context ) : Join { $ table = $ this -> processTable ( $ join -> table , $ context ) ; $ criteria = [ ] ; foreach ( $ join -> criteria as $ index => $ criterion ) { $ criteria [ $ index ] = $ this -> processCriterion ( $ criterion , $ context ) ; } if ( $ table === $ join...
Processes a single join .
56,860
protected function processOrder ( $ order , $ context ) { if ( $ order instanceof Order || $ order instanceof OrderByIsNull ) { $ column = $ this -> processColumnOrSubQuery ( $ order -> column , $ context ) ; if ( $ column === $ order -> column ) { return $ order ; } elseif ( $ order instanceof Order ) { return new Ord...
Processes a single order statement .
56,861
private function skip ( $ nav ) { if ( $ this -> excludeComments && $ nav -> getNodeType ( ) == XML_COMMENT_NODE ) { $ this -> commentsSkipped ++ ; } return ( $ this -> excludeComments && $ nav -> getNodeType ( ) == XML_COMMENT_NODE ) || ( $ this -> excludeWhitespace && $ nav -> IsWhitespaceNode ( ) ) ; }
Check whether to skip this node
56,862
public function get ( $ name = null , $ default = null ) { $ value = null ; if ( null === $ name ) { $ value = $ this -> data ; } elseif ( isset ( $ this -> data [ $ name ] ) ) { $ value = $ this -> data [ $ name ] ; } elseif ( null !== $ default ) { $ value = $ default ; } else { throw new \ Exception ( 'Key not found...
Get request data .
56,863
public function getRenderedParameter ( $ key , $ escaper = null ) { $ subject = $ this -> getParameter ( $ key ) ; preg_match_all ( '/{{([a-zA-Z0-9\.\-\_]+)}}/' , $ subject , $ matches ) ; $ parameterList = $ matches [ 1 ] ; foreach ( $ parameterList as $ parameterKey ) { $ val = $ this -> getParameter ( $ parameterKey...
used to transform a value in a parameter .
56,864
public function withDegree ( Integer $ degree , Number $ coeff ) : self { $ degrees = $ this -> degrees -> put ( $ degree -> value ( ) , new Degree ( $ degree , $ coeff ) ) ; return new self ( $ this -> intercept , ... $ degrees -> values ( ) ) ; }
Create a new polynom with this added degree
56,865
public function derived ( Number $ x , Number $ limit = null ) : Number { $ limit = $ limit ?? Tangent :: limit ( ) ; return divide ( subtract ( $ this ( add ( $ x , $ limit ) ) , $ this ( $ x ) ) , $ limit ) ; }
Compute the derived number of x
56,866
public function getGPIOPins ( ) { if ( true === in_array ( $ this -> revision , [ 'a01041' , 'a21041' , 'a22042' ] , true ) ) { return range ( 2 , 27 ) ; } if ( true === in_array ( $ this -> revision , [ 'a02082' , 'a22082' , 'a32082' ] , true ) ) { return range ( 2 , 27 ) ; } return [ 0 , 1 , 4 , 7 , 8 , 9 , 10 , 11 ,...
Get the valid GPIO pin map
56,867
public function getName ( ) { if ( false === isset ( self :: $ modelNameMap [ $ this -> revision ] ) ) { return 'unknown' ; } return self :: $ modelNameMap [ $ this -> revision ] ; }
Get the revision name
56,868
protected function createFactory ( ) { $ factory = Str :: studly ( class_basename ( $ this -> argument ( 'name' ) ) ) ; $ this -> call ( 'make:factory' , [ 'name' => "{$factory}Factory" , '--model' => $ this -> argument ( 'name' ) , ] ) ; }
Create a model factory for the model .
56,869
public function generateCode ( ) { $ this -> digits [ 0 ] = rand ( 0 , 9 ) ; $ this -> digits [ 1 ] = rand ( 0 , 9 ) ; $ this -> digits [ 2 ] = rand ( 0 , 9 ) ; $ this -> digits [ 3 ] = rand ( 0 , 9 ) ; $ this -> digits [ 4 ] = rand ( 0 , 9 ) ; $ this -> value = $ this -> digits [ 0 ] * 10000 + $ this -> digits [ 1 ] *...
generate captcha value
56,870
protected function configureRequest ( RequestInterface $ Request ) { if ( $ Request -> getStatus ( ) >= Curl :: STATUS_SENT ) { $ Request -> reset ( ) ; } if ( isset ( $ this -> properties [ self :: PROPERTY_HTTP_METHOD ] ) && $ this -> properties [ self :: PROPERTY_HTTP_METHOD ] !== '' ) { $ Request -> setMethod ( $ t...
Verifies URL and Data are setup then sets them on the Request Object
56,871
protected function configureResponse ( ResponseInterface $ Response ) { $ Response -> setRequest ( $ this -> Request ) ; $ Response -> extract ( ) ; return $ Response ; }
Configure the Response Object after sending of the Request
56,872
private function verifyUrl ( $ url ) { if ( strpos ( $ url , static :: $ _URL_VAR_CHARACTER ) !== false ) { throw new InvalidUrl ( array ( get_class ( $ this ) , $ url ) ) ; } return true ; }
Verify if URL is configured properly
56,873
protected function requiresOptions ( ) { $ url = $ this -> getEndPointUrl ( ) ; $ variables = $ this -> extractUrlVariables ( $ url ) ; return ! empty ( $ variables ) ; }
Checks if Endpoint URL requires Options
56,874
protected function extractUrlVariables ( $ url ) { $ variables = array ( ) ; $ pattern = "/(\\" . static :: $ _URL_VAR_CHARACTER . ".*?[^\\/]*)/" ; if ( preg_match ( $ pattern , $ url , $ matches ) ) { array_shift ( $ matches ) ; foreach ( $ matches as $ match ) { $ variables [ ] = $ match [ 0 ] ; } } return $ variable...
Helper method for extracting variables via Regex from a passed in URL
56,875
public function lead ( ) : Number { return $ this -> reduce ( new Integer ( 0 ) , static function ( Number $ lead , Number $ number ) : Number { if ( ! $ lead -> equals ( new Integer ( 0 ) ) ) { return $ lead ; } return $ number ; } ) ; }
First non zero number found
56,876
public function log ( $ message ) { if ( ! $ this -> enableLogging ) return ; if ( ! isset ( $ this -> log ) ) $ this -> log = \ lyquidity \ XPath2 \ lyquidity \ Log :: getInstance ( ) ; $ this -> log -> info ( $ message ) ; }
Log a message to the current log target
56,877
protected function yyExpecting ( $ state ) { $ token = 0 ; $ n = 0 ; $ len = 0 ; $ ok = array_fill ( 0 , count ( XPath2Parser :: $ yyName ) , false ) ; if ( ( $ n = XPath2Parser :: $ yySindex [ $ state ] ) != 0 ) { for ( $ token = $ n < 0 ? - $ n : 0 ; ( $ token < count ( XPath2Parser :: $ yyName ) && ( $ n + $ token <...
computes list of expected tokens on error by tracing the tables .
56,878
public function get ( CacheableInterface $ item ) { $ targetFile = $ this -> getTargetFile ( $ item -> getHashKey ( ) ) ; $ return = false ; if ( file_exists ( $ targetFile ) ) { if ( $ item -> getTtl ( ) > 0 && ( ( filemtime ( $ targetFile ) + $ item -> getTtl ( ) ) < time ( ) ) ) { $ this -> remove ( $ item ) ; } els...
Get value from cache Must return false when cache is expired or invalid
56,879
public function init ( $ config = NULL ) { parent :: init ( $ config ) ; if ( ! isset ( $ config [ 'migration_path' ] ) ) { throw new \ InvalidArgumentException ( 'Missing migration_path parameter' ) ; } foreach ( $ config as $ key => $ value ) { switch ( $ key ) { case 'migration_path' : $ this -> migrationPath = $ va...
Initialises the migrator .
56,880
public function createMigration ( ) { $ date = new \ DateTime ( ) ; $ tStamp = substr ( $ date -> format ( 'U' ) , 2 ) ; if ( self :: STYLE_CAMEL_CASE !== $ this -> migrationClassStyle ) { $ parts = preg_split ( '/(?=[A-Z])/' , $ this -> migrationClass , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ className = $ this -> classPrefix...
Creates a new migration class file .
56,881
public function getMigrationTemplate ( $ name ) { $ template = '<?php' . PHP_EOL . PHP_EOL ; if ( '' !== $ this -> migrationNamespace ) { $ template .= 'namespace ' . $ this -> migrationNamespace . ';' . PHP_EOL . PHP_EOL ; } $ template .= 'use RawPHP\RawMigrator\Migration;' . PHP_EOL ; $ template .= 'use RawPHP\RawDat...
Creates the migration template file code .
56,882
public function createMigrationTable ( ) { if ( empty ( $ this -> migrationTable ) ) { throw new RawException ( 'Migration table name must be set' ) ; } $ result = NULL ; $ table = array ( 'migration_id' => 'INTEGER(11) PRIMARY KEY AUTO_INCREMENT NOT NULL' , 'migration_name' => 'VARCHAR(128) NOT NULL' , 'migration_date...
Creates the migration database table if it doesn t exist .
56,883
public function getMigrations ( ) { $ migrations = array ( ) ; $ dir = opendir ( $ this -> migrationPath ) ; while ( ( $ file = readdir ( $ dir ) ) !== FALSE ) { if ( '.' !== $ file && '..' !== $ file ) { $ migrations [ ] = str_replace ( '.php' , '' , $ file ) ; } } closedir ( $ dir ) ; usort ( $ migrations , array ( $...
Returns a list of migration files .
56,884
public function getNewMigrations ( ) { $ exists = $ this -> db -> tableExists ( $ this -> migrationTable ) ; if ( ! $ exists ) { $ this -> createMigrationTable ( ) ; } $ query = "SELECT * FROM $this->migrationTable" ; $ applied = $ this -> db -> query ( $ query ) ; $ migrations = $ this -> getMigrations ( ) ; $ list = ...
Returns a list of new migrations .
56,885
public function getAppliedMigrations ( ) { $ query = "SELECT * FROM $this->migrationTable" ; $ applied = $ this -> db -> query ( $ query ) ; $ list = array ( ) ; foreach ( $ applied as $ mig ) { $ list [ ] = $ mig [ 'migration_name' ] ; } $ list = array_reverse ( $ list ) ; return $ this -> filter ( self :: ON_GET_APPL...
Returns a list of applied migrations .
56,886
public function migrateUp ( $ levels = NULL ) { if ( NULL !== $ levels ) { $ this -> levels = $ levels ; } $ newMigrations = $ this -> getNewMigrations ( ) ; $ i = 0 ; if ( self :: MIGRATE_ALL === $ this -> levels || $ this -> levels > count ( $ newMigrations ) ) { $ this -> levels = count ( $ newMigrations ) ; } while...
Runs the UP migration .
56,887
public function migrateDown ( $ levels = NULL ) { if ( NULL !== $ levels ) { $ this -> levels = $ levels ; } $ migrations = $ this -> getAppliedMigrations ( ) ; $ i = 0 ; if ( self :: MIGRATE_ALL === $ this -> levels || $ this -> levels > count ( $ migrations ) ) { $ this -> levels = count ( $ migrations ) ; } while ( ...
Runs the DOWN migration .
56,888
private function _addMigrationRecord ( $ class ) { $ name = $ this -> db -> prepareString ( $ class ) ; $ tm = new \ DateTime ( ) ; $ tm = $ tm -> getTimestamp ( ) ; $ query = "INSERT INTO $this->migrationTable ( migration_name, migration_date_applied ) VALUES ( " ; $ query .= "'$name', " ; $ query .= ...
Inserts an applied migration into the database .
56,889
private function _deleteMigrationRecord ( $ class ) { $ name = $ this -> db -> prepareString ( $ class ) ; $ query = "DELETE FROM $this->migrationTable WHERE migration_name = '$name'" ; $ this -> db -> lockTables ( $ this -> migrationTable ) ; $ result = $ this -> db -> execute ( $ query ) ; if ( $ this -> verbose ) { ...
Deletes a migration entry from the database .
56,890
public function lock ( $ lockName ) { $ lockHandle = $ this -> lockProvider -> lock ( $ lockName ) ; if ( $ lockHandle === false ) { return false ; } $ this -> lockList [ $ lockName ] = $ lockHandle ; return true ; }
Attempts to acquire a single lock by name and adds it to the lock set .
56,891
public function toArray ( ) { $ results = [ ] ; foreach ( $ this -> claims as $ claim ) { $ results [ $ claim -> getName ( ) ] = $ claim -> getValue ( ) ; } return $ results ; }
Get the array of claims .
56,892
public function addCalendarEvent ( $ postValues ) { $ responseData = array ( ) ; $ calendarTable = $ this -> getServiceLocator ( ) -> get ( 'MelisCalendarTable' ) ; $ melisCoreAuth = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreAuth' ) ; $ userAuthDatas = $ melisCoreAuth -> getStorage ( ) -> read ( ) ; $ userId =...
Adding and Updating Calendar Event
56,893
public function deleteCalendarEvent ( $ postValues ) { $ calId = null ; $ calendarTable = $ this -> getServiceLocator ( ) -> get ( 'MelisCalendarTable' ) ; $ resultEvent = $ calendarTable -> getEntryById ( $ postValues [ 'cal_id' ] ) ; if ( ! empty ( $ resultEvent ) ) { $ event = $ resultEvent -> current ( ) ; if ( ! e...
Deleting Calendar Item Event
56,894
protected function accessDenied ( $ user , $ message = NULL ) { http_response_code ( 403 ) ; Yii :: app ( ) -> controller -> renderOutput ( array ( ) , 403 , $ message ) ; }
Denies the access of the user . This method is invoked when access check fails .
56,895
public function addLoyaltyPoints ( $ user_id , $ transaction_value , $ platform = null , $ service = null , $ expires_in_days = null , $ transaction_id = null , $ meta = null , $ tag = null , $ frozen = false ) { $ url = $ this -> authenticationService -> getServerEndPoint ( ) . Endpoints :: VERSION . Endpoints :: BASE...
Add loyalty points to users wallet
56,896
public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ q = $ this -> getQuery ( ) ; $ t = $ this -> getType ( ) ; $ scope = $ params -> getSubScope ( $ this -> sub_scope_number ) ; $ this -> sub_scope_number = $ scope -> getScopeID ( ) ; return 'UNION ' . $ t . ' (' . $ params -> getDriver ( ) -> toSQL...
Write a UNION clause as SQL query synta
56,897
public static function getRules ( ) { $ rules = static :: rules ( ) ; if ( RevyAdmin :: isTranslationMode ( ) ) { $ object = new static ( ) ; foreach ( $ rules as $ field => $ rule ) { if ( $ object -> isTranslatableField ( $ field ) ) { unset ( $ rules [ $ field ] ) ; foreach ( Language :: getLocales ( ) as $ locale )...
Validation default rules
56,898
protected function resolveErrorKey ( $ messages = [ ] ) { if ( empty ( $ this -> errorKey ) ) { return $ messages ; } $ keys = explode ( '.' , $ this -> errorKey ) ; $ keys = array_reverse ( $ keys ) ; foreach ( $ keys as $ errorKey ) { $ messages = array ( $ errorKey => $ messages ) ; } return $ messages ; }
Nest messages according to error key
56,899
public function addErrors ( $ messages = [ ] ) { if ( ! is_array ( $ messages ) && ! $ messages instanceof MessageProvider ) { $ messages = ( array ) $ messages ; } return $ this -> errors -> merge ( $ this -> resolveErrorKey ( $ messages ) ) ; }
Add messages to error message bag