idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
3,800
public function orderConfirmationAction ( Request $ request , $ id ) { $ locale = $ this -> getLocale ( $ request ) ; $ this -> get ( 'translator' ) -> setLocale ( $ locale ) ; try { $ orderApiEntity = $ this -> getOrderManager ( ) -> findByIdAndLocale ( $ id , $ locale ) ; $ order = $ orderApiEntity -> getEntity ( ) ;...
Finds a order object by a given id from the url and returns a rendered pdf in a download window
3,801
public function open ( ) : bool { $ path = $ this -> getOptionOrDefault ( 'path' ) ; if ( is_resource ( $ path ) ) { $ this -> resource = $ path ; return true ; } $ context = $ this -> getOptionOrDefault ( 'context' ) ; if ( is_resource ( $ context ) ) { $ this -> resource = @ fopen ( $ path , 'ab' , false , $ context ...
Open a log destination .
3,802
public static function factory ( array $ middlewares = array ( ) ) { $ runner = null ; foreach ( $ middlewares as $ middleware ) { $ runner = $ runner ? $ runner -> add ( $ middleware ) : new static ( $ middleware ) ; } return $ runner ; }
Creates a runner based on an array of middleware
3,803
public static function collapseSerialized ( EloquentCollection $ collection ) { return $ collection -> map ( function ( SerializedModel $ menu_item ) { return $ menu_item -> serialized ( ) ; } ) -> collapse ( ) ; }
Collapse a keyed Eloquent Collection .
3,804
public function addUser ( $ user ) { if ( ! $ this -> hasUser ( $ user ) ) { return RoleUser :: create ( [ 'role_id' => $ this -> id , 'user_id' => $ user -> id ] ) ; } return false ; }
Adds a user into the role .
3,805
public function addPermission ( $ permission ) { if ( ! $ this -> hasPermission ( $ permission ) ) { return PermissionRole :: create ( [ 'role_id' => $ this -> id , 'permission_id' => $ permission -> id ] ) ; } return false ; }
Adds a permission into the role .
3,806
public function deleteUser ( $ user ) { if ( $ this -> hasUser ( $ user ) ) { return RoleUser :: where ( [ 'role_id' => $ this -> id , 'user_id' => $ user -> id ] ) -> first ( ) -> delete ( ) ; } return false ; }
Deletes the specified role user .
3,807
public function deletePermission ( $ permission ) { if ( $ this -> hasPermission ( $ permission ) ) { return PermissionRole :: where ( [ 'role_id' => $ this -> id , 'permission_id' => $ permission -> id ] ) -> first ( ) -> delete ( ) ; } return false ; }
Deletes the specified role permission .
3,808
public function process ( StorableInterface $ object ) { if ( is_array ( $ this -> backends ) && count ( $ this -> backends ) > 0 ) { $ results = [ ] ; $ identifiers = $ object -> getStorableBackendIdentifiers ( ) ; foreach ( $ this -> backends as $ identifier => $ backend ) { if ( in_array ( $ identifier , $ identifie...
Runs through each storage backend and processes the Storable object
3,809
protected function toUtf8 ( $ string ) { if ( $ this -> getEncoding ( ) === 'utf-8' ) { $ result = $ string ; } else { $ result = $ this -> convertEncoding ( $ string , 'UTF-8' , $ this -> getEncoding ( ) ) ; } return $ result ; }
Convert string to UTF - 8
3,810
private function addParameterFallback ( $ name , $ fallbackData = null ) { if ( ! isset ( $ this -> parameters [ $ name ] ) && ! empty ( $ fallbackData ) ) { $ this -> parameters [ $ name ] = $ fallbackData ; } }
This will add fallback data to the parameters if the key is not set .
3,811
public function inject ( ContainerBuilder $ container ) { foreach ( $ this -> schema as $ parameter ) { $ value = $ parameter [ 'default' ] ; if ( $ this -> parametersStorage -> has ( $ parameter [ 'key' ] ) ) { $ value = $ this -> parametersStorage -> get ( $ parameter [ 'key' ] ) ; } $ container -> setParameter ( $ t...
Inject dynamic parameters in the container builder
3,812
public function rebuild ( Kernel $ kernel ) { $ kernelReflectionClass = new \ ReflectionClass ( $ kernel ) ; $ buildContainerReflectionMethod = $ kernelReflectionClass -> getMethod ( 'buildContainer' ) ; $ buildContainerReflectionMethod -> setAccessible ( true ) ; $ dumpContainerReflectionMethod = $ kernelReflectionCla...
Rebuild the container and dump it to the cache to apply change on redis stored parameters
3,813
public function filterByCreateDate ( $ createDate = null , $ comparison = null ) { if ( is_array ( $ createDate ) ) { $ useMinMax = false ; if ( isset ( $ createDate [ 'min' ] ) ) { $ this -> addUsingAlias ( RoleTableMap :: COL_CREATE_DATE , $ createDate [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } ...
Filter the query on the create_date column
3,814
public function filterByUpdateDate ( $ updateDate = null , $ comparison = null ) { if ( is_array ( $ updateDate ) ) { $ useMinMax = false ; if ( isset ( $ updateDate [ 'min' ] ) ) { $ this -> addUsingAlias ( RoleTableMap :: COL_UPDATE_DATE , $ updateDate [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } ...
Filter the query on the update_date column
3,815
public function filterByUserRole ( $ userRole , $ comparison = null ) { if ( $ userRole instanceof \ Alchemy \ Component \ Cerberus \ Model \ UserRole ) { return $ this -> addUsingAlias ( RoleTableMap :: COL_ID , $ userRole -> getRoleId ( ) , $ comparison ) ; } elseif ( $ userRole instanceof ObjectCollection ) { return...
Filter the query by a related \ Alchemy \ Component \ Cerberus \ Model \ UserRole object
3,816
public function useUserRoleQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinUserRole ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'UserRole' , '\Alchemy\Component\Cerberus\Model\UserRoleQuery' ) ; }
Use the UserRole relation UserRole object
3,817
public function useRolePermissionQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinRolePermission ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'RolePermission' , '\Alchemy\Component\Cerberus\Model\RolePermissionQuery' ) ; }
Use the RolePermission relation RolePermission object
3,818
public function filterByUser ( $ user , $ comparison = Criteria :: EQUAL ) { return $ this -> useUserRoleQuery ( ) -> filterByUser ( $ user , $ comparison ) -> endUse ( ) ; }
Filter the query by a related User object using the user_role table as cross reference
3,819
public function filterByPermission ( $ permission , $ comparison = Criteria :: EQUAL ) { return $ this -> useRolePermissionQuery ( ) -> filterByPermission ( $ permission , $ comparison ) -> endUse ( ) ; }
Filter the query by a related Permission object using the role_permission table as cross reference
3,820
public function doDeleteAll ( ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( RoleTableMap :: DATABASE_NAME ) ; } return $ con -> transaction ( function ( ) use ( $ con ) { $ affectedRows = 0 ; $ affectedRows += parent :: doDeleteAll ( $ con...
Deletes all rows from the role table .
3,821
public function delete ( ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( RoleTableMap :: DATABASE_NAME ) ; } $ criteria = $ this ; $ criteria -> setDbName ( RoleTableMap :: DATABASE_NAME ) ; return $ con -> transaction ( function ( ) use ( $...
Performs a DELETE on the database based on the current ModelCriteria
3,822
public function start ( ) { $ data = $ this -> handler -> read ( $ this -> get_id ( ) ) ; if ( false !== $ data && ! is_null ( $ data ) && is_array ( $ data ) ) { $ this -> attributes = $ data ; } $ this -> started = true ; }
Start the session reading the data from a handler .
3,823
public function keep ( $ keys = null ) { $ keys = is_array ( $ keys ) ? $ keys : func_get_args ( ) ; $ this -> merge_new_flashes ( $ keys ) ; $ this -> remove_old_flash_data ( $ keys ) ; }
Reflash a subset of the current flash data .
3,824
public function regenerate ( $ destroy = false ) { if ( $ destroy ) { $ this -> handler -> destroy ( $ this -> get_id ( ) ) ; } $ this -> set_id ( $ this -> generate_session_id ( ) ) ; return true ; }
Generate a new session identifier .
3,825
public function set_id ( $ id ) { $ this -> id = $ this -> is_valid_id ( $ id ) ? $ id : $ this -> generate_session_id ( ) ; }
Set the session ID .
3,826
protected function generate_session_id ( ) { $ length = 40 ; require_once ABSPATH . 'wp-includes/class-phpass.php' ; $ bytes = ( new \ PasswordHash ( 8 , false ) ) -> get_random_bytes ( $ length * 2 ) ; return substr ( str_replace ( [ '/' , '+' , '=' ] , '' , base64_encode ( $ bytes ) ) , 0 , $ length ) ; }
Get a new random session ID .
3,827
public function getCurrentRouteMatch ( ) { if ( empty ( $ this -> currentRouteMatch ) ) { $ this -> currentRouteMatch = \ Drupal :: service ( 'current_route_match' ) ; } return $ this -> currentRouteMatch ; }
Gets the current route match .
3,828
protected function setCssContent ( $ cssContent ) { if ( is_string ( $ cssContent ) ) { $ this -> content = $ cssContent ; } else { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ cssContent ) . "' for argument 'cssContent' given." ) ; } return $ this ; }
Sets the CSS source content .
3,829
protected function migrate ( ) { if ( ! $ this -> container [ 'migrator' ] -> repositoryExists ( ) ) { throw new Exception ( 'Migration table not found.' ) ; } $ this -> container [ 'migrator' ] -> run ( $ this -> getAttribute ( 'path' ) . '/database/migrations' ) ; }
Execute module migrations .
3,830
protected function rollback ( ) { if ( ! $ this -> container [ 'migrator' ] -> repositoryExists ( ) ) { throw new Exception ( 'Migration table not found.' ) ; } $ this -> container [ 'migrator' ] -> rollback ( $ this -> getAttribute ( 'path' ) . '/database/migrations' ) ; }
Rollback module migrations .
3,831
protected function seed ( ) { $ seederFilePath = $ this -> getAttribute ( 'path' ) . '/database/seeds/DatabaseSeeder.php' ; if ( $ this -> container [ 'files' ] -> exists ( $ seederFilePath ) ) { require_once $ seederFilePath ; $ namespace = $ this -> getAttribute ( 'namespace' ) . 'Database\\Seeds\\DatabaseSeeder' ; $...
Seed the database with module seeders .
3,832
public function getOriginalHeader ( $ name ) { return array_key_exists ( $ name , $ this -> _request ) ? $ this -> _request [ $ name ] : null ; }
Get the original HTTP header value from the request
3,833
protected function primeCommandArray ( ) { if ( empty ( $ this -> layoutName ) ) { throw new LayoutNameIsMissingException ( 'You must specify a layout name.' ) ; } $ this -> commandArray [ '-db' ] = $ this -> adapter -> getHostConnection ( ) -> getDbName ( ) ; $ this -> commandArray [ '-lay' ] = $ this -> layoutName ; ...
Adds the default url parameters needed for any request .
3,834
protected function addToCommandArray ( $ values ) { foreach ( $ values as $ key => $ value ) { $ this -> commandArray [ $ key ] = $ value ; } }
Adds additional Url parameters to the request .
3,835
public function executeCommand ( ) { $ this -> adapter -> setCommandArray ( $ this -> commandArray ) ; $ result = $ this -> adapter -> execute ( ) ; $ commandArrayUsed = $ this -> adapter -> getCommandArray ( ) ; $ this -> clearCommandArray ( ) ; $ this -> checkResultForError ( $ result , $ commandArrayUsed ) ; return ...
Performs the steps necessary to execute a SimpleFM query .
3,836
protected function checkResultForError ( $ result , $ commandArrayUsed ) { if ( empty ( $ result ) ) { throw new NoResultReturnedException ( 'The SimpleFM request did not return a result.' ) ; } if ( $ result -> getErrorCode ( ) == 401 ) { throw new RecordsNotFoundException ( $ result -> getErrorMessage ( ) , $ result ...
Parses the SimpleFM result and determines if a FileMaker error was thrown .
3,837
public function persist ( ProfileInterface $ profile ) { foreach ( $ this -> persistenceHandlers as $ persistenceHandler ) { $ persistenceHandler -> persist ( $ profile ) ; } return $ this ; }
Persists data to the persistence handlers
3,838
public function removeEval ( $ key ) { if ( array_key_exists ( $ key , $ this -> eval ) ) { unset ( $ this -> eval [ $ key ] ) ; return true ; } return false ; }
Remove an entry vom the eval array Returns true if entry was removed and false if key was not found
3,839
public function modifyEval ( $ key , $ value ) { if ( array_key_exists ( $ key , $ this -> eval ) ) { $ this -> eval [ $ key ] = $ value ; } }
Set a new value to an existing eval entry
3,840
public function getEval ( $ key ) { if ( array_key_exists ( $ key , $ this -> eval ) ) { return $ this -> eval [ $ key ] ; } return false ; }
Get an entry from the eval array Returns the entry or false if key not found
3,841
public static function replaceStringsAndComments ( $ text ) { if ( is_string ( $ text ) ) { if ( strpos ( $ text , "'" ) !== false || strpos ( $ text , '"' ) !== false ) { $ replaceStringCallback = function ( $ matches ) { return self :: addStringReplacement ( $ matches [ 1 ] . $ matches [ 2 ] . $ matches [ 1 ] ) ; } ;...
Replaces all CSS strings and comments in the given text .
3,842
public static function replaceStringPlaceholders ( $ text , $ deletePlaceholders = false ) { if ( is_string ( $ text ) ) { if ( strpos ( $ text , "_" ) !== false ) { $ replaceStringPlaceholders = function ( $ matches ) use ( $ deletePlaceholders ) { $ result = "" ; if ( isset ( self :: $ replacements [ $ matches [ 1 ] ...
Replaces the string place holders wih the saved strings in a given text .
3,843
public static function removeCommentPlaceholders ( $ text , $ deletePlaceholders = false ) { if ( is_string ( $ text ) ) { if ( strpos ( $ text , "_" ) !== false ) { $ removeStringPlaceholders = function ( $ matches ) use ( $ deletePlaceholders ) { if ( $ deletePlaceholders === true ) { if ( isset ( self :: $ replaceme...
Removes the comment place holders from a given text .
3,844
protected static function addReplacement ( $ string , $ prefix ) { if ( is_string ( $ string ) ) { if ( is_string ( $ prefix ) ) { $ hash = md5 ( self :: $ counter ) ; $ placeholder = "_" . $ prefix . "_" . $ hash . "_" ; self :: $ replacements [ $ hash ] = $ string ; self :: $ counter ++ ; return $ placeholder ; } els...
Adds a replacement to the internal list .
3,845
final private function getRefClass ( ) { if ( $ this -> refClass === null ) { $ this -> refClass = new \ ReflectionClass ( $ this ) ; } return $ this -> refClass ; }
Gets the ReflectionClass object for the current object .
3,846
final public function hasProperty ( $ property ) { if ( ! Str :: is ( $ property ) || ! Str :: match ( $ property , "/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/" ) || $ property == 'this' ) { throw new \ InvalidArgumentException ( "The \$property parameter must be a string and follow the PHP rules of variable naming." )...
Checks if the object has the given property .
3,847
final public function hasMethod ( $ method ) { if ( ! Str :: is ( $ method ) || ! Str :: match ( $ method , "/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/" ) ) { throw new \ InvalidArgumentException ( "The \$method parameter must be a string and follow the PHP rules of method naming." ) ; } return method_exists ( $ this ,...
Checks if the object has the given method .
3,848
public static function download ( $ location , $ filename = null , $ mime = 'application/octet-stream' , $ speed = 1024 , $ disposition = 'attachment' ) { if ( connection_status ( ) != 0 ) return ( false ) ; if ( ! is_file ( $ location ) ) { http_response_code ( 404 ) ; exit ( ) ; } if ( empty ( $ mime ) ) { $ mime = s...
Sends the file to the browser for download
3,849
public static function getFileMime ( $ filename , $ default = 'application/octet-stream' ) { if ( function_exists ( 'mime_content_type' ) ) { return mime_content_type ( $ filename ) ; } $ mime_types = array ( 'txt' => 'text/plain' , 'htm' => 'text/html' , 'html' => 'text/html' , 'php' => 'text/html' , 'css' => 'text/cs...
Get file s mime type
3,850
public static function notice ( $ slug , $ type = null ) { ob_start ( ) ; self :: template ( $ slug , 'notice' ) ; $ result = null ; if ( $ type == null ) { $ result = ob_get_flush ( ) ; } else { $ result = array ( 'message' => ob_get_flush ( ) , 'type' => $ type , ) ; } return $ result ; }
Loads notice templates .
3,851
public function buildErrorResponse ( \ Exception $ e ) { $ response = [ 'type' => get_class ( $ e ) , 'code' => $ e -> getCode ( ) , 'message' => $ e -> getMessage ( ) , 'data' => [ 'status' => 500 ] ] ; if ( $ e instanceof ModelNotFoundException ) { $ response [ 'data' ] [ 'status' ] = 404 ; } if ( $ e instanceof Http...
Given an Exception build a data package suitable for reporting the error to the client .
3,852
public function retrieveCoreStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22CoreStats%22]" ) ; $ coreStats = json_decode ( $ data ) ; return $ coreStats ; }
Retrieve Core Stats
3,853
public function retrieveBadPlayerStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22BadPlayerStats%22]" ) ; $ badPlayerStats = json_decode ( $ data ) ; return $ badPlayerStats ; }
Retrieve Bad Player Stats
3,854
public function retrieveVehicleStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22VehicleStats%22]" ) ; $ vehicleStats = json_decode ( $ data ) ; return $ vehicleStats ; }
Retrieve Vehicle Stats
3,855
public function retrieveMapStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22MapStats%22]" ) ; $ mapStats = json_decode ( $ data ) ; return $ mapStats ; }
Retrieve Map Stats
3,856
public function retrieveGameModeMapStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22GameModeMapStats%22]" ) ; $ gameModeMapStats = json_decode ( $ data ) ; return $ gameModeMapStats ; }
Retrieve Game Mode Map Stats
3,857
public function retrieveWeaponStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22WeaponStats%22]" ) ; $ weapons = json_decode ( $ data ) ; return $ weapons ; }
Retrieve Weapon Stats
3,858
public function retrieveGameModeStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22GameModeStats%22]" ) ; $ gameModeStats = json_decode ( $ data ) ; return $ gameModeStats ; }
Retrieve Game Mode Stats
3,859
public function retrieveRushMapStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22RushMapStats%22]&_?=1351945928776" ) ; $ rushMapStats = json_decode ( $ data ) ; return $ rushMapStats ; }
Retrieve Rush Map Stats
3,860
public function retrieveGameEventStats ( ) { $ data = file_get_contents ( "http://battlefield.play4free.com/en/profile/stats/" . $ this -> _profileID . "/" . $ this -> _soldierID . "?g=[%22GameEventStats%22]" ) ; $ gameEventStats = json_decode ( $ data ) ; return $ gameEventStats ; }
Retrieve Game Event Stats
3,861
public function totalSeconds ( ) : int { return $ this -> days * 86400 + $ this -> h * 3600 + $ this -> i * 60 + $ this -> s ; }
Get the total number of seconds from the DateInterval .
3,862
private function isAuthorized ( Request $ request , Response $ response ) : bool { $ this -> authorized = false ; $ user = $ this -> authenticate ( $ request , $ response ) ; if ( null !== $ user && $ this -> authConstraint -> requiresRoles ( ) ) { $ roles = $ this -> roles ( $ response , $ user ) ; if ( null !== $ rol...
checks if request is authorized
3,863
private function authenticate ( Request $ request , Response $ response ) { $ authenticationProvider = $ this -> injector -> getInstance ( AuthenticationProvider :: class ) ; try { $ user = $ authenticationProvider -> authenticate ( $ request ) ; if ( null == $ user && $ this -> authConstraint -> loginAllowed ( ) ) { $...
checks whether request is authenticated
3,864
private function roles ( Response $ response , User $ user ) { try { return $ this -> injector -> getInstance ( AuthorizationProvider :: class ) -> roles ( $ user ) ; } catch ( AuthProviderException $ ahe ) { $ this -> handleAuthProviderException ( $ ahe , $ response ) ; return null ; } }
checks whether expected role is given
3,865
private function handleAuthProviderException ( AuthProviderException $ ahe , Response $ response ) { if ( $ ahe -> isInternal ( ) ) { $ this -> error = $ response -> internalServerError ( $ ahe ) ; } else { $ response -> setStatusCode ( $ ahe -> getCode ( ) ) ; $ this -> error = new Error ( $ ahe -> getMessage ( ) ) ; ...
sets proper response status code depending on exception
3,866
public function isValid ( ) { $ this -> errorMessages = [ ] ; $ this -> validatorCollection -> rewind ( ) ; while ( $ this -> validatorCollection -> valid ( ) ) { $ this -> checkForErrors ( $ this -> validatorCollection -> current ( ) ) ; $ this -> validatorCollection -> next ( ) ; } $ count = count ( $ this -> errorMe...
Runs the checkForErrors method for each field which adds to errorMessages if invalid
3,867
public function remove ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> items ) ) { throw new CollectionUnknownKeyException ( sprintf ( 'Item name=%s does not exist in collection' , $ name ) ) ; } unset ( $ this -> items [ $ name ] ) ; return true ; }
Remove an item from the collection
3,868
public function get ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> items ) ) { throw new CollectionUnknownKeyException ( sprintf ( 'Item name=%s does not exist in collection' , $ name ) ) ; } return $ this -> items [ $ name ] ; }
Get an item from the collection
3,869
public function processFile ( $ filePath , $ functions ) { $ result = array ( 'problems' => array ( ) , 'fixes' => array ( ) , ) ; $ phpTokens = new PhpFileParser ( $ filePath ) ; $ changes = 0 ; foreach ( $ phpTokens as $ key => $ row ) { if ( is_array ( $ row ) ) { list ( $ token , $ functionName , $ lineNumber ) = $...
Find function calls and extract
3,870
public function hidden ( Form \ Element \ Hidden $ element ) { $ html = html ( 'input' , $ element -> getAttributes ( ) ) ; return $ html ; }
render hidden input
3,871
public function label_date ( Form \ Element \ LabelDate $ element ) { $ html = '<label class="col-md-3 control-label">' . $ element -> getLabel ( ) . '</label>' ; $ html .= '<div class="col-md-9"><p class="form-control-static">' . $ element -> getDisplayValue ( ) . '</p></div>' ; $ class = Style :: FORM_GROUP_CLASS . '...
Render Label Date
3,872
public function image ( Form \ Element \ Image $ element ) { $ element -> addStyle ( 'object-fit' , 'cover !important;' ) ; $ element -> addAttribute ( 'src' , $ element -> getValue ( ) ) ; $ html = '<label class="col-md-3 control-label">' . $ element -> getLabel ( ) . '</label>' ; $ html .= '<div class="col-md-9"><p c...
Render Image input
3,873
public function button ( Form \ Element \ Button $ element ) { $ element -> addClass ( 'btn btn-default' ) ; $ element -> addAttribute ( 'id' , $ element -> getName ( ) ) ; $ html = '<div class="form-group">' ; $ html .= '<label class="col-md-3 control-label">&nbsp;</label>' ; $ html .= '<div class="col-md-9">' . html ...
rende a button element
3,874
public function date_range ( Form \ Element \ DateRange $ element ) { $ class = Style :: FORM_GROUP_CLASS ; if ( $ hasError = ! $ element -> getValidator ( ) -> isValid ( ) ) { if ( empty ( $ element -> getAttribute ( 'data-placement' ) ) ) { $ element -> addAttribute ( 'data-placement' , 'bottom' ) ; } $ message = '' ...
Render a date range element
3,875
protected function parseRuleString ( $ ruleString ) { $ ruleString = preg_replace ( '/^[ \r\n\t\f]*@page[ \r\n\t\f]*/i' , '' , $ ruleString ) ; $ ruleString = trim ( $ ruleString , " \r\n\t\f" ) ; $ pageSelector = new PageSelector ( $ ruleString , $ this -> getStyleSheet ( ) ) ; $ this -> setSelector ( $ pageSelector )...
Parses the page rule .
3,876
public function createDocumentManager ( $ mongouri , $ dbName , $ debug = false , $ managerId = "" , $ newConnection = false , $ options = [ ] ) { if ( ! isset ( $ this -> connexions [ $ mongouri ] ) ) { $ client = new Client ( $ mongouri ) ; } if ( ! isset ( $ this -> managers [ $ managerId ] ) ) { $ database = new Da...
Create new DocumentManager from mongouri and DB name
3,877
protected function getFillableReplace ( ) { $ attributes = array_merge ( $ this -> data [ 'normal_fillable' ] , $ this -> data [ 'translated_fillable' ] ) ; if ( ! count ( $ attributes ) ) return '' ; return $ this -> getAttributePropertySection ( 'fillable' , $ attributes ) ; }
Returns the replacement for the fillable placeholder
3,878
protected function getCastsReplace ( ) { $ attributes = $ this -> data [ 'casts' ] ? : [ ] ; if ( ! count ( $ attributes ) ) return '' ; $ longestLength = 0 ; foreach ( $ attributes as $ attribute => $ type ) { if ( strlen ( $ attribute ) > $ longestLength ) { $ longestLength = strlen ( $ attribute ) ; } } $ replace = ...
Returns the replacement for the casts placeholder
3,879
protected function getDefaultsReplace ( ) { if ( ! config ( 'pxlcms.generator.models.include_defaults' ) ) return '' ; $ attributes = $ this -> data [ 'defaults' ] ? : [ ] ; if ( ! count ( $ attributes ) ) return '' ; $ longestLength = 0 ; foreach ( $ attributes as $ attribute => $ default ) { if ( strlen ( $ attribute...
Returns the replacement for the default attributes placeholder
3,880
public function updateDataFixutreHistory ( array $ updateFields , $ where , array $ parameters = [ ] ) { $ qb = $ this -> _em -> createQueryBuilder ( ) -> update ( 'OkvpnFixtureBundle:DataFixture' , 'm' ) -> where ( $ where ) ; foreach ( $ updateFields as $ fieldName => $ fieldValue ) { $ qb -> set ( $ fieldName , $ fi...
Update data fixture history
3,881
public static function is ( array $ arr ) { $ isdot = true ; foreach ( $ arr as $ key => $ value ) { if ( ! ( $ isdot = ( $ isdot && ! Str :: contains ( $ key , '.' ) ) ) ) { break ; } if ( is_array ( $ value ) ) { $ isdot = ( $ isdot && static :: is ( $ value ) ) ; } } return $ isdot ; }
Tests if the given value is a dot - notated accessible array .
3,882
protected static function getMultiple ( array $ arr , array $ keys , $ default = null ) { $ return = [ ] ; foreach ( $ keys as $ key ) { $ return [ $ key ] = static :: get ( $ arr , $ key , $ default ) ; } return $ return ; }
Gets multiple values from a dot - notated array .
3,883
protected static function setMultiple ( array & $ arr , array $ keyvals ) { foreach ( $ keyvals as $ key => $ value ) { static :: set ( $ arr , $ key , $ value ) ; } }
Sets multiple values to a dot - notated array .
3,884
protected static function deleteMultiple ( array & $ arr , array $ keys ) { $ return = [ ] ; foreach ( $ keys as $ key ) { $ return [ $ key ] = static :: delete ( $ arr , $ key ) ; } return $ return ; }
Deletes multiple items from a dot - notated array .
3,885
protected static function keyExistsMultiple ( array $ arr , array $ keys ) { $ return = [ ] ; foreach ( $ keys as $ key ) { $ return [ $ key ] = static :: keyExists ( $ arr , $ key ) ; } return $ return ; }
Verifies if multiple keys exists in a dot - notated array or not .
3,886
protected static function keyMatchesMultiple ( array $ arr , array $ keys ) { $ return = [ ] ; foreach ( $ keys as $ key ) { $ return [ $ key ] = static :: keyMatches ( $ arr , $ key ) ; } return $ return ; }
Gets full and partial matches to multiple keys .
3,887
public static function convert ( array $ arr ) { $ converted = [ ] ; foreach ( $ arr as $ key => $ value ) { $ keys = explode ( '.' , $ key ) ; $ tmp = & $ converted ; foreach ( $ keys as $ k ) { if ( ! array_key_exists ( $ k , $ tmp ) || ! is_array ( $ tmp [ $ k ] ) ) { $ tmp [ $ k ] = [ ] ; } $ tmp = & $ tmp [ $ k ] ...
Converts an array to a dot - notated array .
3,888
public function registerEventHandler ( $ event , callable $ handler ) { if ( empty ( $ event ) ) { throw new InvalidArgumentException ( 'Event name is required' ) ; } if ( is_callable ( $ handler ) ) { if ( empty ( $ this -> event_handlers [ $ event ] ) ) { $ this -> event_handlers [ $ event ] = [ ] ; } $ this -> event...
Register an internal event handler .
3,889
private static function domain ( string $ url ) : ? string { $ domain = parse_url ( $ url , PHP_URL_HOST ) ; if ( null !== $ domain ) { return implode ( '.' , array_slice ( explode ( '.' , $ domain ) , - 2 ) ) ; } return null ; }
Returns the domain name from URL .
3,890
static public function getLabel ( $ code ) { static :: isValid ( $ code ) ; switch ( $ code ) { case static :: EBP : return 'Euro Business Parcel' ; case static :: GBP : return 'Global Business Parcel' ; case static :: EP : return 'Express Parcel Guaranteed' ; case static :: SHD : return 'Shop Delivery Service' ; case ...
Returns the label for the given product code .
3,891
static function getUniShip ( $ code ) { static :: isValid ( $ code ) ; switch ( $ code ) { case static :: EBP : return 'CC' ; case static :: GBP : return 'FF' ; case static :: EP : case static :: SHD : case static :: FDF : return null ; case static :: BP : default : return 'AA' ; } }
Returns the UNI Ship equivalent product code .
3,892
public function transformEntity ( $ entity , $ transformer = null , SerializerAbstract $ serializer = null ) : array { $ transformer = $ transformer ? : $ this -> getTransformerFromClassProperty ( ) ; $ results = $ this -> transform ( ) -> resourceWith ( $ entity , $ transformer ) -> usingPaginatorIfPaged ( ) ; if ( $ ...
Shortcut method for serializing and transforming an entity .
3,893
protected function getTransformerFromClassProperty ( ) { if ( ! isset ( $ this -> transformer ) || ! $ this -> isTransformer ( $ this -> transformer ) ) { throw new \ InvalidArgumentException ( 'You cannot transform the entity without providing a valid Transformer. Verify your transformer extends ' . TransformerAbstrac...
Gets the transformer from the class and validates it s a correct serializer .
3,894
protected function mapApiRoutes ( ) { Route :: group ( [ 'middleware' => 'api' , 'namespace' => $ this -> namespace . '\Api' , 'domain' => config ( 'hstcms.apiDomain' ) ? config ( 'hstcms.apiDomain' ) : env ( 'APP_URL' ) , 'prefix' => config ( 'hstcms.apiDomain' ) ? '' : config ( 'hstcms.apiPrefix' ) ? config ( 'hstcms...
Define the api routes for the module .
3,895
private function setUrl ( Url $ url ) { $ urlValidationRegex = '_https:\/\/hooks.slack.com\/services\/[\w\/]+$_iuS' ; if ( ! preg_match ( $ urlValidationRegex , ( string ) $ url ) ) { throw new InvalidUrlException ( sprintf ( 'The url: "%s" is not a valid url. Slack webhook urls should always start ...
This wil set the url if it is valid .
3,896
public function dec ( ) : array { $ colors = str_split ( $ this -> hex ( 'no-hash' ) , 2 ) ; return array_map ( function ( $ color ) { return hexdec ( $ color ) ; } , $ colors ) ; }
Get the CSS decimal color .
3,897
public static function validateHexColorString ( string $ hex ) : bool { $ length = strlen ( ltrim ( $ hex , '#' ) ) ; switch ( $ length ) { case 3 : break ; case 6 : break ; default : return false ; } return preg_match ( '/^#?[0-9a-fA-F]{3,6}$/' , $ hex ) === 1 ; }
Validates CSS hexadecimal color .
3,898
public function upload ( ThumbnailRequest $ request ) { $ crudeName = $ request -> input ( 'crudeName' ) ; $ crude = CrudeInstance :: get ( $ crudeName ) ; $ column = $ request -> input ( 'columnName' ) ; $ file = $ request -> file ( ) [ 'file' ] ; $ id = $ request -> input ( 'modelId' ) ; $ model = $ crude -> uploadTh...
Handle thumbnail upload
3,899
public function delete ( ThumbnailRequest $ request ) { $ crudeName = $ request -> input ( 'crudeName' ) ; $ crude = CrudeInstance :: get ( $ crudeName ) ; $ id = $ request -> input ( 'model_id' ) ; $ column = $ request -> input ( 'model_column' ) ; $ model = $ crude -> deleteThumbnailByIdAndColumn ( $ id , $ column ) ...
delete thumbnail file