idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
56,200
public function getPublisherHTML ( $ config = array ( ) ) { $ session_secret = "" ; $ fields = array ( 'config' => $ config ) ; $ webservice_url = '/ws/setruntimeoptions/' . $ this -> publisherKey ; if ( ! empty ( $ config ) ) { if ( array_key_exists ( "gameid" , $ config ) ) { $ webservice_url .= '/' . $ config [ 'gam...
Returns the markup for PlayThru . =
56,201
public function scoreResult ( ) { $ result = false ; if ( $ this -> sessionSecret ) { $ fields = array ( 'session_secret' => urlencode ( $ this -> sessionSecret ) , 'scoring_key' => $ this -> scoringKey ) ; $ resp = $ this -> doHttpsPostReturnJSONArray ( $ this -> webService , '/ws/scoreGame' , $ fields ) ; if ( $ resp...
Check whether the user is a human . Wrapper for the scoreGame API call
56,202
protected function doHttpsPostReturnJSONArray ( $ hostname , $ path , $ fields ) { $ result = $ this -> doHttpsPost ( $ hostname , $ path , $ fields ) ; if ( $ result ) { $ result = json_decode ( $ result ) ; } else { error_log ( "AYAH::doHttpsPostGetJSON: Post to https://$hostname$path returned no result." ) ; $ resul...
Do an HTTPS POST return some JSON decoded as array .
56,203
protected function doHttpsPost ( $ hostname , $ path , $ fields ) { $ result = '' ; $ fields_string = '' ; foreach ( $ fields as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( ! empty ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ fields_string .= $ key . '[' . $ k . ']=' . $ v . '&' ; } } else { $ fiel...
Initiate a request to the AYAH web service through curl or using a socket if the system does not have curl available .
56,204
public static function tableExists ( $ tableName ) { $ query = "SELECT 1 FROM $tableName LIMIT 1" ; try { $ result = Connection :: db ( ) -> query ( $ query ) ; } catch ( Exception $ e ) { return false ; } return $ result !== false ; }
Checks if a given table exists in the database
56,205
public static function getAll ( $ fields = null ) { $ table = self :: getTableNameFromClass ( ) ; if ( $ fields != null && is_array ( $ fields ) ) { $ query = "SELECT " . implode ( ', ' , $ fields ) . " FROM $table" ; } else { $ query = "SELECT * FROM $table" ; } $ res = [ ] ; $ results = Connection :: db ( ) -> query ...
Get all records from the record table
56,206
public static function getOne ( $ id , $ fields = null ) { $ table = self :: getTableNameFromClass ( ) ; if ( $ fields != null && is_array ( $ fields ) ) { $ query = "SELECT " . implode ( ', ' , $ fields ) . " FROM $table WHERE id = $id" ; } else { $ query = "SELECT * FROM $table WHERE id = $id" ; } $ res = [ ] ; $ res...
Get one record from the table based on the id provided
56,207
public function save ( ) { $ result ; if ( ! self :: $ id ) { $ query = "INSERT INTO $this->tableName (" . implode ( ", " , array_keys ( $ this -> props ) ) . ") VALUES(" ; for ( $ i = 0 ; $ i < count ( $ this -> props ) ; $ i ++ ) { $ query .= "?" ; if ( $ i != count ( $ this -> props ) - 1 ) { $ query .= "," ; } } $ ...
Save either a new or existing record
56,208
public static function destroy ( $ id ) { $ table = self :: getTableNameFromClass ( ) ; self :: getOne ( $ id ) ; $ query = "DELETE FROM $table WHERE id = " . $ id ; try { Connection :: db ( ) -> query ( $ query ) ; return true ; } catch ( Exception $ e ) { return false ; } }
Delete a record by id from the table in context
56,209
public function transform ( $ value ) : string { if ( null === $ value || '' === $ value ) { return '' ; } if ( ! is_numeric ( $ value ) ) { throw new TransformationFailedException ( 'Expected a numeric or null.' ) ; } if ( $ value >= PHP_INT_MAX || $ value <= - PHP_INT_MAX ) { throw new TransformationFailedException (...
Transforms a number type into number .
56,210
public function reverseTransform ( $ value ) { if ( ! is_scalar ( $ value ) ) { throw new TransformationFailedException ( 'Expected a scalar.' ) ; } if ( '' === $ value ) { return null ; } $ result = $ value ; if ( ! is_numeric ( $ result ) ) { throw new TransformationFailedException ( 'Value is not numeric.' ) ; } if ...
Transforms a normalized number into an integer or float .
56,211
protected function locateFile ( $ file ) { $ this -> locateFile && $ file = call_user_func ( $ this -> locateFile , $ file ) ; return $ file ; }
Convert file name by callback
56,212
public function getRevMap ( ) { if ( $ this -> revMap === null ) { if ( $ this -> revFile && is_file ( $ this -> revFile ) ) { $ this -> revMap = ( array ) json_decode ( file_get_contents ( $ this -> revFile ) ) ; } else { $ this -> revMap = [ ] ; } } return $ this -> revMap ; }
Returns rev file content that parsed to array
56,213
public function addRevFile ( $ file ) { $ this -> getRevMap ( ) ; if ( is_file ( $ file ) ) { $ this -> revMap = json_decode ( file_get_contents ( $ file ) , true ) + $ this -> revMap ; } return $ this ; }
Add rev map from file
56,214
public function getRevFile ( $ file ) { $ map = $ this -> getRevMap ( ) ; if ( isset ( $ map [ $ file ] ) ) { $ index = strrpos ( $ file , '.' ) ; $ file = $ this -> revPrefix . substr ( $ file , 0 , $ index ) . '-' . $ map [ $ file ] . substr ( $ file , $ index ) ; } return $ file ; }
Returns the file path contains revision
56,215
public function conectar ( $ destino , $ usuario , $ password = false ) { parent :: conectar ( $ destino , $ usuario , $ password ) ; $ this -> destino = $ destino ; $ this -> usuario = $ usuario ; $ this -> password = $ password ; $ this -> objeto = 'objetosLdap' ; }
Sobreescribirlo a este nivel obedece a que es en los objetos donde por ahora he visto la necesidad de acceder a las credenciales de conexion para tratar con diferentes objetos
56,216
public function actualizarObjetoLdap ( ) { if ( $ this -> existe ) { $ dn = $ this -> entrada [ 'dn' ] ; $ cambios = array ( ) ; foreach ( $ this -> cambios as $ atributos ) { $ cambios [ $ atributos ] = $ this -> entrada [ $ atributos ] ; } return $ this -> modificarEntradaLdap ( $ dn , $ cambios ) ; } else { $ this -...
Actualiza una entrada LDAP existente
56,217
protected function borrarObjetoLdap ( ) { if ( $ this -> existe ) { $ dn = $ this -> dnObjeto ; return $ this -> borrarEntradaLdap ( $ dn ) ; } else { $ this -> configurarErrorLdap ( 'Actualizacion' , 'Esa entrada no existe' ) ; return false ; } }
Borra el objeto que se ha consultado
56,218
public function setAppRoot ( array $ config ) { $ this -> app_name = $ config [ 'app_name' ] ; $ this -> app_dir = rtrim ( $ config [ 'app_dir' ] , '/' ) ; $ this -> debug = $ config [ 'debug' ] ; $ this -> config_dir = $ config [ 'config_dir' ] ; $ this -> view_dir = $ config [ 'view_dir' ] ; $ this -> vars_dir = $ co...
set up working directories .
56,219
public function loadConfig ( $ env_file = null ) { $ this -> configure ( $ this -> config_dir . '/configure' ) ; if ( $ this -> debug ) { $ this -> configure ( $ this -> config_dir . '/configure-debug' ) ; } $ this -> loadEnvironment ( $ env_file ) ; return $ this ; }
loads the main configuration for the application .
56,220
public function loadEnvironment ( $ env_file ) { $ env_file .= '.php' ; if ( ! file_exists ( $ env_file ) ) { return $ this ; } $ environments = ( array ) include ( $ env_file ) ; foreach ( $ environments as $ env ) { $ this -> configure ( $ this -> config_dir . "/{$env}/configure" ) ; } return $ this ; }
loads the environment based configuration .
56,221
public function catchError ( array $ error_files ) { $ this -> app -> set ( Web :: ERROR_VIEWS , $ error_files ) ; $ whoops = new Run ; if ( $ this -> debug ) { error_reporting ( E_ALL ) ; $ whoops -> pushHandler ( new PrettyPageHandler ) ; } else { error_reporting ( E_ERROR ) ; $ whoops -> pushHandler ( $ this -> getE...
set up global exception handler .
56,222
public function getLog ( ) { if ( $ this -> app -> exists ( LoggerInterface :: class ) ) { return $ this -> app -> get ( LoggerInterface :: class ) ; } $ var_dir = $ this -> vars_dir . '/log/app.log' ; $ logger = new Logger ( 'log' ) ; $ logger -> pushHandler ( new FingersCrossedHandler ( new StreamHandler ( $ var_dir ...
get shared logger . use Monolog as default .
56,223
public function lock ( $ id , $ value , array $ parameters = array ( ) ) { $ id = ltrim ( $ id , '\\' ) ; $ obj = $ this -> set ( $ id , $ value , $ parameters ) ; $ this -> offsetSet ( "lock.{$id}" , true ) ; return $ obj ; }
Set a value and prevent modification to return value
56,224
private function getUndefined ( $ fqClassName , array $ parameters ) { if ( ! empty ( $ parameters ) ) { $ reflectionClass = new ReflectionClass ( $ fqClassName ) ; return $ reflectionClass -> newInstanceArgs ( $ parameters ) ; } return new $ fqClassName ; }
If the service has not been defined within the container attempt to instantiate the class directly
56,225
private function getFiles ( $ path ) { $ files = array ( ) ; foreach ( new \ DirectoryIterator ( $ path ) as $ file ) { if ( $ file -> isDot ( ) || ( null != $ this -> scriptName && sprintf ( '%s.php' , $ this -> scriptName ) != $ file -> getFilename ( ) ) ) { continue ; } $ files [ $ file -> getFilename ( ) ] = sprint...
Get files for a specific path
56,226
public static function fromNative ( \ DateTimeInterface $ dateTime ) : Date { return new self ( ( int ) $ dateTime -> format ( 'Y' ) , ( int ) $ dateTime -> format ( 'm' ) , ( int ) $ dateTime -> format ( 'd' ) ) ; }
Creates a date object from the date part of the supplied date time .
56,227
public static function fromFormat ( string $ format , string $ dateString ) : Date { return self :: fromNative ( \ DateTimeImmutable :: createFromFormat ( $ format , $ dateString ) ) ; }
Creates a date object from the supplied format string
56,228
public function daysBetween ( Date $ other ) : int { return $ this -> dateTime -> diff ( $ other -> dateTime , true ) -> days ; }
Returns the amount of days between the supplied dates .
56,229
public function createService ( ServiceLocatorInterface $ serviceLocator ) { if ( ! $ serviceLocator -> has ( 'ServiceListener' ) ) { $ serviceLocator -> setFactory ( 'ServiceListener' , 'HumusMvc\Service\ServiceListenerFactory' ) ; } if ( ! $ serviceLocator -> has ( 'Zf1MvcListener' ) ) { $ serviceLocator -> setFactor...
Creates and returns the module manager
56,230
public function toArray ( $ ignoreEmpty = false ) { if ( ! $ ignoreEmpty ) { return $ this -> data ; } return array_filter ( $ this -> data , function ( $ value ) { return ! empty ( $ value ) ; } ) ; }
Extract data to an array
56,231
public function toString ( $ ignoreEmpty = false , $ numPrefix = null , $ separator = null ) { if ( empty ( $ separator ) ) { $ separator = '&' ; } return http_build_query ( $ this -> toArray ( $ ignoreEmpty ) , $ numPrefix , $ separator ) ; }
Extract data as a query string .
56,232
protected function fromArray ( $ data ) { if ( empty ( $ data ) ) { return $ this ; } $ this -> data = array_replace_recursive ( $ this -> data , $ data ) ; return $ this ; }
Set data from an array
56,233
protected function fromString ( $ queryString ) { if ( empty ( $ queryString ) ) { return $ this ; } $ data = array ( ) ; parse_str ( $ queryString , $ data ) ; $ this -> fromArray ( $ data ) ; return $ this ; }
Set data from a query string
56,234
private function getThemeAttributes ( ) { $ theme = Cii :: getConfig ( 'theme' , 'default' ) ; if ( ! file_exists ( Yii :: getPathOfAlias ( 'webroot.themes.' . $ theme ) . DIRECTORY_SEPARATOR . 'Theme.php' ) ) throw new CHttpException ( 400 , Yii :: t ( 'Api.setting' , 'The requested theme type is not set. Please set a...
Retrieves the appropriate model for the theme
56,235
private function loadData ( $ post , & $ model ) { $ model -> populate ( $ _POST , false ) ; if ( $ model -> save ( ) ) return $ this -> getModelAttributes ( $ model ) ; return $ this -> returnError ( 400 , NULL , $ model -> getErrors ( ) ) ; }
Populates and saves model attributes
56,236
private function getModelAttributes ( & $ model ) { $ response = array ( ) ; $ reflection = new ReflectionClass ( $ model ) ; $ properties = $ reflection -> getProperties ( ReflectionProperty :: IS_PROTECTED ) ; foreach ( $ properties as $ property ) $ response [ $ property -> name ] = $ model [ $ property -> name ] ; ...
Retrieves model attributes for a particular model
56,237
private function InitModule ( array $ idParts ) { if ( count ( $ idParts ) < 1 || count ( $ idParts ) > 2 ) { Response :: Redirect ( BackendRouter :: ModuleUrl ( new TemplateList ( ) ) ) ; } $ this -> module = ClassFinder :: CreateFrontendModule ( $ idParts [ 0 ] ) ; if ( ! $ this -> module instanceof FrontendModule ||...
Initializes the bundle and module names
56,238
protected function OnSuccess ( ) { $ newTemplate = $ this -> Value ( 'Name' ) ; $ action = Action :: Create ( ) ; if ( $ this -> template ) { $ action = Action :: Update ( ) ; $ this -> UpdateUsages ( $ newTemplate ) ; $ oldFile = $ this -> CalcFile ( $ this -> template ) ; if ( File :: Exists ( $ oldFile ) ) { File ::...
Saves the template into the given file name
56,239
public function getLocales ( ) { $ currentLocales = array ( ) ; foreach ( $ this -> localeCategories as $ category ) { if ( $ category === LC_ALL ) continue ; $ currentLocales [ $ category ] = setlocale ( $ category , 0 ) ; } return $ currentLocales ; }
Get all categories with its corresponding locale set
56,240
public function pad ( $ length = 0 , $ chars = ' ' , $ type = STR_PAD_BOTH ) { return new static ( str_pad ( $ this -> subject , $ length , $ chars , $ type ) ) ; }
Pad a string to a certain length with another string .
56,241
private function doRead ( string $ read , int $ length ) : string { if ( null === $ this -> handle ) { throw new \ LogicException ( 'Can not read from closed input stream.' ) ; } $ data = @ $ read ( $ this -> handle , $ length ) ; if ( false === $ data ) { $ error = lastErrorMessage ( 'unknown error' ) ; if ( ! @ feof ...
do actual read
56,242
public function bytesLeft ( ) : int { if ( null === $ this -> handle || ! is_resource ( $ this -> handle ) ) { throw new \ LogicException ( 'Can not read from closed input stream.' ) ; } $ bytesRead = ftell ( $ this -> handle ) ; if ( ! is_int ( $ bytesRead ) ) { return 0 ; } return $ this -> getResourceLength ( ) - $ ...
returns the amount of bytes left to be read
56,243
public function getUser ( $ id ) { $ request = $ this -> client -> get ( $ this -> customer [ 'url' ] . '/api/users/' . $ id ) ; $ request -> setAuth ( $ this -> customer [ 'username' ] , $ this -> customer [ 'password' ] ) ; $ response = $ request -> send ( ) ; return json_decode ( ( string ) $ response -> getBody ( t...
Get a specific user
56,244
public function patchUser ( $ id , array $ fields ) { $ request = $ this -> client -> patch ( $ this -> customer [ 'url' ] . '/api/users/' . $ id ) ; $ request -> setAuth ( $ this -> customer [ 'username' ] , $ this -> customer [ 'password' ] ) ; $ request -> setBody ( json_encode ( $ fields ) ) ; $ response = $ reques...
Edit an user fields .
56,245
public function setURLFromServerVars ( ) { if ( $ this -> server -> get ( 'REQUEST_SCHEME' ) ) { $ base = $ this -> server [ 'REQUEST_SCHEME' ] . '://' . $ this -> server [ 'SERVER_NAME' ] ; $ this -> url = new URL ( $ base . $ this -> server [ 'REQUEST_URI' ] ) ; $ this -> webroot = new URL ( $ base . rtrim ( dirname ...
Determine the webroot and the URL from server variables . Webroot is based on the location of the index . php that is executing which we consider to be the webroot .
56,246
public function startSession ( URL $ domain , Dictionary $ config ) { if ( $ this -> session === null ) { $ this -> session = new Session ( $ domain , $ config , $ this -> server ) ; $ this -> session -> start ( ) ; } return $ this ; }
Start the HTTP Session and initalize the session object
56,247
public function register ( FixtureLoader $ loader ) { $ value = new Pair ( $ loader -> getName ( ) , $ loader ) ; $ this -> loaders -> add ( $ value ) ; return $ this ; }
Register the loader of fixture
56,248
private static function getBasePath ( ) { if ( empty ( self :: $ basePath ) ) { self :: $ basePath = sprintf ( '%s%s%s' , sys_get_temp_dir ( ) , DIRECTORY_SEPARATOR , self :: BASE_PATH_NAME ) ; } return self :: $ basePath ; }
Get Base Path
56,249
private static function getWorkbenchPath ( ) { if ( empty ( self :: $ workbenchPath ) ) { self :: $ workbenchPath = sprintf ( '%s%s%s%s' , self :: getBasePath ( ) , DIRECTORY_SEPARATOR , time ( ) , rand ( 100 , 999 ) ) ; } return self :: $ workbenchPath ; }
Get Workbench Path
56,250
protected function getGenericDatabases ( array $ databases ) { $ genericDatabases = array ( ) ; foreach ( $ databases as $ database ) { $ genericDatabases [ ] = $ this -> getGenericDatabase ( $ database ) ; } return $ genericDatabases ; }
Gets the generic databases .
56,251
protected function getGenericSequences ( array $ sequences ) { $ genericSequences = array ( ) ; foreach ( $ sequences as $ sequence ) { $ genericSequences [ ] = $ this -> getGenericSequence ( $ sequence ) ; } return $ genericSequences ; }
Gets the generic sequences .
56,252
protected function getGenericSequence ( $ sequence ) { $ name = $ sequence [ 'name' ] ; $ initialValue = ( int ) $ sequence [ 'initial_value' ] ; $ incrementSize = ( int ) $ sequence [ 'increment_size' ] ; return new Sequence ( $ name , $ initialValue , $ incrementSize ) ; }
Gets the generic sequence .
56,253
protected function getGenericViews ( array $ views ) { $ genericViews = array ( ) ; foreach ( $ views as $ view ) { $ genericViews [ ] = $ this -> getGenericView ( $ view ) ; } return $ genericViews ; }
Gets the generic views .
56,254
protected function getGenericTableNames ( array $ tableNames ) { $ genericTableNames = array ( ) ; foreach ( $ tableNames as $ tableName ) { $ genericTableNames [ ] = $ this -> getGenericTableName ( $ tableName ) ; } return $ genericTableNames ; }
Gets the generic table names .
56,255
protected function getGenericColumns ( array $ columns ) { $ genericColumns = array ( ) ; foreach ( $ columns as $ column ) { $ genericColumns [ ] = $ this -> getGenericColumn ( $ column ) ; } return $ genericColumns ; }
Gets the generic table columns .
56,256
protected function getGenericColumn ( array $ column ) { $ name = $ column [ 'name' ] ; list ( $ column [ 'comment' ] , $ typeName ) = $ this -> extractTypeFromComment ( $ column [ 'comment' ] ) ; if ( $ typeName === null ) { $ typeName = $ this -> getConnection ( ) -> getPlatform ( ) -> getMappedType ( $ column [ 'typ...
Gets the generic table column .
56,257
protected function getGenericPrimaryKey ( array $ primaryKey ) { $ genericPrimaryKey = new PrimaryKey ( $ primaryKey [ 0 ] [ 'name' ] ) ; foreach ( $ primaryKey as $ primaryKeyColumn ) { $ genericPrimaryKey -> addColumnName ( $ primaryKeyColumn [ 'column_name' ] ) ; } return $ genericPrimaryKey ; }
Gets the generic table primary key .
56,258
protected function getGenericForeignKeys ( array $ foreignKeys ) { $ genericForeignKeys = array ( ) ; foreach ( $ foreignKeys as $ foreignKey ) { $ name = $ foreignKey [ 'name' ] ; if ( ! isset ( $ genericForeignKeys [ $ name ] ) ) { $ genericForeignKeys [ $ name ] = new ForeignKey ( $ foreignKey [ 'name' ] , array ( $...
Gets the generic table foreign keys .
56,259
protected function getGenericIndexes ( array $ indexes ) { $ genericIndexes = array ( ) ; foreach ( $ indexes as $ index ) { $ name = $ index [ 'name' ] ; if ( ! isset ( $ genericIndexes [ $ name ] ) ) { $ genericIndexes [ $ name ] = new Index ( $ name , array ( $ index [ 'column_name' ] ) , ( bool ) $ index [ 'unique'...
Gets the generic table indexes .
56,260
protected function getGenericChecks ( array $ checks ) { $ genericChecks = array ( ) ; foreach ( $ checks as $ check ) { $ genericChecks [ ] = new Check ( $ check [ 'name' ] , $ check [ 'definition' ] ) ; } return $ genericChecks ; }
Gets the generic table checks .
56,261
protected function extractTypeFromComment ( $ comment ) { if ( preg_match ( '/^(.*)\(FridgeType::([a-zA-Z0-9]+)\)$/' , $ comment , $ matches ) ) { if ( empty ( $ matches [ 1 ] ) ) { $ matches [ 1 ] = null ; } return array ( $ matches [ 1 ] , strtolower ( $ matches [ 2 ] ) ) ; } return array ( $ comment , null ) ; }
Extracts the type from the comment if it exists .
56,262
protected function tryMethod ( $ method , array $ arguments = array ( ) ) { try { call_user_func_array ( array ( $ this , $ method ) , $ arguments ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Tries to execute a method .
56,263
protected function restoreState ( array $ data ) { if ( isset ( $ data [ 'status' ] ) ) { $ this -> status = array_merge ( $ this -> status , $ data [ 'status' ] ) ; } if ( isset ( $ data [ 'jobUuid' ] ) ) { $ this -> jobUuid = $ data [ 'jobUuid' ] ; $ this -> logContext [ 'jobUuid' ] = $ data [ 'jobUuid' ] ; } else { ...
Restore state of task from data supplied by command
56,264
public function onKernelResponse ( FilterResponseEvent $ event ) { $ locale = $ this -> localeProvider -> determinePreferredLocale ( ) ; if ( empty ( $ locale ) ) { return ; } $ requestCookie = $ this -> cookieHelper -> read ( $ event -> getRequest ( ) ) ; if ( $ requestCookie && $ requestCookie -> getValue ( ) === $ l...
If there is a logged in user with a preferred language set it as a cookie .
56,265
public function beforeAuthenticate ( \ Magento \ Customer \ Model \ AccountManagement $ subject , $ username , $ password ) { try { $ mlmId = trim ( $ username ) ; $ found = $ this -> daoDwnlCust -> getByMlmId ( $ mlmId ) ; if ( $ found ) { $ custId = $ found -> getCustomerRef ( ) ; $ customer = $ this -> daoCust -> ge...
Look up for customer s email by MLM ID on authentication .
56,266
public function beforeCreateAccount ( \ Magento \ Customer \ Model \ AccountManagement $ subject , \ Magento \ Customer \ Api \ Data \ CustomerInterface $ customer , $ password = null , $ redirectUrl = '' ) { $ addrs = $ customer -> getAddresses ( ) ; if ( is_array ( $ addrs ) ) { foreach ( $ addrs as $ addr ) { $ coun...
Extract country code and save into Magento registry when customer is created through adminhtml .
56,267
public static function formatAsMoney ( $ value , $ currencySymbol = "&pound;" , $ roundToInteger = false ) { if ( is_numeric ( $ value ) ) return $ currencySymbol . number_format ( $ value , $ roundToInteger ? 0 : 2 , "." , "" ) ; else return null ; }
Convenience function for formatting a number as money using the supplied currency symbol
56,268
public function setCreatedResourceLink ( TimelineLinkEvent $ event ) : void { $ action = $ event -> getAction ( ) ; if ( 'created_resource' != $ action -> getVerb ( ) ) { return ; } $ production = $ action -> getComponent ( 'indirectComplement' ) -> getData ( ) ; $ resource = $ action -> getComponent ( 'directComplemen...
Set the link for the created resource .
56,269
private function setTableCell ( $ aElements , $ features = null ) { $ sReturn = null ; foreach ( $ aElements as $ key => $ value ) { $ value = str_replace ( [ '& ' , '\"' , "\'" ] , [ '&amp; ' , '"' , "'" ] , $ value ) ; if ( ( isset ( $ features [ 'grouping_cell' ] ) ) && ( $ features [ 'grouping_cell' ] == $ key ) ) ...
Generates a table cell
56,270
private function setTableHeader ( $ aElements , $ bHeadersBreaked ) { $ aTableHeader = $ aElements ; if ( $ bHeadersBreaked ) { $ aTableHeader = $ this -> setArrayToArrayKbr ( $ aElements ) ; } $ sReturn = [ ] ; foreach ( array_keys ( $ aTableHeader ) as $ value ) { $ sReturn [ ] = $ this -> setStringIntoTag ( $ value ...
Generates a table header
56,271
public function setNovaData ( Rock_Datet_DateObj $ dateObj ) { $ this -> format = $ dateObj -> getFormat ( ) ; $ this -> ts = $ dateObj -> getTimeStamp ( ) ; }
Substituir data de referencia por uma nova .
56,272
private function somaDia ( $ qtdDias ) { $ somaDia = $ qtdDias ; if ( $ qtdDias > 0 ) { $ somaDia = "+$qtdDias" ; } $ ts = strtotime ( "$somaDia day" , $ this -> ts ) ; return $ ts ; }
Soma dias .
56,273
private function ultimoDiaMes ( ) { $ ts = $ this -> ts ; $ mesAtual = strftime ( '%m' , $ ts ) ; $ mesTmp = $ mesAtual ; $ i = 0 ; while ( $ mesAtual == $ mesTmp ) { $ ts = $ this -> somaDia ( ++ $ i ) ; $ mesTmp = strftime ( '%m' , $ ts ) ; } return $ this -> somaDia ( -- $ i ) ; }
Calcula ultimo dia do mes .
56,274
public function syncPackages ( $ type ) { $ criteria = [ 'type' => $ type ] ; $ em = $ this -> getDoctrineHelper ( ) -> getEntityManager ( ) ; $ searchResults = $ this -> getHelper ( ) -> getPackages ( $ criteria ) ; foreach ( $ searchResults as $ result ) { $ package = $ this -> getHelper ( ) -> getPackage ( $ result ...
Searches for all packages of particular type and adds them to Smuggler
56,275
public function getConsoleCommandArguments ( Request $ request ) { $ port = ( int ) $ request -> attributes -> get ( 'port' ) ; $ package = $ request -> attributes -> get ( 'id' ) ; $ operation = $ request -> attributes -> get ( 'operation' ) ; return [ 'app/console' , 'wellcommerce:package:' . $ operation , '--port=' ...
Returns console command arguments
56,276
public function changePackageStatus ( Request $ request ) { $ id = $ request -> attributes -> get ( 'id' ) ; $ em = $ this -> getDoctrineHelper ( ) -> getEntityManager ( ) ; $ repository = $ this -> getRepository ( ) ; $ package = $ repository -> find ( $ id ) ; if ( null === $ package ) { throw new EntityNotFoundExcep...
Changes package info according to operation and data fetched from PackagistAPI
56,277
public static function fromString ( string $ dateTimeString , string $ timeZoneId ) : TimezonedDateTime { return new self ( new \ DateTimeImmutable ( $ dateTimeString , new \ DateTimeZone ( $ timeZoneId ) ) ) ; }
Creates a DateTime object from the supplied date string
56,278
public function convertTimezone ( string $ timezoneId ) : TimezonedDateTime { return new TimezonedDateTime ( ( new \ DateTimeImmutable ( 'now' , new \ DateTimeZone ( $ timezoneId ) ) ) -> setTimestamp ( $ this -> dateTime -> getTimestamp ( ) ) ) ; }
Returns the current date time according to the supplied timezone
56,279
public static function secondsSinceMidnightStr ( $ time ) { $ time_a = explode ( ':' , $ time ) ; switch ( count ( $ time_a ) ) { case 0 : case 1 : return null ; case 2 : $ time_a [ ] = 0 ; break ; case 3 : break ; default : return null ; } return self :: secondsSinceMidnight ( ( int ) $ time_a [ 0 ] , ( int ) $ time_a...
Return number of seconds since midnight .
56,280
public static function formatStrTime ( $ time , $ withSeconds = true ) { $ time = str_pad ( $ time . '' , 6 , '0' , STR_PAD_LEFT ) ; $ _time = array ( ) ; $ _time [ ] = substr ( $ time , 0 , 2 ) ; $ _time [ ] = substr ( $ time , 2 , 2 ) ; if ( $ withSeconds ) { $ _seconds = substr ( $ time , 4 , 2 ) ; $ _time [ ] = $ _...
Takes time in hhmmss format and returns formatted string .
56,281
final public function interpolate ( $ message , array $ context = array ( ) ) { return strtr ( $ message , array_combine ( array_map ( function ( $ key ) { return "{{$key}}" ; } , array_keys ( $ context ) ) , array_values ( $ context ) ) ) ; }
This is the default method for interpolating in PSR - 3 loggers
56,282
public static function isWord ( $ word ) { if ( ! is_string ( $ word ) ) { return false ; } return ( bool ) preg_match ( self :: WORD_FILTER , $ word ) ; }
Filters non - words out .
56,283
public function handleError ( $ errNumber , $ errString , $ errFile = '' , $ errLine = 0 ) { $ interfaceSettings = $ this -> cmd -> getConfigOpt ( 'interface' ) ; $ textColor = $ interfaceSettings [ 'error' ] [ 'text_color' ] ; $ textBgColor = $ interfaceSettings [ 'error' ] [ 'text_background' ] ; $ this -> env -> sen...
Handles generated errors .
56,284
public static function redirect ( $ url , array $ parameters = [ ] , int $ statusCode = Response :: STATUS_MOVED_PERMANENTLY ) : Response { if ( ! empty ( $ parameters ) ) { $ url = $ url . '?' . http_build_query ( $ parameters ) ; } $ headers = new Headers ( ) ; $ headers -> add ( new Header ( 'Location' , $ url ) ) ;...
Redirect to a url
56,285
public static function createFromString ( string $ string ) : Response { $ lines = explode ( "\r\n" , $ string ) ; list ( $ httpVersion , $ statusCode , $ statusText ) = explode ( ' ' , array_shift ( $ lines ) , 3 ) ; $ headers = new Headers ( ) ; foreach ( $ lines as $ index => $ line ) { unset ( $ lines [ $ index ] )...
Create a Response object from a string
56,286
public function getStatusLine ( ) : string { return sprintf ( 'HTTP/%s %s %s' , self :: HTTP_VERSION , $ this -> statusCode , self :: getStatusText ( $ this -> statusCode ) ) ; }
Get the complete status line
56,287
public function send ( ) { if ( headers_sent ( ) ) { throw new HttpException ( Response :: STATUS_INTERNAL_SERVER_ERROR , 'Headers already send' ) ; } header ( $ this -> getStatusLine ( ) ) ; foreach ( $ this -> headers as $ header ) { header ( $ header ) ; } echo $ this -> body ; }
Sends the response to the web server
56,288
public function isTranslatable ( $ vid ) { if ( ! is_numeric ( $ vid ) ) { $ vid = $ this -> vocabulary ( $ vid ) ; } return $ this -> vocabularyById [ $ vid ] -> isTranslatable ( ) ; }
Is this vocabulary translatable ?
56,289
public function getLanguage ( $ vocabulary_id , $ language_id = null ) { if ( ! $ this -> isTranslatable ( $ vocabulary_id ) ) { return 1 ; } if ( $ language_id === null ) { return I18N :: getCurrentId ( ) ; } return $ language_id ; }
Get the internal language for the vocabulary
56,290
public function vocabulary ( $ key ) { if ( is_numeric ( $ key ) ) { return $ this -> vocabularyById [ $ key ] -> machine_name ; } return $ this -> vocabularyByName [ $ key ] -> id ; }
Get a vocabulary by name or ID
56,291
public function uncacheTerm ( $ term_id ) { if ( array_key_exists ( $ term_id , $ this -> terms ) ) { unset ( $ this -> terms [ $ term_id ] ) ; } return $ this -> termRepository -> uncacheTerm ( $ term_id ) ; }
Remove a term from the cache
56,292
public function addParent ( $ term_id , $ parent_id ) { $ this -> testCanAddParents ( $ term_id , 1 ) ; $ this -> termHierarchyRepository -> addParent ( $ term_id , $ parent_id ) ; }
Add one parent to a term
56,293
public function addParents ( $ term_id , array $ parent_ids ) { $ this -> testCanAddParents ( $ term_id , count ( $ parent_ids ) ) ; foreach ( $ parent_ids as $ id ) { $ this -> termHierarchyRepository -> addParent ( $ term_id , $ id ) ; } }
Add a list of parents to a term
56,294
public function getTermsForVocabulary ( $ vocabulary_id ) { return $ this -> cache -> remember ( 'Rocket::Taxonomy::Terms::' . $ vocabulary_id , 60 , function ( ) use ( $ vocabulary_id ) { $ terms = TermContainer :: where ( 'vocabulary_id' , $ vocabulary_id ) -> get ( [ 'id' ] ) ; $ results = [ ] ; if ( ! empty ( $ ter...
Get all the terms of a vocabulary
56,295
public function searchTerm ( $ term , $ vocabulary_id , $ language_id = null , $ exclude = [ ] ) { $ language_id = $ this -> getLanguage ( $ vocabulary_id , $ language_id ) ; $ term = trim ( $ term ) ; if ( $ term == '' ) { return ; } $ query = TermData :: select ( 'taxonomy_terms.id' ) -> join ( 'taxonomy_terms' , 'ta...
Search a specific term if it doesn t exist returns false
56,296
public function getTermId ( $ title , $ vocabulary_id , $ language_id = null , $ type = 0 ) { $ title = trim ( $ title ) ; if ( $ title == '' ) { return false ; } if ( ! is_numeric ( $ vocabulary_id ) ) { $ vocabulary_id = $ this -> vocabulary ( $ vocabulary_id ) ; } $ language_id = $ this -> getLanguage ( $ vocabulary...
Returns the id of a term if it doesn t exist creates it .
56,297
public function getTermIds ( $ taxonomies ) { $ tags = [ ] ; foreach ( $ taxonomies as $ voc => $ terms ) { $ vocabulary_id = $ this -> vocabulary ( $ voc ) ; $ exploded = is_array ( $ terms ) ? $ terms : explode ( ',' , $ terms ) ; foreach ( $ exploded as $ term ) { $ result = $ this -> getTermId ( $ term , $ vocabula...
Adds one or more tags and returns an array of id s
56,298
public function getHttp ( ) { if ( ! $ this -> http ) { $ this -> http = new Http ( ) ; $ this -> http -> setRequest ( $ this ) ; } return $ this -> http ; }
Returns Http object
56,299
protected function getCountCommon ( $ data = array ( ) ) { parent :: getCountCommon ( $ data ) ; $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( $ this -> tableAlias . '.*' ) ; if ( ! empty ( $ data [ 'include_count' ] ) ) { $ subQuery = ' SELECT COUNT(DISTINCT post_id) ...
Set some common data